Questions tagged [gdb]

The GNU Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages.

168 questions
90
votes
3 answers

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 finished the debugging. I guess it was because…
Pichi Wuana
  • 1,159
  • 2
  • 9
  • 10
33
votes
5 answers

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 debug a memory leaks of a running process?
howtechstuffworks
  • 439
  • 1
  • 5
  • 5
26
votes
4 answers

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 then have to go to user/run/ and then type…
user4352158
  • 431
  • 2
  • 6
  • 9
21
votes
1 answer

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 .text_addr = 0xa0070000 (y or n) How to make it not ask and…
xmllmx
  • 1,750
  • 2
  • 19
  • 29
18
votes
2 answers

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 a.out it starts the process as normal user, and launches a…
jyz
  • 657
  • 2
  • 10
  • 17
16
votes
2 answers

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 it. What does it mean?
Display name
  • 1,267
  • 2
  • 14
  • 22
14
votes
2 answers

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 able to get a snapshot of the process under normal…
Falmarri
  • 12,897
  • 17
  • 58
  • 71
12
votes
2 answers

Unix History: return code octal?

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: http://comments.gmane.org/gmane.comp.gdb.devel/30363 But that's not a particularly satisfying answer. Some quick…
Pat
  • 223
  • 1
  • 5
11
votes
5 answers

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 executable contained within the core dump? …
user13757
10
votes
4 answers

why doesn't gdb like aliases

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: > gdb ff GNU gdb (Debian 7.12-6+b1)…
shirish
  • 11,967
  • 27
  • 107
  • 190
9
votes
3 answers

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 script?
Viesturs
  • 933
  • 3
  • 10
  • 15
8
votes
1 answer

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 tips over 4G (I guess the return value of the…
Gaius
  • 358
  • 5
  • 19
8
votes
2 answers

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. Either assembly, or some sort of middle ground…
cat pants
  • 753
  • 5
  • 23
  • 38
7
votes
2 answers

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 offending process (or try kill -SIGTERM), but that…
Reinstate Monica
  • 663
  • 8
  • 21
7
votes
1 answer

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 libc library is repeated 4 times; if they have…
John P
  • 1,053
  • 2
  • 10
  • 20
1
2 3
11 12