-
-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #597 from JohanMabille/debugger
Implementation of the debugger
- Loading branch information
Showing
11 changed files
with
587 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from IPython.core.compilerop import CachingCompiler | ||
import tempfile | ||
import os | ||
|
||
def murmur2_x86(data, seed): | ||
m = 0x5bd1e995 | ||
length = len(data) | ||
h = seed ^ length | ||
rounded_end = (length & 0xfffffffc) | ||
for i in range(0, rounded_end, 4): | ||
k = (ord(data[i]) & 0xff) | ((ord(data[i + 1]) & 0xff) << 8) | \ | ||
((ord(data[i + 2]) & 0xff) << 16) | (ord(data[i + 3]) << 24) | ||
k = (k * m) & 0xffffffff | ||
k ^= k >> 24 | ||
k = (k * m) & 0xffffffff | ||
|
||
h = (h * m) & 0xffffffff | ||
h ^= k | ||
|
||
val = length & 0x03 | ||
k = 0 | ||
if val == 3: | ||
k = (ord(data[rounded_end + 2]) & 0xff) << 16 | ||
if val in [2, 3]: | ||
k |= (ord(data[rounded_end + 1]) & 0xff) << 8 | ||
if val in [1, 2, 3]: | ||
k |= ord(data[rounded_end]) & 0xff | ||
h ^= k | ||
h = (h * m) & 0xffffffff | ||
|
||
h ^= h >> 13 | ||
h = (h * m) & 0xffffffff | ||
h ^= h >> 15 | ||
|
||
return h | ||
|
||
def get_tmp_directory(): | ||
tmp_dir = tempfile.gettempdir() | ||
pid = os.getpid() | ||
return tmp_dir + '/ipykernel_' + str(pid) | ||
|
||
def get_tmp_hash_seed(): | ||
hash_seed = 0xc70f6907 | ||
return hash_seed | ||
|
||
def get_file_name(code): | ||
name = murmur2_x86(code, get_tmp_hash_seed()) | ||
return get_tmp_directory() + '/' + str(name) + '.py' | ||
|
||
class XCachingCompiler(CachingCompiler): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(XCachingCompiler, self).__init__(*args, **kwargs) | ||
self.filename_mapper = None | ||
self.log = None | ||
|
||
def get_code_name(self, raw_code, code, number): | ||
filename = get_file_name(raw_code) | ||
|
||
if self.filename_mapper is not None: | ||
self.filename_mapper(filename, number) | ||
|
||
return filename | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.