简体   繁体   English

gdb 如何简化内存地址/偏移量?

[英]gdb how to simplify memory address/offset?

This is my sample c code这是我的示例 c 代码

user@linux:~$ gdb -q hello
Reading symbols from hello...done.
(gdb) 
(gdb) list 
1   #include<stdio.h>
2   
3   int main()
4   {
5       printf("Hello World!\n");
6       return 0;
7   }
8   

And this is it's assembly code.这是它的汇编代码。

(gdb) disassemble main 
Dump of assembler code for function main:
   0x000000000000063a <+0>: push   %rbp
   0x000000000000063b <+1>: mov    %rsp,%rbp
   0x000000000000063e <+4>: lea    0x9f(%rip),%rdi        # 0x6e4
   0x0000000000000645 <+11>:    callq  0x510 <puts@plt>
   0x000000000000064a <+16>:    mov    $0x0,%eax
   0x000000000000064f <+21>:    pop    %rbp
   0x0000000000000650 <+22>:    retq   
End of assembler dump.
(gdb) 

The memory address contains 18 character and most of them is number 0 .内存地址包含 18 个字符,其中大部分是数字0

Instead of displaying all numbers, would it be possible to simplify it?不是显示所有数字,是否可以简化它?

Let say 0x63a instead of 0x000000000000063a假设0x63a而不是0x000000000000063a

The memory address contains 18 character and most of them is number 0内存地址包含 18 个字符,其中大部分是数字 0

There is no "the memory" here.这里没有“记忆”。 You are apparently talking about displaying addresses.您显然是在谈论显示地址。

Let say 0x63a instead of 0x000000000000063a假设 0x63a 而不是 0x000000000000063a

You are on a 64-bit system, and every address is exactly 64-bits.你是一个64位系统上,每个地址正好是64位。 Displaying addresses as something other than a 64-bit number would be very confusing.将地址显示为 64 位以外的数字会非常混乱。

PS You have a position-independent executable. PS 你有一个与位置无关的可执行文件。 It doesn't actually run at address 0x000000000000063a .实际上并不在地址0x000000000000063a运行 If you use start and disas main , you will get a very different result.如果你使用startdisas main ,你会得到非常不同的结果。

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

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