Questions tagged [gdb]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
35
votes
1answer
53k views

How to step-into, step-over and step-out with GDB?

I typed help while I was in the GDB but didn't find anything about step-into, step-over and step-out. I put a breakpoint in an Assembly program in _start (break _start). Afterwards I typed next and it ...
18
votes
5answers
33k views

How can I find a memory leak of a running process?

Is there a way, I can find the memory leak of a running process? I can use Valgrind for finding memory leaks before the start of a process. I can use GDB to attach it to a running process. How could I ...
16
votes
2answers
3k views

What does C@t{++} mean in the gdb man page?

I was reading the manpage for gdb and I came across the line: You can use GDB to debug programs written in C, C@t{++}, Fortran and Modula-2. The C@t{++} looks like a regex but I can't seem to decode ...
16
votes
2answers
16k views

Can gdb debug suid root programs?

I wrote a program that calls setuid(0) and execve("/bin/bash",NULL,NULL). Then I did chown root:root a.out && chmod +s a.out When I execute ./a.out I get a root shell. However when I do gdb ...
15
votes
3answers
27k views

How to compile without optimizations -O0 using CMake

I am using Scientific Linux (SL). I am trying to compile a project that uses a bunch of C++ (.cpp) files. In the directory user/project/Build, I enter make to compile and link all the .cpp files. I ...
12
votes
2answers
8k views

Dump process core without killing the process

Is there a way to get a core dump (or something similar) for a process without actually killing the processes? I have a multithreaded python process running on an embedded system. And I want to be ...
11
votes
1answer
4k views

How to make gdb not ask me “y or n”?

When I use GDB command add-symbol-file to load the symbol, GDB always asks me 'y or n', like this: gdb> add-symbol-file mydrv.ko 0xa0070000 add symbol table from file "mydrv.ko" at ....
10
votes
4answers
1k views

why doesn't gdb like aliases [duplicate]

I made an alias ff and sourced it from ~/.zsh/aliases.zsh. The aliases run well themselves: alias ff ff='firefox --safe-mode' and it runs as expected. But when I try to run it under gdb I get: &...
10
votes
3answers
6k views

Why does GDB need the executable as well as the core dump?

I'm debugging using core dumps, and note that gdb needs you to supply the executable as well as the core dump. Why is this? If the core dump contains all the memory that the process uses, isn't the ...
10
votes
2answers
920 views

Unix History: return code octal?

// EDIT: Request to move this question to unix.stackexchange.com I was thrown off guard today by gdb: Program exited with code 0146. gdb prints the return code in octal; looking into why I found: ...
8
votes
2answers
2k views

How to determine what instructions a process is executing?

I know about strace and ltrace, but that only tells me what system calls and library calls a process is executing, respectively. I would like to know exactly what instructions a process is executing. ...
7
votes
6answers
3k views

Run program at lower CPU speed?

