Chinaunix首页 | 论坛 | 博客
  • 博客访问: 772900
  • 博文数量: 239
  • 博客积分: 60
  • 博客等级: 民兵
  • 技术积分: 1045
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-22 18:25
文章分类

全部博文(239)

文章存档

2019年(9)

2018年(64)

2017年(2)

2016年(26)

2015年(30)

2014年(41)

2013年(65)

2012年(2)

分类: C/C++

2016-02-18 22:44:49

gdb backtrace简单分三步,查找是否支持当前命令 -> 校验gdb调试器扩展 -> 执行并显示结果。
1) 查找backtrace命令执行函数,调用堆栈1为:

点击(此处)折叠或打开

  1. (gdb) bt
  2. #0 exceptions_state_mc (action=action@entry=CATCH_ITER) at ./common/common-exceptions.c:177
  3. #1 0x00000000006c8917 in exceptions_state_mc_action_iter () at ./common/common-exceptions.c:207
  4. #2 0x000000000050d685 in gdbpy_apply_frame_filter (extlang=<optimized out>, frame=0x29b3c90, flags=7, args_type=CLI_SCALAR_VALUES,
  5.     out=0x2a8b5a0, frame_low=0, frame_high=-1) at ./python/py-framefilter.c:1530
  6. #3 0x00000000005c1c28 in apply_ext_lang_frame_filter (frame=0x29b3c90, flags=flags@entry=7,
  7.     args_type=args_type@entry=CLI_SCALAR_VALUES, out=out@entry=0x2a8b5a0, frame_low=frame_low@entry=0, frame_high=frame_high@entry=-1)
  8.     at extension.c:569
  9. #4 0x00000000005bb573 in backtrace_command_1 (from_tty=1, no_filters=0, show_locals=0, count_exp=0x0) at stack.c:1820
  10. #5 backtrace_command (arg=0x0, from_tty=1) at stack.c:1935
  11. #6 0x00000000006912dd in execute_command (p=<optimized out>, p@entry=0x28ee190 "bt", from_tty=1) at top.c:468
  12. #7 0x00000000005cb681 in command_handler (command=0x28ee190 "bt") at event-top.c:494
  13. #8 0x00000000005cbbdc in command_line_handler (rl=<optimized out>) at event-top.c:692
  14. #9 0x00000000006e4fd0 in rl_callback_read_char () at callback.c:220
  15. #10 0x00000000005cb6e9 in rl_callback_read_char_wrapper (client_data=<optimized out>) at event-top.c:171
  16. #11 0x00000000005cb733 in stdin_event_handler (error=<optimized out>, client_data=0x0) at event-top.c:432
  17. #12 0x00000000005ca5fd in gdb_wait_for_event (block=block@entry=1) at event-loop.c:834
  18. #13 0x00000000005ca842 in gdb_do_one_event () at event-loop.c:323
  19. #14 0x00000000005ca8be in start_event_loop () at event-loop.c:347
  20. #15 0x00000000005c4423 in captured_command_loop (data=data@entry=0x0) at main.c:318
  21. #16 0x00000000005c137d in catch_errors (func=func@entry=0x5c4410 <captured_command_loop>, func_args=func_args@entry=0x0,
  22.     errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
  23. #17 0x00000000005c53be in captured_main (data=data@entry=0x7ffc1edbfea0) at main.c:1157
  24. #18 0x00000000005c137d in catch_errors (func=func@entry=0x5c4950 <captured_main>, func_args=func_args@entry=0x7ffc1edbfea0,
  25.     errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
  26. #19 0x00000000005c586b in gdb_main (args=args@entry=0x7ffc1edbfea0) at main.c:1165
  27. #20 0x00000000004627b5 in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32

2)判断是否设置python扩展,调用堆栈2为:

点击(此处)折叠或打开

  1. (gdb) bt
  2. #0 frame_unwind_pc (this_frame=0x29b3bc0) at frame.c:867
  3. #1 0x000000000069a4d9 in get_frame_pc_if_available (frame=frame@entry=0x29b3c90, pc=pc@entry=0x7ffc1edbf930) at frame.c:2231
  4. #2 0x000000000069bd2c in get_prev_frame (this_frame=this_frame@entry=0x29b3c90) at frame.c:2131
  5. #3 0x000000000050afc5 in frame_info_to_frame_object (frame=frame@entry=0x29b3c90) at ./python/py-frame.c:377
  6. #4 0x000000000050d6f8 in bootstrap_python_frame_filters (frame_high=-1, frame_low=0, frame=0x29b3c90)
  7.     at ./python/py-framefilter.c:1448
  8. #5 gdbpy_apply_frame_filter (extlang=<optimized out>, frame=0x29b3c90, flags=7, args_type=CLI_SCALAR_VALUES, out=0x2a8b5a0,
  9.     frame_low=0, frame_high=-1) at ./python/py-framefilter.c:1543
  10. #6 0x00000000005c1c28 in apply_ext_lang_frame_filter (frame=0x29b3c90, flags=flags@entry=7,
  11.     args_type=args_type@entry=CLI_SCALAR_VALUES, out=out@entry=0x2a8b5a0, frame_low=frame_low@entry=0, frame_high=frame_high@entry=-1)
  12.     at extension.c:569
  13. #7 0x00000000005bb573 in backtrace_command_1 (from_tty=1, no_filters=0, show_locals=0, count_exp=0x0) at stack.c:1820
  14. #8 backtrace_command (arg=0x0, from_tty=1) at stack.c:1935
  15. #9 0x00000000006912dd in execute_command (p=<optimized out>, p@entry=0x28ee190 "bt", from_tty=1) at top.c:468
  16. #10 0x00000000005cb681 in command_handler (command=0x28ee190 "bt") at event-top.c:494
  17. #11 0x00000000005cbbdc in command_line_handler (rl=<optimized out>) at event-top.c:692
  18. #12 0x00000000006e4fd0 in rl_callback_read_char () at callback.c:220
  19. #13 0x00000000005cb6e9 in rl_callback_read_char_wrapper (client_data=<optimized out>) at event-top.c:171
  20. #14 0x00000000005cb733 in stdin_event_handler (error=<optimized out>, client_data=0x0) at event-top.c:432
  21. #15 0x00000000005ca5fd in gdb_wait_for_event (block=block@entry=1) at event-loop.c:834
  22. #16 0x00000000005ca842 in gdb_do_one_event () at event-loop.c:323
  23. #17 0x00000000005ca8be in start_event_loop () at event-loop.c:347
  24. #18 0x00000000005c4423 in captured_command_loop (data=data@entry=0x0) at main.c:318
  25. #19 0x00000000005c137d in catch_errors (func=func@entry=0x5c4410 <captured_command_loop>, func_args=func_args@entry=0x0,
  26.     errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
  27. #20 0x00000000005c53be in captured_main (data=data@entry=0x7ffc1edbfea0) at main.c:1157
  28. #21 0x00000000005c137d in catch_errors (func=func@entry=0x5c4950 <captured_main>, func_args=func_args@entry=0x7ffc1edbfea0,
  29.     errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
  30. #22 0x00000000005c586b in gdb_main (args=args@entry=0x7ffc1edbfea0) at main.c:1165
  31. #23 0x00000000004627b5 in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32
