jump顧名思義就是跳到某一行開始執行, 而且是會立刻執行直到遇到breakpoint. 因為jump並不會對stack, memory, 或register有任何改變(除了PC/program counter), 也因此jump的範圍需要在同一個function內部, 避免crash.
你也可以用set $pc=<execute_address> + "continue", "next", "step"替代
Type "apropos word" to search for commands related to "word"... Reading symbols from a.out...done. (gdb) set listsize unlimited (gdb) list 1 #include <stdio.h> 2 3 static void possible_crash_1(void) 4 { 5 printf("%s(#%d)\n", __FUNCTION__, __LINE__); 6 } 7 8 static void possible_crash_2(void) 9 { 10 printf("%s(#%d)\n", __FUNCTION__, __LINE__); 11 } 12 13 static void possible_crash_3(void) 14 { 15 printf("%s(#%d)\n", __FUNCTION__, __LINE__); 16 } 17 18 int main(int argc, char *argv[]) 19 { 20 possible_crash_1(); 21 22 possible_crash_2(); 23 24 possible_crash_3(); 25 26 return 0; 27 } 28 (gdb) b main Breakpoint 1 at 0x400576: file jump.c, line 20. (gdb) run Starting program: /build/brook/a.out Breakpoint 1, main (argc=1, argv=0x7fffffffe4e8) at jump.c:20 20 possible_crash_1(); (gdb) j 22 Continuing at 0x40057b. possible_crash_2(#10) possible_crash_3(#15) [Inferior 1 (process 9816) exited normally] (gdb) run Starting program: /build/brook/a.out Breakpoint 1, main (argc=1, argv=0x7fffffffe4e8) at jump.c:20 20 possible_crash_1(); (gdb) set $pc=0x40057b (gdb) n possible_crash_2(#10) 24 possible_crash_3(); (gdb) n possible_crash_3(#15) 26 return 0;
- https://sourceware.org/gdb/download/onlinedocs/gdb/Jumping.html#Jumping, 17.2 Continuing at a Different Address
沒有留言:
張貼留言