Andes Workshop

It is currently Mon Aug 26, 2019 11:58 am

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: gdb load多個symbol的方法
PostPosted: Tue Apr 03, 2012 4:59 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
load symbol可以用 add-symbol-file 指令

例如用
add-symbol-file rom.adx 0x8000
表示把 rom.adx 的symbol以 .text 為0x8000 base 載入 (其他section會跟著調整)
詳細功能可以在gdb用 help add-symbol-file 查
---------------------------------------------------

第1個adx檔用file
file xxx.adx (file會清掉之前的所有symbol)
第2個之後用add-symbol-file

add-symbol-file rom.adx 0x8000
其中0x8000是rom.adx檔的.text base

如果加入的不是.text而是其他section。
要個別打入section的名稱及位址。請參考下面的說明。

(gdb) help add-symbol-file
Load symbols from FILE, assuming FILE has been dynamically loaded.
Usage: add-symbol-file FILE ADDR [-s <SECT> <SECT_ADDR> -s <SECT> <SECT_ADDR> ..
.]
ADDR is the starting address of the file's text.
The optional arguments are section-name section-address pairs and
should be specified if the data and bss segments are not contiguous
with the text. SECT is a section name to be loaded at SECT_ADDR.
(gdb)


Top
 Profile Send private message E-mail  
 
 Post subject: Re: gdb load多個symbol的方法
PostPosted: Wed Jun 27, 2012 6:47 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
example

hylai@APC002 /cygdrive/d/mycode/patch
$ nds32le-elf-gdb.exe
GNU gdb (2012-03-16) 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-mingw32 --target=nds32le-elf".
source E:\Andestech\AndeSight200MCU\toolchains\nds32le-elf-newlib-v2\bin\.Andes
dbinit
(gdb) target remote:1234
Remote debugging using :1234
0x00016e02 in ?? ()
core0(gdb) target remote:1234
A program is being debugged already. Kill it? (y or n) y

Remote debugging using :1234
0x00016da6 in ?? ()
core0(gdb) file mainprog.adx
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from d:\mycode\patch\mainprog.adx...done.
core0(gdb) load
Loading section .nds32_init, size 0x4 lma 0x500000
Loading section .init, size 0xc lma 0x500004
Loading section .text, size 0x9518 lma 0x500010
Loading section .rodata, size 0x338 lma 0x509528
Loading section .eh_frame, size 0x34 lma 0x509860
Loading section .ctors, size 0x4 lma 0x509894
Loading section .dtors, size 0x4 lma 0x509898
Loading section .jcr, size 0x4 lma 0x50989c
Loading section .data, size 0x870 lma 0x5098a0
Loading section .sdata_w, size 0x38 lma 0x50a110
Loading section .sdata_b, size 0x3 lma 0x50a148
Loading section FUNC_TABLE, size 0xc lma 0x510000
Start address 0x500010, load size 41303
Transfer rate: 433 KB/sec, 2950 bytes/write.
core0(gdb) file patch.adx
A program is being debugged already.
Are you sure you want to change the file? (y or n) y

Load new symbol table from "d:\mycode\patch\patch.adx"? (y or n) y
Reading symbols from d:\mycode\patch\patch.adx...done.
core0(gdb) load
Loading section FUNC_TABLE, size 0xc lma 0x510000
Loading section FUNC_PATCH, size 0x38 lma 0x510020
Start address 0x500010, load size 68
Transfer rate: 544 bits in <1 sec, 34 bytes/write.
core0(gdb) file mainprog.adx
A program is being debugged already.
Are you sure you want to change the file? (y or n) y

Load new symbol table from "d:\mycode\patch\mainprog.adx"? (y or n) y
Reading symbols from d:\mycode\patch\mainprog.adx...done.
core0(gdb)add-symbol-file patch.adx 0x500000 -s FUNC_TABLE 0x510000 -s FUNC_PATCH 0x510020
add symbol table from file "patch.adx" at
.text_addr = 0x500000
FUNC_TABLE_addr = 0x510000
FUNC_PATCH_addr = 0x510020
(y or n) y
Reading symbols from d:\mycode\patch\patch.adx...warning: Lowest section in d:\
ycode\patch\patch.adx is FUNC_TABLE at 00510000
warning: section .text not found in d:\mycode\patch\patch.adx
done.
core0(gdb) set $pc=0x500000
core0(gdb) b main
Breakpoint 1 at 0x50010c: file ../main.c, line 20.
core0(gdb) c
Continuing.

Breakpoint 1, main () at ../main.c:20
20 printf("func1(30)=%d\n",jump_table.func_a(30));
core0(gdb) s
func1 (x=30) at ../main.c:28
28 return x*num1;
core0(gdb) n
29 }
core0(gdb) s
main () at ../main.c:21
21 printf("func2(30)=%d\n",jump_table.func_b(30));
core0(gdb) s
func2 (x=30) at ../patchprog.c:24
24 return x*num2*100;
core0(gdb)


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

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group