gdb view source code in cross-compiled environment

Linux x86上, 交叉编 arm code后, copy executed file into target machine, take appForTest executed file as an example.

ps -ef | grep appForTest, to get the pid number, such as 1903

gdb attach 1903

b main

===>

Breakpoint 1 at 0x19a6d4: file /home/henry/src/main.cpp, line 378.
(gdb) l
364 /home/henry/src/main.cpp: No such file or directory.

 

Solution:

tar -zcvf src.tar.gz /home/henry/src

copy src.tar.gz into target machine, such as /home/root/src.tar.gz

cd /home/root

tar -zxvf src.tar.gz

now, there's a fold named src in /home/root, namely, that is /home/root/src

 

Important point as below:

repeat upper steps with gdb:

gdb attach 1903

set substiture-path /home/henry/src /home/root/src

b main

l

===>

now source code can be shown normally.

 

posted @ 2024-12-26 15:51  HenryLiuY  阅读(13)  评论(0)    收藏  举报