Andes Workshop

It is currently Mon Aug 19, 2019 2:58 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: debug information
PostPosted: Tue Mar 06, 2012 5:38 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
我分享如何看debug information。

下面有幾個檔案
a.c
Code:
#include "common.h"

void
foo ()
{
  LALA lala;
}

int
main ()
{
  return 0;
}


b.c
Code:
#define HELLO
#include "common.h"

void
bar ()
{
  LALA lala;
}


common.h
Code:
typedef struct
{
  int f1;
#ifdef HELLO
  int f2;
#endif
  int f3;
} LALA;


Makefile
Code:
all:
   nds32le-elf-gcc a.c b.c -g -O0 -o case1.out
   nds32le-elf-gcc b.c a.c -g -O0 -o case2.out


因為這裡的structure用條件式編譯的緣故,
相同的structure LALA,內容不相同。
我們可以從debug information中看到的element。
command為
Code:
$ nds32le-elf-readelf.exe -w case1.out >> out.txt


打開out.txt檔。
看到資訊如下圖,可知a.c中,LALA define的structure有2個int變數f1及f3,size為8 bytes
Attachment:
p1.gif
p1.gif [ 39.02 KiB | Viewed 4117 times ]


我們看b.c的debug information,可以看到LALA define的structure有3個變數,f1 f2 f3。
size為12 bytes
Attachment:
p2.gif
p2.gif [ 34.05 KiB | Viewed 4117 times ]


gdb用當時所指向的pc值去抓debug information,
所以不會抓錯變數。
最後,附上我測試用的檔案。
Attachment:
debug_info.zip [6.04 KiB]
Downloaded 451 times


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group