编写C / C ++代码时,为了debugging二进制可执行文件,必须在编译器/链接器上启用debugging选项。 在GCC的情况下,选项是-g。 当启用debugging选项时,如何影响二进制可执行文件? 允许debugging器function的文件中存储了哪些附加数据?
GDB是否有一个内置的脚本机制,我应该编写一个期望的脚本,还是有更好的解决scheme吗? 我会每次发送相同的命令序列,并将每个命令的输出保存到一个文件(很可能使用GDB的内置日志logging机制,除非有人有更好的主意)。
我希望能够在GDB中设置一个断点,并让它运行到这一点 – 并在这个过程中,打印出它已经“通过”的行。 下面是一个例子,基于这个带有main函数和函数的简单文件,以及两个断点: $ cat > test.c <<EOF #include "stdio.h" int count=0; void doFunction(void) { // two steps forward count += 2; // one step back count–; } int main(void) { // some pointless init commands; count = 1; count += 2; count = 0; //main loop while(1) { doFunction(); printf("%d\n", count); } } […]
我试图在eclipse cdt中为STL对象添加漂亮的打印。 我试图按照这里描述的步骤: http://sourceware.org/gdb/wiki/STLSupport 我检查了python文件夹,但我似乎无法完成这项工作… 我创build了一个gdbinit,并select了我的debuggingconfiguration,但每当我尝试开始debugging,我得到以下错误: Error while executing Python code. !STACK 0 java.lang.Exception: /home/lizardking/workspace/eu.sofia.kpi.cpp.x86.testapp/.gdbinit:6: Error in sourced command file: Error while executing Python code. at org.eclipse.cdt.dsf.mi.service.command.AbstractMIControl$RxThread.processMIOutput(AbstractMIControl.java:824) at org.eclipse.cdt.dsf.mi.service.command.AbstractMIControl$RxThread.run(AbstractMIControl.java:662) 如果我尝试在python shell中执行gdbinit的内容,我得到这个错误: Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. import sys sys.path.insert(0, '/home/Documents/python') […]
我在x86 Linux上有一些编译库,我想快速确定它们是否用debugging符号编译。
我想在GDB中检查一个std::vector的内容,我该怎么做呢? 为了简单起见,我们假设它是一个std::vector<int> 。
我是内核开发的新手,我想知道如何使用QEMU和gdb运行/debuggingLinux内核。 我其实读罗伯特·爱的书,但不幸的是,它不能帮助读者如何安装适当的工具来运行或debugging内核…所以我所做的是遵循本教程http://opensourceforu.efytimes.com / 2011/02 / kernel-development-debugging-eclipse / 。 我使用eclipse作为IDE在内核上开发,但是我想首先在QEMU / gdb下运行。 所以我到目前为止做的是: 1)编译内核: make defconfig (then setting the CONFIG_DEBUG_INFO=y in the .config) make -j4 2)一旦编译完成,我运行Qemu使用: qemu-system-x86_64 -s -S /dev/zero -kernel /arch/x86/boot/bzImage 在“停止”状态下启动内核 3)因此我必须使用gdb,我尝试下面的命令: gdb ./vmlinux 它正确运行,但是…现在我不知道该怎么做…我知道我必须使用远程debugging端口1234(Qemu使用的默认端口),使用vmlinux作为符号表文件debugging。 所以我的问题是:我应该怎么做才能在Qemu上运行内核,将debugging器附加到它上面,从而让它们一起工作,通过内核开发使我的生活更轻松。
现在我正在使用这样的function: #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> #include <unistd.h> void print_trace() { char pid_buf[30]; sprintf(pid_buf, "–pid=%d", getpid()); char name_buf[512]; name_buf[readlink("/proc/self/exe", name_buf, 511)]=0; int child_pid = fork(); if (!child_pid) { dup2(2,1); // redirect output to stderr fprintf(stdout,"stack trace for %s pid=%s\n",name_buf,pid_buf); execlp("gdb", "gdb", "–batch", "-n", "-ex", "thread", "-ex", "bt", name_buf, pid_buf, NULL); abort(); /* If gdb […]
在分析核心转储文件时,我需要检查哪些内容? 请从头开始告诉我。
我有一个multithreading的应用程序,在我的所有testing机器上都非常稳定,似乎几乎每个用户都稳定(基于没有崩溃的抱怨)。 应用程序经常为一个用户崩溃,但是,谁发送崩溃报告。 所有的崩溃报告(~10个连续的报告)看起来基本相同: Date/Time: 2010-04-06 11:44:56.106 -0700 OS Version: Mac OS X 10.6.3 (10D573) Report Version: 6 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 com.apple.CoreFoundation 0x90ab98d4 __CFBasicHashRehash + 3348 1 com.apple.CoreFoundation 0x90adf610 CFBasicHashRemoveValue + 1264 2 com.apple.CoreText 0x94e0069c TCFMutableSet::Intersect(__CFSet const*) const […]