gpt4 book ai didi

c - GDB 无法识别新文件/行

转载 作者:行者123 更新时间:2023-11-30 19:12:45 26 4
gpt4 key购买 nike

我正在尝试使用 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 列出它们)。 GDB 只关心编译的二进制文件,而那个是您不知何故忽略更新的文件。

关于c - GDB 无法识别新文件/行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36503133/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com