[英]gdb C code in linux - Address out of bounds
I have the following C code: 我有以下C代码:
#include <stdio.h>
char strA[80] = {"string to be used for demonstration purposes."};
char strB[80];
int main(void){
char *pA; //A pointer to type char
char *pB; //Another pointer to type char
puts(strA); //Show string A
pA = strA; //Point pA to string A
puts(pA); //Show what pA is pointing to
//printf("pA = %s", pA);
pB = strB; //Point pB to string B
putchar('\n'); //Move down one line on the screen
while(*pA != '\0'){
*pB++ = *pA++;
}
*pB = '\0';
puts(strB); //Show string B on the screen
return 0;
}
now I use gdb for debugging and I do following steps: 现在我使用gdb进行调试,并执行以下步骤:
gdb str
break main
run
x/s $esp
but here I get the "Address out if bounds" error... could any body tell me how I can solve it? 但在这里我得到了“如果有界限的地址”错误......任何人都可以告诉我如何解决它? thank you
谢谢
That's because you're on a 64 bit machine, $esp is a 32 bit register. 那是因为你在64位机器上,$ esp是一个32位寄存器。 You'll want to do
x/s
$rsp 你想做
x/s
$ rsp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.