嵌入式Linux上的轻量级调试

发布于 2024-08-13 07:27:50 字数 234 浏览 5 评论 0原文

我正在开发一个在小型基于 Linux 的 SBC(~32MB RAM)上运行的应用程序。遗憾的是,我的应用程序最近变得太大,无法再在 GDB 下运行。有谁知道我可以在嵌入式 Linux 中使用任何好的、轻量级的调试方法?甚至能够查看线程的堆栈跟踪也会非常有帮助。

我应该提到这个应用程序是用 C++ 编写的并运行多个线程,因此 gdbserver 是不行的,因为它不适用于多线程应用程序。

预先感谢,

玛哈

I'm developing an application that runs on a small Linux-based SBC (~32MB RAM). Sadly, my app recently became too large to run under GDB anymore. Does anyone know of any good, lightweight debugging methods that I can use in embedded Linux? Even being able to view a thread's stack trace would be extremely helpful.

I should mention that this application is written in C++ and runs multiple threads, so gdbserver is a no-go as it doesn't work with multithreaded apps.

Thanks in advance,

Maha

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

佼人 2024-08-20 07:27:50

gdbserver 绝对适用于多线程应用程序,我现在正在开发一个具有 >25 个线程的嵌入式项目,并且我们一直使用 gdbserver。

info threads 

列出系统中所有

thread <thread number from info threads>  

切换到该线程执行的线程。

thread apply XXX <command>  

在 XXX 指定的线程上运行,该线程也可以是“全部”。因此,如果您想要所有正在运行的线程的回溯,那么

thread apply all bt

一旦您进入给定线程的执行流程,所有典型命令都会像在单线程进程中一样工作。

gdbserver definitely works with multi-threaded applications, I'm working on an embedded project right now with >25 threads and we use gdbserver all the time.

info threads 

lists all the threads in the system

thread <thread number from info threads>  

switches to that thread of execution.

thread apply XXX <command>  

Runs on the thread designated by XXX, which can also be 'all'. So if you want the back trace from all running threads do

thread apply all bt

Once you're in the execution flow of a given threads all your typical commands work as they would in a single threaded process.

怎会甘心 2024-08-20 07:27:50

我听说有人进行一些 hack,比如在 QEMU 这样的模拟器中运行应用程序,然后在其上运行 GDB(或 valgrind 之类的东西)。这听起来很痛苦,但如果它有效的话......

你会用 libunwind (获取堆栈跟踪)和 printf 风格的日志记录到达任何地方吗?

I've heard of people doing hacks like running the application in an emulator like QEMU and then running GDB (or things like valgrind) on that. It sounds painful, but if it works....

Would you get anywhere with libunwind (to get stack traces) and printf-style logging?

陪你搞怪i 2024-08-20 07:27:50

串口打印是我能想到的最轻量的了~~~
在主机上很容易看到,在你的应用程序中代码也很简单~~

如果你没有串口,我们曾经使用过GPIO端口并使用它模拟了一个串口。它工作得很好,但有点慢:-( ~~~

Serial port printing is the most light weight I can think of ~~~
Easily seen in a Host PC, and simple and light weight code inside your app~~

If you do not have a serial port, once we used an GPIO port and simulated a serial port using it. It worked perfectly well, but was a bit slow :-( ~~~

開玄 2024-08-20 07:27:50

您构建自己的调试器有什么原因吗?我正在使用 ARM 处理器 (AT91SAM926x) 开发 Linux 系统,并且我们使用 CodeSourcery 的编译器和调试器。我认为他们还没有发布带有 GDB 7 的版本,但我正在使用 gdbserver 工具调试多线程 C++ 应用程序,没有任何问题。

Is there a reason why you have built your own debugger? I am developing a Linux system using an ARM processor (AT91SAM926x) and we are using both compiler and debugger from CodeSourcery. I do not think that they have released a version with GDB 7 yet but I am debugging multithreaded C++ applications using the gdbserver tool without any problems.

爱给你人给你 2024-08-20 07:27:50

Gdbserver 确实可以与多线程应用程序一起使用。然而,您确实需要为您的主机编译一个跨目标调试器,以使其能够与您的目标 gdb 一起工作。

有关如何执行此操作的详细说明,请参阅本文:

使用 GDB 和 GDBserver 进行远程跨目标调试

Gdbserver does indeed work with multithreaded applications. However you do need to compile a cross target debugger for your host to get it to work with your target gdb.

See this article for a detailed description of how to do it:

Remote cross-target debugging with GDB and GDBserver

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文