GDB 无法识别新的 files/lines

GDB wont recognize new files/lines

我正在尝试使用 qemu 模拟器和 gdb 内核调试 xv6。

但是,gdb 不会识别我对文件所做的任何添加。例如,它不会识别新文件,甚至不会识别现有文件中的新行,例如:

在文件x86.h中我添加了另一个函数,这是代码(我添加了cas):

static inline void
lcr3(uint val)
{
  asm volatile("movl %0,%%cr3" : : "r" (val));
}

static inline uint
cas(volatile int *addr,int expected, int newval)
{
  uint flags;
  uint zf;
  asm volatile("movl %0,%%eax;lock;cmpxchg %2,%3;jne afterChange;movl %%eax,%0;afterChange:;pushfl; popl %1":"+m"(*addr),"=r"(flags):"r"(expected),"r"(newval):"%eax");
  zf = (flags >> 6) & 1;
  return zf;
}

gdb 会识别 lcr3,但不会识别 cas,但是,当我实际搜索文件时,我可以找到以下行:

(gdb) list lcr3
138   return val;
139 }
140 
141 static inline void
142 lcr3(uint val)
143 {
144   asm volatile("movl %0,%%cr3" : : "r" (val));
145 }
146 
147 static inline uint
(gdb) list
148 cas(volatile int *addr,int expected, int newval)
149 {
150   uint flags;
151   uint zf;
152   asm volatile("movl %0,%%eax;lock;cmpxchg %2,%3;jne afterChange;movl %%eax,%0;afterChange:;pushfl; popl %1":"+m"(*addr),"=r"(flags):"r"(expected),"r"(newval):"%eax");
153   //zf = (flags >> 6) & 1;
154   zf = flags;
155   return zf;
156 }
157 

我正在使用这个 makefile(基本的 xv6 makefile): https://github.com/mit-pdos/xv6-public/blob/master/Makefile

很乐意提供任何帮助。谢谢。

gdb wont recognize any additions i do to the files.
i have created a new copy, updated the modified files, and compiled (fresh). did not work

这很可能意味着您正在调试您认为正在调试的文件的旧副本。

这样做:

  1. ls -il xv6 观察其(最近)时间戳。它应该是最近的,因为您已经完成 make clean 并重建了它。
  2. 现在 rm -f xv6; ls -l xv6 验证文件是否已消失。
  3. 现在再次尝试调试,观察你仍然可以(这证明了我的猜测)。
  4. 弄清楚你是什么副本实际调试,并更新
  5. 利润。

更新:

I am updating the right files, as i mentioned in the initial post, when i actually look into the files content using gdb i can see the modifications.

您(显然)在谈论源文件。 GDB 不关心源文件,不使用它们(除非你要求GDB list它们)。 GDB 只关心 compiled 二进制文件,而 that 是你不知何故忽略更新的文件。