gdb调试的简单操作总结

  (gdb) r // 运行

  Starting program: F:8.7ceshi.exe

  [New Thread 10196.0x1b74]

  [New Thread 10196.0x173c]

  [New Thread 10196.0xe84]

  Thread 1 hit Breakpoint 1, main () at ceshi.cpp:36

  36 n = read(), m = read(); // 碰到断点

  (gdb) watch n // 添加监测变量 n

  Hardware watchpoint 2: n

  (gdb) c // 继续运行

  Continuing.

  2 3

  Thread 1 hit Hardware watchpoint 2: n // n 的变化

  Old value = 0

  New value = 2

  main () at ceshi.cpp:36

  36 n = read(), m = read();

  (gdb) watch a // 添加监测数组 a

  Watchpoint 3: a

  (gdb) c

  Continuing.

  Watchpoint 2 deleted because the program has left the block

  in which its expression is valid.

  Thread 1 hit Watchpoint 3: a // a 的变化

  Old value = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

  New value = {0, 1, 0, 0, 0, 0, 0, 0, 0, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  Thread 1 hit Watchpoint 3: a

  Old value = {0, 1, 0, 0, 0, 0, 0, 0, 0, 0}

  New value = {0, 1, 2, 0, 0, 0, 0, 0, 0, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  Thread 1 hit Watchpoint 3: a

  Old value = {0, 1, 2, 0, 0, 0, 0, 0, 0, 0}

  New value = {0, 1, 2, 3, 0, 0, 0, 0, 0, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  Thread 1 hit Watchpoint 3: a

  Old value = {0, 1, 2, 3, 0, 0, 0, 0, 0, 0}

  New value = {0, 1, 2, 3, 4, 0, 0, 0, 0, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  Thread 1 hit Watchpoint 3: a

  Old value = {0, 1, 2, 3, 4, 0, 0, 0, 0, 0}

  New value = {0, 1, 2, 3, 4, 5, 0, 0, 0, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  Thread 1 hit Watchpoint 3: a

  Old value = {0, 1, 2, 3, 4, 5, 0, 0, 0, 0}

  New value = {0, 1, 2, 3, 4, 5, 6, 0, 0, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  Thread 1 hit Watchpoint 3: a

  Old value = {0, 1, 2, 3, 4, 5, 6, 0, 0, 0}

  New value = {0, 1, 2, 3, 4, 5, 6, 7, 0, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  Thread 1 hit Watchpoint 3: a

  Old value = {0, 1, 2, 3, 4, 5, 6, 7, 0, 0}

  New value = {0, 1, 2, 3, 4, 5, 6, 7, 8, 0}

  main () at ceshi.cpp:39

  39 s.emplace_back(i);

  (gdb) c

  Continuing.

  AK IOI!

  qwq

  qwq

  qwq

  qwq

  qwq

  qwq

  qwq

  qwq

  qwq

  qwq

  end!

  [Thread 10196.0xe84 exited with code 0]

  [Thread 10196.0x173c exited with code 0]

  [Thread 10196.0x1b74 exited with code 0]

  [Inferior 1 (process 10196) exited normally]

  (gdb)