版权声明:欢迎转发,转发请标明出处 https://blog.csdn.net/weixin_39465823/article/details/88933581
我这里是跳转到11行,跳转过去会执行,执行报错,所以终止了(例1)。也可以跳转到函数(例2)。
例1:
(gdb) b 31
Breakpoint 1 at 0x870: file mystrcopy.c, line 31.
(gdb) r
Starting program: /home/gyz/mc/mystrcopy
copying string!
Breakpoint 1, main (argv=1, argc=0x7fffffffe238) at mystrcopy.c:31
31 MyStringCopy(str3,str2);
(gdb) s
MyStringCopy (s1=0x0, s2=0x7fffffffe0e0 "copying string!") at mystrcopy.c:7
7 if(NULL == s1)
(gdb) jump 11
Continuing at 0x555555554765.
Program received signal SIGSEGV, Segmentation fault.
0x0000555555554786 in MyStringCopy (
s1=0x1 <error: Cannot access memory at address 0x1>,
s2=0x7fffffffe0e0 "copying string!") at mystrcopy.c:14
14 while(0 != (*p++ = *s1++));
(gdb)
例2:
(gdb) jump PrintNumbers:2
Line 19 is not in `main'. Jump anyway? (y or n) y
Continuing at 0x5555555547a0.
[Inferior 1 (process 4376) exited normally]
(gdb)