gdb backtrace简单分三步,查找是否支持当前命令 -> 校验gdb调试器扩展 -> 执行并显示结果。
1) 查找backtrace命令执行函数,调用堆栈1为:
-
(gdb) bt
-
#0 exceptions_state_mc (action=action@entry=CATCH_ITER) at ./common/common-exceptions.c:177
-
#1 0x00000000006c8917 in exceptions_state_mc_action_iter () at ./common/common-exceptions.c:207
-
#2 0x000000000050d685 in gdbpy_apply_frame_filter (extlang=<optimized out>, frame=0x29b3c90, flags=7, args_type=CLI_SCALAR_VALUES,
-
out=0x2a8b5a0, frame_low=0, frame_high=-1) at ./python/py-framefilter.c:1530
-
#3 0x00000000005c1c28 in apply_ext_lang_frame_filter (frame=0x29b3c90, flags=flags@entry=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)
-
at extension.c:569
-
#4 0x00000000005bb573 in backtrace_command_1 (from_tty=1, no_filters=0, show_locals=0, count_exp=0x0) at stack.c:1820
-
#5 backtrace_command (arg=0x0, from_tty=1) at stack.c:1935
-
#6 0x00000000006912dd in execute_command (p=<optimized out>, p@entry=0x28ee190 "bt", from_tty=1) at top.c:468
-
#7 0x00000000005cb681 in command_handler (command=0x28ee190 "bt") at event-top.c:494
-
#8 0x00000000005cbbdc in command_line_handler (rl=<optimized out>) at event-top.c:692
-
#9 0x00000000006e4fd0 in rl_callback_read_char () at callback.c:220
-
#10 0x00000000005cb6e9 in rl_callback_read_char_wrapper (client_data=<optimized out>) at event-top.c:171
-
#11 0x00000000005cb733 in stdin_event_handler (error=<optimized out>, client_data=0x0) at event-top.c:432
-
#12 0x00000000005ca5fd in gdb_wait_for_event (block=block@entry=1) at event-loop.c:834
-
#13 0x00000000005ca842 in gdb_do_one_event () at event-loop.c:323
-
#14 0x00000000005ca8be in start_event_loop () at event-loop.c:347
-
#15 0x00000000005c4423 in captured_command_loop (data=data@entry=0x0) at main.c:318
-
#16 0x00000000005c137d in catch_errors (func=func@entry=0x5c4410 <captured_command_loop>, func_args=func_args@entry=0x0,
-
errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
-
#17 0x00000000005c53be in captured_main (data=data@entry=0x7ffc1edbfea0) at main.c:1157
-
#18 0x00000000005c137d in catch_errors (func=func@entry=0x5c4950 <captured_main>, func_args=func_args@entry=0x7ffc1edbfea0,
-
errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
-
#19 0x00000000005c586b in gdb_main (args=args@entry=0x7ffc1edbfea0) at main.c:1165
-
#20 0x00000000004627b5 in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32
2)判断是否设置python扩展,调用堆栈2为:
-
(gdb) bt
-
#0 frame_unwind_pc (this_frame=0x29b3bc0) at frame.c:867
-
#1 0x000000000069a4d9 in get_frame_pc_if_available (frame=frame@entry=0x29b3c90, pc=pc@entry=0x7ffc1edbf930) at frame.c:2231
-
#2 0x000000000069bd2c in get_prev_frame (this_frame=this_frame@entry=0x29b3c90) at frame.c:2131
-
#3 0x000000000050afc5 in frame_info_to_frame_object (frame=frame@entry=0x29b3c90) at ./python/py-frame.c:377
-
#4 0x000000000050d6f8 in bootstrap_python_frame_filters (frame_high=-1, frame_low=0, frame=0x29b3c90)
-
at ./python/py-framefilter.c:1448
-
#5 gdbpy_apply_frame_filter (extlang=<optimized out>, frame=0x29b3c90, flags=7, args_type=CLI_SCALAR_VALUES, out=0x2a8b5a0,
-
frame_low=0, frame_high=-1) at ./python/py-framefilter.c:1543
-
#6 0x00000000005c1c28 in apply_ext_lang_frame_filter (frame=0x29b3c90, flags=flags@entry=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)
-
at extension.c:569
-
#7 0x00000000005bb573 in backtrace_command_1 (from_tty=1, no_filters=0, show_locals=0, count_exp=0x0) at stack.c:1820
-
#8 backtrace_command (arg=0x0, from_tty=1) at stack.c:1935
-
#9 0x00000000006912dd in execute_command (p=<optimized out>, p@entry=0x28ee190 "bt", from_tty=1) at top.c:468
-
#10 0x00000000005cb681 in command_handler (command=0x28ee190 "bt") at event-top.c:494
-
#11 0x00000000005cbbdc in command_line_handler (rl=<optimized out>) at event-top.c:692
-
#12 0x00000000006e4fd0 in rl_callback_read_char () at callback.c:220
-
#13 0x00000000005cb6e9 in rl_callback_read_char_wrapper (client_data=<optimized out>) at event-top.c:171
-
#14 0x00000000005cb733 in stdin_event_handler (error=<optimized out>, client_data=0x0) at event-top.c:432
-
#15 0x00000000005ca5fd in gdb_wait_for_event (block=block@entry=1) at event-loop.c:834
-
#16 0x00000000005ca842 in gdb_do_one_event () at event-loop.c:323
-
#17 0x00000000005ca8be in start_event_loop () at event-loop.c:347
-
#18 0x00000000005c4423 in captured_command_loop (data=data@entry=0x0) at main.c:318
-
#19 0x00000000005c137d in catch_errors (func=func@entry=0x5c4410 <captured_command_loop>, func_args=func_args@entry=0x0,
-
errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
-
#20 0x00000000005c53be in captured_main (data=data@entry=0x7ffc1edbfea0) at main.c:1157
-
#21 0x00000000005c137d in catch_errors (func=func@entry=0x5c4950 <captured_main>, func_args=func_args@entry=0x7ffc1edbfea0,
-
errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
-
#22 0x00000000005c586b in gdb_main (args=args@entry=0x7ffc1edbfea0) at main.c:1165
-
#23 0x00000000004627b5 in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32
3)显示堆栈,调用堆栈3为:
-
(gdb) bt
-
#0 0x00000000006bf4dc in skip_spaces_const (chp=chp@entry=0x29603b0 "main") at ./common/common-utils.c:275
-
#1 0x0000000000607ef3 in msymbol_hash_iw (string=string@entry=0x29603b0 "main") at minsyms.c:89
-
#2 0x0000000000607fda in lookup_minimal_symbol (name=0x29603b0 "main", sfile=sfile@entry=0x0, objf=objf@entry=0x2a9a9c0)
-
at minsyms.c:172
-
#3 0x000000000069bd8f in inside_main_func (this_frame=0x29b3c90) at frame.c:2088
-
#4 get_prev_frame (this_frame=this_frame@entry=0x29b3c90) at frame.c:2147
-
#5 0x000000000050afc5 in frame_info_to_frame_object (frame=frame@entry=0x29b3c90) at ./python/py-frame.c:377
-
#6 0x000000000050d6f8 in bootstrap_python_frame_filters (frame_high=-1, frame_low=0, frame=0x29b3c90)
-
at ./python/py-framefilter.c:1448
-
#7 gdbpy_apply_frame_filter (extlang=<optimized out>, frame=0x29b3c90, flags=7, args_type=CLI_SCALAR_VALUES, out=0x2a8b5a0,
-
frame_low=0, frame_high=-1) at ./python/py-framefilter.c:1543
-
#8 0x00000000005c1c28 in apply_ext_lang_frame_filter (frame=0x29b3c90, flags=flags@entry=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)
-
at extension.c:569
-
#9 0x00000000005bb573 in backtrace_command_1 (from_tty=1, no_filters=0, show_locals=0, count_exp=0x0) at stack.c:1820
-
#10 backtrace_command (arg=0x0, from_tty=1) at stack.c:1935
-
#11 0x00000000006912dd in execute_command (p=<optimized out>, p@entry=0x28ee190 "bt", from_tty=1) at top.c:468
-
#12 0x00000000005cb681 in command_handler (command=0x28ee190 "bt") at event-top.c:494
-
#13 0x00000000005cbbdc in command_line_handler (rl=<optimized out>) at event-top.c:692
-
#14 0x00000000006e4fd0 in rl_callback_read_char () at callback.c:220
-
#15 0x00000000005cb6e9 in rl_callback_read_char_wrapper (client_data=<optimized out>) at event-top.c:171
-
#16 0x00000000005cb733 in stdin_event_handler (error=<optimized out>, client_data=0x0) at event-top.c:432
-
#17 0x00000000005ca5fd in gdb_wait_for_event (block=block@entry=1) at event-loop.c:834
-
#18 0x00000000005ca842 in gdb_do_one_event () at event-loop.c:323
-
#19 0x00000000005ca8be in start_event_loop () at event-loop.c:347
-
#20 0x00000000005c4423 in captured_command_loop (data=data@entry=0x0) at main.c:318
-
#21 0x00000000005c137d in catch_errors (func=func@entry=0x5c4410 <captured_command_loop>, func_args=func_args@entry=0x0,
-
errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
-
#22 0x00000000005c53be in captured_main (data=data@entry=0x7ffc1edbfea0) at main.c:1157
-
#23 0x00000000005c137d in catch_errors (func=func@entry=0x5c4950 <captured_main>, func_args=func_args@entry=0x7ffc1edbfea0,
-
errstring=errstring@entry=0x7bc022 "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240
-
#24 0x00000000005c586b in gdb_main (args=args@entry=0x7ffc1edbfea0) at main.c:1165
-
#25 0x00000000004627b5 in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32
阅读(1620) | 评论(0) | 转发(0) |