4 # genv8constants.py output_file libv8_base.a
6 # Emits v8dbg constants stored in libv8_base.a in a format suitable for the V8
14 if len(sys.argv) != 3:
15 print "usage: objsym.py outfile libv8_base.a"
18 outfile = file(sys.argv[1], 'w');
19 pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ],
20 stdout=subprocess.PIPE).stdout;
21 pattern = re.compile('00000000 <(v8dbg_.*)>:');
22 numpattern = re.compile('[0-9a-fA-F]{2}');
26 * File automatically generated by genv8constants. Do not edit.
28 * The following offsets are dynamically from libv8_base.a. See src/v8ustack.d
29 * for details on how these values are used.
32 #ifndef V8_CONSTANTS_H
33 #define V8_CONSTANTS_H
45 # This bit of code has nasty knowledge of the objdump text output
46 # format, but this is the most obvious robust approach. We could almost
47 # rely on looking at numbered fields, but some instructions look very
48 # much like hex numbers (e.g., "adc"), and we don't want to risk picking
49 # those up by mistake, so we look at character-based columns intead.
51 for i in range (0, 3):
52 # 6-character margin, 2-characters + 1 space for each field
54 octetstr = line[idx:idx+2]
55 if not numpattern.match(octetstr):
58 curr_val += int('0x%s' % octetstr, 16) << (curr_octet * 8);
64 outfile.write("#define %s 0x%x\n" % (curr_sym.upper(), curr_val));
70 match = pattern.match(line)
74 curr_sym = match.group(1);
78 #error "only i386 is supported for DTrace ustack helper"
81 #endif /* V8_CONSTANTS_H */