Do not patch the instruction address when symbolizing the reports.

Instead, print the correct address at runtime.

llvm-svn: 165018
This commit is contained in:
Alexander Potapenko 2012-10-02 15:42:24 +00:00
parent f97cb15aee
commit 77c0ac2336
3 changed files with 11 additions and 33 deletions

View File

@ -146,39 +146,8 @@ class DarwinSymbolizer(Symbolizer):
self.vmaddr = None
self.pipe = None
def get_binary_vmaddr(self):
"""Get the slide value to be added to the address.
We're looking for the following piece in otool -l output:
Load command 0
cmd LC_SEGMENT
cmdsize 736
segname __TEXT
vmaddr 0x00000000
"""
if self.vmaddr:
return self.vmaddr
cmdline = ['otool', '-l', self.binary]
pipe = subprocess.Popen(cmdline,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
is_text = False
vmaddr = 0
for line in pipe.stdout:
line = line.strip()
if line.startswith('segname'):
is_text = (line == 'segname __TEXT')
continue
if line.startswith('vmaddr') and is_text:
sv = line.split(' ')
vmaddr = int(sv[-1], 16)
break
self.vmaddr = vmaddr
return self.vmaddr
def write_addr_to_pipe(self, offset):
slide = self.get_binary_vmaddr()
print >> self.pipe.stdin, '0x%x' % (int(offset, 16) + slide)
print >> self.pipe.stdin, '0x%x' % int(offset, 16)
def open_atos(self):
if DEBUG:

View File

@ -151,6 +151,7 @@ void MemoryMappingLayout::Reset() {
current_load_cmd_count_ = -1;
current_load_cmd_addr_ = 0;
current_magic_ = 0;
current_filetype_ = 0;
}
// Next and NextSegmentLoad were inspired by base/sysinfo.cc in
@ -171,7 +172,13 @@ bool MemoryMappingLayout::NextSegmentLoad(
const SegmentCommand* sc = (const SegmentCommand *)lc;
if (start) *start = sc->vmaddr + dlloff;
if (end) *end = sc->vmaddr + sc->vmsize + dlloff;
if (offset) *offset = sc->fileoff;
if (offset) {
if (current_filetype_ == /*MH_EXECUTE*/ 0x2) {
*offset = sc->vmaddr;
} else {
*offset = sc->fileoff;
}
}
if (filename) {
internal_strncpy(filename, _dyld_get_image_name(current_image_),
filename_size);
@ -190,6 +197,7 @@ bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
// Set up for this image;
current_load_cmd_count_ = hdr->ncmds;
current_magic_ = hdr->magic;
current_filetype_ = hdr->filetype;
switch (current_magic_) {
#ifdef MH_MAGIC_64
case MH_MAGIC_64: {

View File

@ -84,6 +84,7 @@ class MemoryMappingLayout {
char filename[], uptr filename_size);
int current_image_;
u32 current_magic_;
u32 current_filetype_;
int current_load_cmd_count_;
char *current_load_cmd_addr_;
# endif