GDB не дает возврата при достижении точки останова, но это указано в файле команд - PullRequest
0 голосов
/ 19 апреля 2020

Я пытаюсь получить обратную трассировку при достижении строки в коде C.

Я передаю командный файл в gdb, и он работает, за исключением случаев, когда он достигает точки останова, ничего не происходит.

Я использую Debian Testing с версией gdb 9.1-3

мой код скомпилирован с CFLAGS:

-Og -g3 -m32 -gdwarf-4 -fvar-tracking-assignments -w

g cc версия (Debian 9.3.0-10) 9.3.0

использование других версий dwarf, похоже, не имеет никакого значения.

Файл команд, которые я включаю:

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 / g cc?

Я искал похожие проблемы и ответы, но, похоже, ни у кого нет этой конкретной проблемы c.

Спасибо! :)

1 Ответ

0 голосов
/ 01 мая 2020

Хорошо, после нескольких проб и чтения я наконец-то получил по крайней мере модифицированную версию вышеописанного скрипта для работы. Кажется, что циклы while и nexts переопределяют любые запросы вывода. Когда я удаляю циклы в конце, список выводится обратно.

новый скрипт 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]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...