[hellogcc] Re: How to skip function prologue with stabs debug info?

  • From: Yao Qi <qiyaoltc@xxxxxxxxx>
  • To: hellogcc@xxxxxxxxxxxxx
  • Date: Thu, 28 Jul 2011 10:07:36 +0800

2011/7/27 Triple Yang <triple.yang@xxxxxxxxx>:
> 最近看GDB的移植代码,以or32为出发点,里面提到含有dwarf调试信息的function prologue可以从调试信息中获取相关信息,GDB
> internal中对skip_prologue的说明也提到了。如果调试信息是stabs格式的,如何实现skip_prologue()函数?

skip_prologue 其实就是要把函数的prologue给找到,然后根据需要跳过去。现在的gdb,采用了很多中办法,依次尝试。你可以在别的
*-tdep.c里边找到。基本的方法就是,先采用平台无关的方式,比如这样,

+  if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL))
+    {
+      CORE_ADDR post_prologue_pc
+        = skip_prologue_using_sal (gdbarch, func_addr);
+      if (post_prologue_pc != 0)
+        return max (start_pc, post_prologue_pc);
+    }

这样的方式,和port和debuginfo种类(dwarf or
stab)是没有关系的。如果你需要gdb能够在使用stab在这里,那么你需要看看你的stab信息,compiler是否产生的对。我不熟悉stab,但是如果dwarf
里边的debug_line错了,这里也是有问题的。

然后,gdb可以尝试port specific的方式,其实就是prologue analyzer,
从函数开始,一个一个分析汇编指令,找到prologue的结束位置,这样也达到了skip_prologue的要求,而且你以后frame
unwind也可以work了,基本。

-- 
Yao Qi <qiyaoltc AT gmail DOT com>
http://sites.google.com/site/duewayqi/

Other related posts: