Assembly x86 Programming Debugging (GDB):如何通过高级索引打印出数据
Assembly x86 Programming Debugging (GDB): How to print out data through advancing indexing
我想知道如何在 GDB 中通过高级索引打印出数据?例如,假设我想打印出 8(%ebp) 处的值以获取传递给函数的第一个参数。我该怎么做?以下命令似乎不起作用:
p (int)8 ($esp)
我总是遇到这个分段错误:
Program received signal SIGSEGV, Segmentation fault. 0x00000008 in ??
() The program being debugged was signaled while in a function called
from GDB. GDB remains in the frame where the signal was received. To
change this behavior use "set unwindonsignal on". Evaluation of the
expression containing the function (at 0x0x8) will be abandoned. When
the function is done executing, GDB will silently stop.
我认为 8($esp)
尝试将 8
作为函数调用,并以 %esp
作为参数。 (但是绝对地址 8
不在有效的可执行页面中)。请记住,GDB 使用 GDB 的类 C 语法,而不是 AT&T 汇编寻址模式语法。
寄存器 + 偏移算不上“高级索引”,但无论如何,它很容易转换为 GDB 表达式:
x $esp + 8
x
命令检查该地址的内存。使用 help x
查看格式化选项和要显示的元素数量。 p
将打印地址,除非您将其转换为指针并像 p *(int*)(8 + $esp)
那样取消引用它
我想知道如何在 GDB 中通过高级索引打印出数据?例如,假设我想打印出 8(%ebp) 处的值以获取传递给函数的第一个参数。我该怎么做?以下命令似乎不起作用:
p (int)8 ($esp)
我总是遇到这个分段错误:
Program received signal SIGSEGV, Segmentation fault. 0x00000008 in ?? () The program being debugged was signaled while in a function called from GDB. GDB remains in the frame where the signal was received. To change this behavior use "set unwindonsignal on". Evaluation of the expression containing the function (at 0x0x8) will be abandoned. When the function is done executing, GDB will silently stop.
我认为 8($esp)
尝试将 8
作为函数调用,并以 %esp
作为参数。 (但是绝对地址 8
不在有效的可执行页面中)。请记住,GDB 使用 GDB 的类 C 语法,而不是 AT&T 汇编寻址模式语法。
寄存器 + 偏移算不上“高级索引”,但无论如何,它很容易转换为 GDB 表达式:
x $esp + 8
x
命令检查该地址的内存。使用 help x
查看格式化选项和要显示的元素数量。 p
将打印地址,除非您将其转换为指针并像 p *(int*)(8 + $esp)