如何调试嵌入式进程?

时间:2021-07-09 20:44:35

I have a problem with debugging a process on arm + Linux platform:

我有一个在arm + Linux平台上调试进程的问题:

This is a daemon process working with CAPWAP protocol, so it continuously communicates with another remote process. When it crashes with a segmentation fault, my usual means of debugging is to add some log output via printf, to find where the process has crashed, but it's not very efficient.

这是一个与CAPWAP协议一起工作的守护进程,因此它可以继续与另一个远程进程通信。当它由于分割错误而崩溃时,我通常的调试方法是通过printf添加一些日志输出,以查找进程已经崩溃的位置,但这不是很有效。

Is there any other way to debug this problem?

还有其他方法来调试这个问题吗?

2 个解决方案

#1


3  

You could also enable core(5) dump, then use gdb post-mortem on that core with

您还可以启用core(5)转储,然后在该核心上使用gdb后期分析

  gdb yourprogram core

To enable core dump, you need to call the setrlimit(2) syscall with RLIMIT_CORE, usually in some parent process (e.g. the shell with ulimit)

要启用核心转储,需要使用RLIMIT_CORE调用setrlimit(2) syscall,通常在一些父进程中(例如带有ulimit的shell)

BTW, you could also start your program thru gdb using

顺便说一句,你也可以通过gdb启动你的程序

  gdb --args yourprogram argtoyourprogram

Don't forget to compile your program with gcc -Wall -g. The -Wall options give almost all warnings (very useful), and the -g produces debugging information.

不要忘记使用gcc -Wall -g编译程序。-Wall选项提供了几乎所有的警告(非常有用),而-g生成调试信息。

#2


0  

There are two options for debugging in this case.

在这种情况下,有两个调试选项。

  1. Debug your program using GDB debugger. You can set breakpoints in your program using GDB.

    使用GDB调试器调试程序。可以使用GDB在程序中设置断点。

  2. Use Android-ndk for debugging your segmentation fault. This kind of debug can provide the exact location of the error.

    使用Android-ndk调试分割错误。这种调试可以提供错误的确切位置。

#1


3  

You could also enable core(5) dump, then use gdb post-mortem on that core with

您还可以启用core(5)转储,然后在该核心上使用gdb后期分析

  gdb yourprogram core

To enable core dump, you need to call the setrlimit(2) syscall with RLIMIT_CORE, usually in some parent process (e.g. the shell with ulimit)

要启用核心转储,需要使用RLIMIT_CORE调用setrlimit(2) syscall,通常在一些父进程中(例如带有ulimit的shell)

BTW, you could also start your program thru gdb using

顺便说一句,你也可以通过gdb启动你的程序

  gdb --args yourprogram argtoyourprogram

Don't forget to compile your program with gcc -Wall -g. The -Wall options give almost all warnings (very useful), and the -g produces debugging information.

不要忘记使用gcc -Wall -g编译程序。-Wall选项提供了几乎所有的警告(非常有用),而-g生成调试信息。

#2


0  

There are two options for debugging in this case.

在这种情况下,有两个调试选项。

  1. Debug your program using GDB debugger. You can set breakpoints in your program using GDB.

    使用GDB调试器调试程序。可以使用GDB在程序中设置断点。

  2. Use Android-ndk for debugging your segmentation fault. This kind of debug can provide the exact location of the error.

    使用Android-ndk调试分割错误。这种调试可以提供错误的确切位置。