सी कोड में एक पंक्ति तक पहुंचने पर मैं बैकट्रैक प्राप्त करने का प्रयास कर रहा हूं।

मैं कमांड फ़ाइल को जीडीबी को खिलाता हूं और यह काम करता है सिवाय इसके कि जब यह ब्रेकपॉइंट तक पहुंचता है तो कुछ नहीं होता है।

मैं जीडीबी संस्करण 9.1-3 . के साथ डेबियन परीक्षण का उपयोग कर रहा हूं

मेरा कोड CFLAGS के साथ संकलित है:

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

जीसीसी संस्करण है (डेबियन 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);

कोई विचार जो मैं यहां गलत कर रहा हूं या यह एक जीडीबी/जीसीसी बग है?

मैंने इसी तरह की समस्याओं और उत्तरों की तलाश की है, लेकिन ऐसा लगता है कि किसी के पास यह विशिष्ट समस्या नहीं है।

धन्यवाद! :)

c gdb
0
flowerbug 19 अप्रैल 2020, 18:24

1 उत्तर

सबसे बढ़िया उत्तर

ठीक है, कुछ विभिन्न परीक्षणों और पढ़ने के बाद मुझे अंततः उपरोक्त स्क्रिप्ट का कम से कम एक संशोधित संस्करण काम करने के लिए मिल गया है। ऐसा लगता है कि नेक्स्ट और स्टेप्स के लूप आउटपुट के किसी भी प्रश्न को ओवरराइड करते हैं। जब मैंने अंत में छोरों को हटा दिया तो लिस्टिंग बैकट्रेस दिखाई देती है।

नई जीडीबी स्क्रिप्ट

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]
0
flowerbug 1 मई 2020, 15:05