当到达C代码中的一行时,我试图获取回溯。
我将命令文件提供给gdb,它可以工作,除了到达断点时什么都没有发生。
我正在将Debian Testing与gdb版本9.1-3一起使用
我的代码是使用CFLAGS编译的:
-Og -g3 -m32 -gdwarf-4 -fvar-tracking-assignments -w
gcc版本是(Debian 9.3.0-10)9.3.0
使用其他版本的矮人似乎没有什么区别。
我包含的命令文件是:
set confirm off
set pagination off
set logging file gdbrogue.txt
set logging overwrite on
set logging on
set breakpoint pending on
#set trace-commands on
directory /home/me/src/github/rogue-54-for-rogomatic
symbol-file -readnow /usr/local/bin/rogue
skip file hardscroll.c
skip file hashmap.c
skip file lib_addch.c
skip file lib_addstr.c
skip file lib_clreol.c
skip file lib_erase.c
skip file lib_getch.c
skip file lib_move.c
skip file lib_mvcur.c
skip file lib_refresh.c
skip file lib_touch.c
skip file lib_tparm.c
skip file lib_tputs.c
skip file lib_winch.c
skip file lib_window.c
skip file tty_update.c
skip function look
skip function msg
skip function read
skip function unctrl
skip function __kernel_vsyscall
define my_prt_mlist
set $current = mlist
while ($current > 0)
printf "curr %p prev %p next %p\n", $current, $current->l_prev, $current->l_next
printf " t_type %c\n", $current->t_type
printf " t_pos.y %d t_pos.x %d\n", $current->t_pos.y, $current->t_pos.x
if ($current->t_dest > 0)
printf " t_dest->y %d t_dest->x %d\n", $current->t_dest->y, $current->t_dest->x
end
set $current = $current->l_next
end
end
break chase.c:32 if (level == 7)
commands
printf "player(y,x) (%d,%d)\n", player.t_pos.y, player.t_pos.x
my_prt_mlist
end
break chase.c:455 if (level == 7)
commands
printf "player(y,x) (%d,%d)\n", player.t_pos.y, player.t_pos.x
my_prt_mlist
backtrace full
end
while (level < 7)
next
end
while (level == 7)
step
end
while (level > 7)
next
end
输出显示已达到中断,但未显示回溯?
roomin (cp=0x582403cc) at chase.c:445
445 roomin(coord *cp) {
452 if (((cp->x > MAXCOLS) || (cp->y > MAXLINES)) ||
454 msg("in some bizarre place (%d, %d)", unc(*cp));
Breakpoint 2, roomin (cp=0x582403cc) at chase.c:455
455 return NULL;
do_chase (th=0x5823ede0) at chase.c:142
142 door = (chat(th->t_pos.y, th->t_pos.x) == DOOR);
任何想法我在这里做错了还是这是gdb / gcc错误?
我一直在寻找类似的问题和答案,但似乎没有一个特定的问题。
谢谢! :)
好吧,在经过各种尝试和阅读之后,我终于至少得到了上述脚本的修改版本才能工作。似乎nexts和steps的while循环会覆盖对输出的任何询问。当我最后删除循环时,将显示清单和回溯。
新gdb脚本
set confirm off
set pagination off
set logging file gdbrogue.txt
set logging overwrite on
set logging on
set breakpoint pending on
#set trace-commands on
directory /home/me/src/github/rogue-54-for-rogomatic
symbol-file -readnow /usr/local/bin/rogue
skip file hardscroll.c
skip file hashmap.c
skip file lib_addch.c
skip file lib_addstr.c
skip file lib_clreol.c
skip file lib_erase.c
skip file lib_getch.c
skip file lib_move.c
skip file lib_mvcur.c
skip file lib_refresh.c
skip file lib_touch.c
skip file lib_tparm.c
skip file lib_tputs.c
skip file lib_winch.c
skip file lib_window.c
skip file tty_update.c
skip function look
skip function msg
skip function read
skip function unctrl
skip function __kernel_vsyscall
define my_prt_mlist
set $current = mlist
while ($current > 0)
printf "curr %p prev %p next %p\n", $current, $current->l_prev, $current->l_next
printf " t_type %c\n", $current->t_type
printf " t_pos.y %d t_pos.x %d\n", $current->t_pos.y, $current->t_pos.x
if ($current->t_dest > 0)
printf " t_dest->y %d t_dest->x %d\n", $current->t_dest->y, $current->t_dest->x
end
set $current = $current->l_next
end
end
break chase.c:453 if (level == 7)
commands
my_prt_mlist
backtrace full
end
cont
File hardscroll.c will be skipped when stepping.
File hashmap.c will be skipped when stepping.
File lib_addch.c will be skipped when stepping.
File lib_addstr.c will be skipped when stepping.
File lib_clreol.c will be skipped when stepping.
File lib_erase.c will be skipped when stepping.
File lib_getch.c will be skipped when stepping.
File lib_move.c will be skipped when stepping.
File lib_mvcur.c will be skipped when stepping.
File lib_refresh.c will be skipped when stepping.
File lib_touch.c will be skipped when stepping.
File lib_tparm.c will be skipped when stepping.
File lib_tputs.c will be skipped when stepping.
File lib_winch.c will be skipped when stepping.
File lib_window.c will be skipped when stepping.
File tty_update.c will be skipped when stepping.
Function look will be skipped when stepping.
Function msg will be skipped when stepping.
Function read will be skipped when stepping.
Function unctrl will be skipped when stepping.
Function __kernel_vsyscall will be skipped when stepping.
Breakpoint 1 at 0x5662b9a7: file chase.c, line 454.
Breakpoint 1, roomin (cp=0x577483cc) at chase.c:454
454 msg("in some bizarre place (%d, %d)", unc(*cp));
curr 0x577483c0 prev (nil) next 0x57748480
t_type Z
t_pos.y 18 t_pos.x 8
t_dest->y 10 t_dest->x 19
curr 0x57748480 prev 0x577483c0 next 0x57747dc0
t_type S
t_pos.y 8 t_pos.x 19
t_dest->y 10 t_dest->x 19
curr 0x57747dc0 prev 0x57748480 next 0x57746de0
t_type S
t_pos.y 9 t_pos.x 65
t_dest->y 10 t_dest->x 19
curr 0x57746de0 prev 0x57747dc0 next 0x57748300
t_type C
t_pos.y 10 t_pos.x 8
t_dest->y 542792192 t_dest->x 18
curr 0x57748300 prev 0x57746de0 next 0x577482a0
t_type B
t_pos.y 10 t_pos.x 47
curr 0x577482a0 prev 0x57748300 next 0x577481e0
t_type Z
t_pos.y 10 t_pos.x 30
curr 0x577481e0 prev 0x577482a0 next 0x57748120
t_type R
t_pos.y 10 t_pos.x 29
curr 0x57748120 prev 0x577481e0 next 0x577480c0
t_type O
t_pos.y 12 t_pos.x 37
curr 0x577480c0 prev 0x57748120 next 0x57748060
t_type I
t_pos.y 12 t_pos.x 39
curr 0x57748060 prev 0x577480c0 next 0x57747fa0
t_type Z
t_pos.y 11 t_pos.x 43
curr 0x57747fa0 prev 0x57748060 next 0x57746c00
t_type H
t_pos.y 10 t_pos.x 45
curr 0x57746c00 prev 0x57747fa0 next 0x57746d80
t_type I
t_pos.y 18 t_pos.x 15
curr 0x57746d80 prev 0x57746c00 next (nil)
t_type L
t_pos.y 5 t_pos.x 22
#0 roomin (cp=0x577483cc) at chase.c:454
rp = <optimized out>
fp = <optimized out>
#1 0x5662c3c1 in do_chase (th=0x57746de0) at chase.c:137
cp = <optimized out>
rer = 0x56653364 <passages+132>
ree = <optimized out>
mindist = 32767
curdist = <optimized out>
stoprun = false
door = <optimized out>
obj = <optimized out>
this = {x = 65, y = 9}
#2 0x5662c74d in move_monst (tp=0x57746de0) at chase.c:68
No locals.
#3 0x5662c7f3 in runners () at chase.c:41
tp = 0x57746de0
next = 0x57748300
wastarget = false
orig_pos = {x = 8, y = 10}
#4 0x5662df79 in do_daemons (flag=2) at daemon.c:114
dev = 0x56655e20 <d_list>
#5 0x5662de0e in command () at command.c:484
ch = <optimized out>
ntimes = -1
fp = <optimized out>
mp = <optimized out>
countch = 115 's'
direction = 75 'K'
newcount = 1 '\001'
#6 0x566311b7 in playit () at main.c:322
opts = <optimized out>
#7 0x5663162d in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at main.c:188
env = <optimized out>
lowtime = <optimized out>
pid = <optimized out>
pidfilename = "roguepid.10955", '\000' <repeats 49 times>
pidfp = <optimized out>
[Inferior 1 (process 10955) detached]