summaryrefslogtreecommitdiff
path: root/tools/genv8constants.py
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2012-12-27 07:16:23 +0400
committerFedor Indutny <fedor.indutny@gmail.com>2013-01-07 23:04:11 +0400
commitf9afb3f01002e5667a0df80ee784af0dfe2305c2 (patch)
treedb72374b9be16c1b69385ddfe547fded9340923d /tools/genv8constants.py
parent13296e4b13b5ed192c4faa6501f3efec2ded8ac1 (diff)
downloadandroid-node-v8-f9afb3f01002e5667a0df80ee784af0dfe2305c2.tar.gz
android-node-v8-f9afb3f01002e5667a0df80ee784af0dfe2305c2.tar.bz2
android-node-v8-f9afb3f01002e5667a0df80ee784af0dfe2305c2.zip
dtrace: x64 ustack helper
Diffstat (limited to 'tools/genv8constants.py')
-rwxr-xr-xtools/genv8constants.py52
1 files changed, 35 insertions, 17 deletions
diff --git a/tools/genv8constants.py b/tools/genv8constants.py
index efc644152d..fb8b5ffa8c 100755
--- a/tools/genv8constants.py
+++ b/tools/genv8constants.py
@@ -18,8 +18,10 @@ if len(sys.argv) != 3:
outfile = file(sys.argv[1], 'w');
pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
bufsize=-1, stdout=subprocess.PIPE).stdout;
-pattern = re.compile('00000000 <(v8dbg_.*)>:');
-numpattern = re.compile('[0-9a-fA-F]{2}');
+pattern = re.compile('(00000000|0000000000000000) <(.*)>:');
+v8dbg = re.compile('^v8dbg.*$')
+numpattern = re.compile('^[0-9a-fA-F]{2} $');
+octets = 4
outfile.write("""
/*
@@ -32,13 +34,27 @@ outfile.write("""
#ifndef V8_CONSTANTS_H
#define V8_CONSTANTS_H
-#if defined(__i386)
""");
curr_sym = None;
curr_val = 0;
curr_octet = 0;
+def out_reset():
+ global curr_sym, curr_val, curr_octet
+ curr_sym = None;
+ curr_val = 0;
+ curr_octet = 0;
+
+def out_define():
+ global curr_sym, curr_val, curr_octet, outfile, octets
+ if curr_sym != None:
+ if curr_val & 0x80000000 != 0:
+ outfile.write("#define %s -0x%x\n" % (curr_sym.upper(), 0x100000000 - curr_val));
+ else:
+ outfile.write("#define %s 0x%x\n" % (curr_sym.upper(), curr_val));
+ out_reset();
+
for line in pipe:
if curr_sym != None:
#
@@ -51,32 +67,34 @@ for line in pipe:
for i in range (0, 3):
# 6-character margin, 2-characters + 1 space for each field
idx = 6 + i * 3;
- octetstr = line[idx:idx+2]
+ octetstr = line[idx:idx+3]
if not numpattern.match(octetstr):
break;
+ if curr_octet > octets:
+ break;
+
curr_val += int('0x%s' % octetstr, 16) << (curr_octet * 8);
curr_octet += 1;
- if curr_octet < 4:
- continue;
-
- outfile.write("#define %s 0x%x\n" % (curr_sym.upper(), curr_val));
- curr_sym = None;
- curr_val = 0;
- curr_octet = 0;
- continue;
-
match = pattern.match(line)
if match == None:
continue;
- curr_sym = match.group(1);
+ octets = len(match.group(1)) / 2;
+
+ # Print previous symbol
+ out_define();
+
+ v8match = v8dbg.match(match.group(2));
+ if v8match != None:
+ out_reset();
+ curr_sym = match.group(2);
+
+# Print last symbol
+out_define();
outfile.write("""
-#else
-#error "only i386 is supported for DTrace ustack helper"
-#endif
#endif /* V8_CONSTANTS_H */
""");