English 中文(简体)
• 如何利用b树来洗刷巴策产生的可执行的双手
原标题:how to use gdb to debug a executable binary generated by bazel build

有一种简单的源代码“世界.cpp”,而“bazel”则以这种方式建造:

$ bazel build --cxxopt=-std=c++11 -c dbg --strip=never //examples/hello_world:hello_world

so I can debug it like this, and everything is going well, the source code symbols can display:

$ gdb bazel-bin/examples/hello_world/hello_world
Reading symbols from bazel-bin/examples/hello_world/hello_world...done.
(gdb) b main
Breakpoint 1 at 0x51e9: file examples/hello_world/main.cpp, line 46.
(gdb) r
Starting program: /home/wss/.cache/bazel/_bazel_wss/4110822ab2eb09dee5980f588bc10e42/execroot/com_minieye_aiplorer/bazel-out/k8-dbg/bin/examples/hello_world/hello_world 

Breakpoint 1, main (argc=1, argv=0x7fffffffe1c8) at examples/hello_world/main.cpp:46
warning: Source file is more recent than executable.
46    std::cout << "WITH LINUX~~~" << std::endl;
(gdb) l
41    return 0;
42  }
43  
44  int main(int argc, char *argv[]) {
45  #ifdef WITH_LINUX_PC
46    std::cout << "WITH LINUX~~~" << std::endl;
47  #endif
48    if (jsonHandle(argc, argv) < 0) {
49      return -1;
50    }

但是,当我去拜策-宾/谢普勒/盖洛-世界时,它就显示:

$ cd bazel-bin/examples/hello_world/
$ gdb hello_world
(gdb) b main
Breakpoint 1 at 0x51e9: file examples/hello_world/main.cpp, line 46.
(gdb) l
32  examples/hello_world/main.cpp: No such file or directory
(gdb) l
32  in examples/hello_world/main.cpp

谁能告诉我什么? 如果我想直接根据可执行的双位目录进行ug击,如何做?

======================================
And the same problem is, I build the code of hello-world with cross-comipler toolchains, and scp the executable binary to the target ARM core device, and the log is below:

Reading symbols from hello_world...
(gdb) b main
Breakpoint 1 at 0x40497c
(gdb) l
1       ../sysdeps/aarch64/start.S: No such file or directory.
(gdb) n
The program is not being run.
(gdb) r
Starting program: /app/algo/apa/bin/hello_world

Python Exception <class  NameError > Installation error: gdb._execute_unwinders function is missing:
Breakpoint 1, 0x000000000040497c in main ()
(gdb) l
1       in ../sysdeps/aarch64/start.S
(gdb) n

So, how to debug the program under a embedded enviorment? It still cannot display the source code.

问题回答

汇编者不得将汇编目录列入辩论信息。 相反,它只是将相对途径储存在源文档中。 因此,你看到以下信息:

examples/hello_world/main.cpp: No such file or directory

在不了解汇编目录的情况下,亚洲开发银行只是根据目前的工作名录寻找文件。

然而,你可以帮助亚行走。 如果是,

(gdb) directory /path/to/project/directory

然后,亚洲开发银行还将在<代码>/path/to/project/directory内查找文档——记住,该名录应为examples/hello_world/main.cpp有效的名录。

You can use show directories to see which directories GDB is using, or use set directories to completely rewrite the stored directory list (the directory command just adds a new directory to the list).





相关问题
tell gdb to disassemble "unknown" code

is it possible to configure gdb in order to debug assembly code when there are no debug symbols or no sources available ? I mean showing assembly instruction by assembly instruction when performing a ...

C++ Netbeans debugging issues

I installed netbeans6.7.1 ide for c/c++ also i have mingw/msys cygwin installed and i have given C:Msysin as environment variable path.It has gdb7 version.However wheni run dbugging thru netbeans ...

setting strings in gdb

c++: int main() { string a = "a"; ... ... } when i debug in gdb: (gdb) set var a = "ok" Invalid cast I run the program and pause at a break point after string a has been ...

How to debug programms written in fasm under linux using gdb?

I wrote simple "hello, world" in fasm, and its works, but how i can generate debug info for gdb and edb (Evan s Debugger)? Fasm compiler could only produce debugging symbols in its specific format - "...

How can I display Unicode strings while debugging on linux?

I have been working for some years now as C++ Developer using MS Visual Studio as working platform. Since I privately prefer to use linux, I recently took the chance to move my working environment to ...

Continue to debug after failed assertion on Linux?

When an assertion fails with Visual C++ on Windows, the debugger stops, displays the message, and then lets you continue (or, if no debugging session is running, offers to launch visual studio for you)...

热门标签