Perintah checkpoint

Membuat checkpoint baru

Syntax

checkpoint

Keterangan

Checkpoint GDB adalah proses terpisah yang dibuat dengan menyalin keadaan proses yang sedang di-debug menggunakan fungsi fork(). Setelah dibuat, proses checkpoint akan tetap ditangguhkan sampai dipilih menggunakan perintah restart. Anda dapat kembali ke proses utama dengan menjalankan perintah restart dengan nomor checkpoint 0.

Contoh

Kami akan mendemonstrasikan penggunaan perintah checkpoint menggunakan program C++ dasar yang mengiterasi dari 0 hingga 9 dan menampilkan pesan di setiap iterasi:

#include <stdio.h> int main(int argc, char **argv) {   for(int i = 0; i < argc; i++)     printf("Arg %d: %s\n", i, argv[i]);   return 0; }

Kami akan membuat checkpoint pada iterasi 0, menjalankan program hingga iterasi 3, mengembalikan checkpoint, menjalankan beberapa iterasi di sana, dan kembali ke cabang utama:

(gdb) break report Breakpoint 1 at 0x8048453: file test.cpp, line 6. (gdb) run Starting program: /home/bazis/test Breakpoint 1, report (iteration=0) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) checkpoint checkpoint: fork returned pid 2003. (gdb) continue 3 Will ignore next 2 crossings of breakpoint 1. Continuing. Pid 1999, iteration 0 Pid 1999, iteration 1 Pid 1999, iteration 2 Breakpoint 1, report (iteration=3) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) info checkpoints 1 process 2003 at 0x8048453, file test.cpp, line 6 * 0 process 1999 (main process) at 0x8048453, file test.cpp, line 6 (gdb) restart 0 Switching to process 1999 #0 report (iteration=3) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) restart 1 Switching to process 2003 #0 report (iteration=0) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) continue Continuing. Pid 2003, iteration 0 Breakpoint 1, report (iteration=1) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) restart 0 Switching to process 1999 #0 report (iteration=3) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) continue Continuing. Pid 1999, iteration 3 Breakpoint 1, report (iteration=4) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) restart 1 Switching to process 2003 #0 report (iteration=1) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) continue Continuing. Pid 2003, iteration 1 Breakpoint 1, report (iteration=2) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration); (gdb) continue 7 Will ignore next 6 crossings of breakpoint 1. Continuing. Pid 2003, iteration 2 Pid 2003, iteration 3 Pid 2003, iteration 4 Pid 2003, iteration 5 Pid 2003, iteration 6 Pid 2003, iteration 7 Pid 2003, iteration 8 Breakpoint 1, report (iteration=9) at test.cpp:6 6 printf("Pid %d, iteration %dgetpid(), iteration);