3)显示堆栈,调用堆栈3为:

点击(此处)折叠或打开

  1. (gdb) bt
  2. #0 0x00000000006bf4dc in skip_spaces_const (chp=chp@entry=0x29603b0 "main") at ./common/common-utils.c:275
  3. #1 0x0000000000607ef3 in msymbol_hash_iw (string=string@entry=0x29603b0 "main") at minsyms.c:89
  4. #2 0x0000000000607fda in lookup_minimal_symbol (name=0x29603b0 "main", sfile=sfile@entry=0x0, objf=objf@entry=0x2a9a9c0)
  5.     at minsyms.c:172
  6. #3 0x000000000069bd8f in inside_main_func (this_frame=0x29b3c90) at frame.c:2088
  7. #4 get_prev_frame (this_frame=this_frame@entry=0x29b3c90) at frame.c:2147
  8. #5 0x000000000050afc5 in frame_info_to_frame_object (frame=frame@entry=0x29b3c90) at ./python/py-frame.c:377
  9. #6 0x000000000050d6f8 in bootstrap_python_frame_filters (frame_high=-1, frame_low=0, frame=0x29b3c90)
  10.     at ./python/py-framefilter.c:1448
  11. #7 gdbpy_apply_frame_filter (extlang=<optimized out>, frame=0x29b3c90, flags=7, args_type=CLI_SCALAR_VALUES, out=0x2a8b5a0,
  12.     frame_low=0, frame_high=-1) at ./python/py-framefilter.c:1543
  13. #8 0x00000000005c1c28 in apply_ext_lang_frame_filter (frame=0x29b3c90, flags=flags@entry=7,
  14.     args_type=args_type@entry=CLI_SCALAR_VALUES, out=out@entry=0x2a8b5a0, frame_low=frame_low@entry=0, frame_high=frame_high@entry=-1)
  15.     at extension.c:569
  16. #9 0x00000000005bb573 in backtrace_command_1 (from_tty=1, no_filters=0, show_locals=0, count_exp=0x0) at stack.c:1820
  17. #10 backtrace_command (arg=0x0, from_tty=1) at stack.c:1935
  18. #11 0x00000000006912dd in execute_command (p=<optimized out>, p@entry=0x28ee190 "bt", from_tty=1) at top.c:468
  19. #12 0x00000000005cb681 in command_handler (command=0x28ee190 "bt") at event-top.c:494
  20. #13 0x00000000005cbbdc in command_line_handler (rl=<optimized out>) at event-top.c:692
  21. #14 0x00000000006e4fd0 in rl_callback_read_char () at callback.c:220
  22. #15 0x00000000005cb6e9 in rl_callback_read_char_wrapper (client_data=<optimized out>) at event-top.c:171
  23. #16 0x00000000005cb733 in stdin_event_handler (error=<optimized out>, client_data=0x0) at event-top.c:432
  24. #17 0x00000000005ca5fd in gdb_wait_for_event (block=block@entry=1) at event-loop.c:834
  25. #18 0x00000000005ca842 in gdb_do_one_event () at event-loop.c:323
  26. #19 0x00000000005ca8be in start_event_loop () at event-loop.c:347
  27. #20 0x00000000005c4423 in captured_command_loop (data=data@entry=0x0) at main.c:318
  28. #21 0x00000000005c137d in catch_errors (func=func@entry=0x5c4410 <captured_command_loop>, func_args=func_args@entry=0x0,
  29.     errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
  30. #22 0x00000000005c53be in captured_main (data=data@entry=0x7ffc1edbfea0) at main.c:1157
  31. #23 0x00000000005c137d in catch_errors (func=func@entry=0x5c4950 <captured_main>, func_args=func_args@entry=0x7ffc1edbfea0,
  32.     errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
  33. #24 0x00000000005c586b in gdb_main (args=args@entry=0x7ffc1edbfea0) at main.c:1165
  34. #25 0x00000000004627b5 in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32

阅读(1620) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~