It would be very useful for me to run specific programs in a Linux environment with a fixed (lower) CPU clock speed (say, runat 400mhz ./my-program --argument-of="my program" for getting that clock ...
7
votes
1answer
4k views

Can anything useful be done with a truncated core?

We have processes written in a mix of Python, Java and C++ that core dump from time to time. They allocate more memory in chunks as needed during runtime, and are known to crash when their allocation ...
6
votes
1answer
2k views

How to save the result of printf to a variable in GDB?

(gdb)printf "Hello %d", 7 Hello 7 (gdb)set $MyVar = printf "Hello %d", 7 // ??? How to save the result of printf "Hello %d", 7 to $MyVar?
6
votes
1answer
3k views

What exactly is and what does a core dump of process contain?

It's clear that GDB can generate a core dump of process for example via its wrapper - gcore, however it's not clear what exactly it includes and it's really hard to find an answear because different ...
5
votes
3answers
1k views

GDB step in delays

I am making a nice presentation of ARM assembly code execution and I would need GDB to step the code every 1 second infinitely long (well until I press CTRL+C). Has anyone got solution? I don't want ...
5
votes
1answer
363 views

How to produce a VLC stack trace?

I've reported a VLC bug and included the output of gdb's bt full, but the response from a project representative is that the trace is "incomplete". How can I produce a trace that would be usable to a ...
5
votes
2answers
323 views

bash / gdb autocompletes core file on RedHat but not on Ubuntu

When a program dumps core, we have set our kernel.core_pattern to put the core file in a particular location with a certain filename etc. kernel.core_pattern = | /var/core_file_handler.py %e %s %p %...
5
votes
2answers
2k views

The structure of /proc/kcore on 64-bit machine and relation to physical memory

Let me preface this question by saying that I've found a lot of answers for questions similar to my question but for 32-bit machines. However, I can't find anything for 64-bit machines. Please no ...
5
votes
1answer
7k views

GDB cannot exec my test program

My computer run with Ubuntu 14.04. GDB seems to be abnormal in different account. For example I make a very simple test. I write a file under ~/test/test.c like this: #include <stdio.h> #...
5
votes
2answers
701 views

Safest way to force close a file descriptor

Sometimes you need to unmount a filesystem or detach a loop device but it is busy because of open file descriptors, perhaps because of a smb server process. To force the unmount, you can kill the ...
5
votes
1answer
5k views

permission denied for ptrace under GDB

I have set a super simple C program and compiled it with GCC (with the -g flag). I've tried running it with gdb a.out, set a breakpoint on main and run it, but GDB ignored my breakpoint and simply ran ...
5
votes
1answer
759 views

Backtrace of “git clone” running inside qemu-user-emulation based arm-chroot

I'm running a wheezy:armhf chroot using qemu user emulation on my jessie:x86_64 system. Somehow, a git clone on a particular private repository will hang inside the chroot, while succeed natively. ...
4
votes
2answers
4k views

gdb in one command

When I debug an executable program with arguments arg1 arg2 with gdb I perform the following sequence gdb file ./program run arg1 arg2 bt quit How can I do the same from one command line in shell ...
4
votes
1answer
5k views

How to set up gdb to scan through heap memory?

I want to print out and analyze the contents of the system heap. Obviously, this should be a privileged operation, and might go against the grain of what GDB was intended to do. Specifically, I want ...
4
votes
1answer
283 views

Why some libraries and other parts get repeated in the linux virtual memory with gdb?

This is the result of looking at virtual memory of a process in gdb; I have some questions regarding this: Why are some parts of the virtual memory are repeated? For example, our program (stack6) and ...
4
votes
1answer
1k views

Hardware breakpoint in GDB +QEMU missing start_kernel

I am trying to debug a kernel running on QEMU with GDB. The kernel has been compiled with these options: CONFIG_DEBUG_INFO=y CONFIG_GDB_SCRIPTS=y I launch the kernel in qemu with the following ...
4
votes
2answers
4k views

Missing separate debuginfo for - GDB

I have mentioned -g option along with -Wall in the Makefile. When I run gdb onlineSunday, I get: Missing separate debuginfo for /usr/lib64/kde4/plugins/imageformats/kimg_dds.so Try: zypper install -...
4
votes
1answer
3k views

gdb attach permission question (ptrace_scope is read-only)

When using gdb to attach to the process. It shows Could not attach to process. If your uid matches the uid of the target process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try ...
4
votes
2answers
2k views

How can I run gdb in one machine and run kgdb kernel in another machine?

I want to run two machine: debugged machine: compiled kernel with kgdb option. debugger machine: for running gdb How can I debug machine 1 from machine 2?
4
votes
1answer
184 views

How to prevent a process from writing to the systemd journal?

I am using a third party .NET Core application (a binary distribution used by a VS Code extension) that unfortunately has diagnostic logging enabled with no apparent way to disable it (I did already ...
4
votes
1answer
695 views

QEMU for ARM programs with GDB [closed]

I want to emulate an ARM processor for running the assembly programs using QEMU in RHEL. I have installed QEMU but I still have problems in running the assembly program. I got the assembly program, ...
4
votes
0answers
147 views

Interrupt a slow gdb command?

I unwisely asked gdb to list all defined functions. (gdb) info function Now it is excitedly slurping up CPU and memory. If I'm really quick about it, GDB will stop with Ctrl-C and give me a prompt ...
4
votes
0answers
337 views

gdb hangs on “quit()”

When I want to close gdb, I frequently mistype quit() instead of quit Whenever that happens, gdb hangs indeterminately, and I end up using kill -9 gdb_pid to terminate it. I would like to ask: ...
3
votes
1answer
2k views

GDB up arrow doesn't work

I searched a lot about similar problems but found nothing. When running gdb I couldn't use up arrow for walking through previous commands. Up and down arrows are just ignored. I have started to ...
3
votes
1answer
2k views

Elapsed time in gdb

Is there a way to measure elapsed time running the program under gdb? Look to this: <------------bp----------------------------------> Assume that we are debugging a file and in some random ...
3
votes
1answer
767 views

Why does a gdb client fail to talk to its gdb server when started by this “expect” script?

I'm building a continuous integration environment for a firmware codebase, programming an ARM Cortex M0 using a Segger JLink device and running tests on the target using gdb and Segger's RTT tool. I ...
3
votes
1answer
4k views

“Missing separate debuginfo for …” when running gcore

I am running the following: command: gcore 56058 output: Missing separate debuginfo for /lib64/libdl.so.2 Try: zypper install -C "debuginfo(build-id)=dcca9c1f648bda0a7318a7c8844982c440e3e4a3" ...
3
votes
1answer
237 views

gdb set overwrite logging on should overwrite gdb.txt correct?

I was looking at Logging Output and had been trying this particular command - set logging overwrite on AFAI understood it, that command is supposed to overwrite the contents of gdb.txt but it does ...
3
votes
1answer
267 views

GDB hangs forever on Solaris

GDB seems to hang everytime when I try run command from gdb prompt. When I ran ps, there are two gdb processes that have been spawned and pstack reveals the following - 15:47:02:/home/stufs1/...
3
votes
2answers
959 views

GDB throws error on Arch Linux

When I try stepping through a program, gdb throws this error std::ostream::operator<< (this=0x6013c0 <std::cout@@GLIBCXX_3.4>, __n=2) at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/...
3
votes
1answer
268 views

Accessing memory mapped registers in gdb

I'm trying to read (hopefully write as well) to the memory mapped hardware registers in a qemu virtual machine using gdb (remote connected). But it's just not working: (gdb) p *0x2000000 Cannot ...
3
votes
0answers
98 views

kgdb not returning control to gdb

I've compiled a kernel with kgdb support and I'm trying to debug it. I have two machines running, a debug machine (running the kgdb kernel) and the machine I'm using to debug it. They are connected ...
2
votes
1answer
4k views

what are some of the best resources to learn advanced debugging techniques using gdb? [closed]

I know the basics of how to use gdb. But I would like to learn some advanced debugging techniques using gdb. What are the best resources - books, blogs, tutorials - that any of you use regularly. I ...
2
votes
2answers
2k views

Using gdb to inspect environment variables

I have been trying to find the address of the SHELL environment variable in a program on a Ubuntu 12.04 machine. I have turned off ASLR. I found similar posts : SO question and blog post I have ...
2
votes
1answer
8k views

Missing separate debuginfos

I'm trying to debug a code using GDB in a Fedora machine. It produces this message each time I run it. Missing separate debuginfos, use: debuginfo-install glibc-2.18-12.fc20.x86_64 libgcc-4.8.3-1....
2
votes
2answers
236 views

Tshark not running via gdb

I have successfully installed wireshark on centos 6.4 I can run the command tshark it works perfectly fine. I want to run gdb so that I want to learn how it decodes tcp and udp packet as I am writing ...
2
votes
1answer
882 views

Debug a setuid binary as non-root

I have a CentOS 7 system. I need to attach my GDB to an already running application, but get the (apparently usual) "ptrace: Operation not permitted." error. Running GDB as root prevents the error, ...
2
votes
1answer
3k views

ptrace: Operation not permitted when attaching to a zombie process

I have a reproducible situation where a compiler instance goes into a zombie state when I rebuild a package, but gdb won't permit me to attach: serenity ~ # ps ax | grep defunct 11351 pts/1 Z+ ...
2
votes
1answer
1k views

Measure exact clock cycles for a C/assembly program

I need to measure the exact number of clock cycles it takes to execute a program. I already used the clock() function but it's values are dependent on system parameters. I could not figure out how to ...