简体   繁体   English

在lldb中获取GDB x命令输出

[英]Getting GDB x command output in lldb

Compiled a simple hello world program with gcc. 用gcc编译了一个简单的hello world程序。

int main( int argc, char** argv )
{
  printf( "hello, world!\n" );
  printf( "Vale!\n" );

  return 0;
}

otool -lV a gives me the following: otool -lV a给我以下内容:

Section
  sectname __stubs
   segname __TEXT
      addr 0x0000000100000f7a
      size 0x0000000000000006
    offset 3962
     align 2^1 (2)
    reloff 0
    nreloc 0
      type S_SYMBOL_STUBS
attributes PURE_INSTRUCTIONS SOME_INSTRUCTIONS
 reserved1 0 (index into indirect symbol table)
 reserved2 6 (size of stubs)

When I use gdb, I get: 当我使用gdb时,我得到:

gdb ./a
(gdb) x/2i 0x0000000100000f7a
   0x100000f7a: jmpq   *0x90(%rip)            # 0x100001010
   0x100000f80: lea    0x81(%rip),%r11        # 0x100001008

It is the values # 0x100001010 and # 0x100001008 that I am interested in getting when using lldb, but when I use lldb, what I see: 使用lldb时我感兴趣的是#0x100001010和#0x100001008值,但是当我使用lldb时,我看到的是:

lldb ./a
(lldb) x/2i 0x0000000100000f7a
0x100000f7a:  ff 25 90 00 00 00  jmpq   *0x90(%rip)
0x100000f80:  00 00              addb   %al, (%rax)

Is there any way to get lldb to provide the same values ( # 0x100001010 and # 0x100001008 ) that gdb does? 有什么方法可以使lldb提供与gdb相同的值(#0x100001010和#0x100001008)?

Use disassemble -s , for instance to find & dump the STUBS section. 例如,使用disassemble -s查找并转储STUBS部分。 You can provide a count as well as a start address, though for some reason when I build your little example there's only one external reference in the stubs section. 您可以提供一个计数以及一个起始地址,尽管由于某些原因,当我构建您的小示例时,在存根部分只有一个外部引用。

So, for instance: 因此,例如:

(lldb) image dump sections foo
Sections for '/private/tmp/foo' (x86_64):
  SectID     Type             File Address                             File Off.  File Size  Flags      Section Name
  ---------- ---------------- ---------------------------------------  ---------- ---------- ---------- ----------------------------
  0x00000100 container        [0x0000000000000000-0x0000000100000000)  0x00000000 0x00000000 0x00000000 foo.__PAGEZERO
  0x00000200 container        [0x0000000100000000-0x0000000100001000)  0x00000000 0x00001000 0x00000000 foo.__TEXT
  0x00000001 code             [0x0000000100000f20-0x0000000100000f68)  0x00000f20 0x00000048 0x80000400 foo.__TEXT.__text
  0x00000002 code             [0x0000000100000f68-0x0000000100000f6e)  0x00000f68 0x00000006 0x80000408 foo.__TEXT.__stubs
  0x00000003 code             [0x0000000100000f70-0x0000000100000f8a)  0x00000f70 0x0000001a 0x80000400 foo.__TEXT.__stub_helper
  0x00000004 data-cstr        [0x0000000100000f8a-0x0000000100000fa0)  0x00000f8a 0x00000016 0x00000002 foo.__TEXT.__cstring
  0x00000005 regular          [0x0000000100000fa0-0x0000000100000fe8)  0x00000fa0 0x00000048 0x00000000 foo.__TEXT.__unwind_info
  0x00000006 eh-frame         [0x0000000100000fe8-0x0000000100001000)  0x00000fe8 0x00000018 0x00000000 foo.__TEXT.__eh_frame
  0x00000300 container        [0x0000000100001000-0x0000000100002000)  0x00001000 0x00001000 0x00000000 foo.__DATA
  0x00000007 data-ptrs        [0x0000000100001000-0x0000000100001010)  0x00001000 0x00000010 0x00000006 foo.__DATA.__nl_symbol_ptr
  0x00000008 data-ptrs        [0x0000000100001010-0x0000000100001018)  0x00001010 0x00000008 0x00000007 foo.__DATA.__la_symbol_ptr
  0x00000400 container        [0x0000000100002000-0x0000000100003000)  0x00002000 0x00000200 0x00000000 foo.__LINKEDIT
  0x00000200 container        [0x0000000100003000-0x0000000100004000)  0x00002000 0x000002ce 0x00000000 foo.__DWARF
  0x00000001 dwarf-abbrev     [0x0000000100003000-0x000000010000304c)  0x00002000 0x0000004c 0x00000000 foo.__DWARF.__debug_abbrev
  0x00000002 dwarf-aranges    [0x000000010000304c-0x000000010000307c)  0x0000204c 0x00000030 0x00000000 foo.__DWARF.__debug_aranges
  0x00000003 dwarf-info       [0x000000010000307c-0x00000001000030f8)  0x0000207c 0x0000007c 0x00000000 foo.__DWARF.__debug_info
  0x00000004 dwarf-line       [0x00000001000030f8-0x0000000100003137)  0x000020f8 0x0000003f 0x00000000 foo.__DWARF.__debug_line
  0x00000005 dwarf-pubnames   [0x0000000100003137-0x0000000100003152)  0x00002137 0x0000001b 0x00000000 foo.__DWARF.__debug_pubnames
  0x00000006 dwarf-pubtypes   [0x0000000100003152-0x0000000100003175)  0x00002152 0x00000023 0x00000000 foo.__DWARF.__debug_pubtypes
  0x00000007 dwarf-str        [0x0000000100003175-0x00000001000031d8)  0x00002175 0x00000063 0x00000000 foo.__DWARF.__debug_str
  0x00000008 apple-names      [0x00000001000031d8-0x0000000100003214)  0x000021d8 0x0000003c 0x00000000 foo.__DWARF.__apple_names
  0x00000009 apple-types      [0x0000000100003214-0x0000000100003286)  0x00002214 0x00000072 0x00000000 foo.__DWARF.__apple_types
  0x0000000a apple-namespaces [0x0000000100003286-0x00000001000032aa)  0x00002286 0x00000024 0x00000000 foo.__DWARF.__apple_namespac
  0x0000000b apple-objc       [0x00000001000032aa-0x00000001000032ce)  0x000022aa 0x00000024 0x00000000 foo.__DWARF.__apple_objc
(lldb) disassemble -s 0x0000000100000f68 
foo`symbol stub for: printf:
foo[0x100000f68]:  jmpq   *0xa2(%rip)               ; (void *)0x0000000100000f80

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM