Questions tagged [gdb]

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

Filter by
Sorted by
Tagged with
-1 votes
2 answers
42 views

How can we edit the source code of GNU's gdb debugger?

I am on a Linux(Ubuntu 22) machine with gcc installed. We know that gcc comes with gdb as debugger. There are many commands in gdb and I want to change the behaviour of some inbuilt commands(disp). ...
Matthew kale's user avatar
0 votes
0 answers
15 views

gdb watch a expr in a loop

code snippet: foreach(lc, vars) { if (IsA(lfirst(lc), Var)) { Var *var = (Var *) lfirst(lc); /* if system column, return error */ if (var->varattno < 0) ...
jian's user avatar
  • 539
0 votes
1 answer
67 views

gdb print out a pointer is null or not

source:https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/optimizer/plan/planner.c (gdb) n 3556 if (root->group_pathkeys) (gdb) s 3558 else if (root->...
jian's user avatar
  • 539
0 votes
0 answers
37 views

Same binary & different permissions, How can it be?

I was doing a pwn ctf and found a weird situation. The ctf includes binary file and a server. There is a given elf 64 bit. checksec output (same local & server). Arch: amd64-64-little RELRO: ...
Ori's user avatar
  • 1
0 votes
1 answer
20 views

gdb execute through to a specific function

https://git.postgresql.org/cgit/postgresql.git/tree/src/test/modules/delay_execution/delay_execution.c https://stackoverflow.com/questions/11967440/stepping-into-specific-function-in-gdb I loaded the ...
jian's user avatar
  • 539
0 votes
0 answers
28 views

Unable to break to libc function from gdb

Target: gdbserver --wrapper env "LD_PRELOAD=/test.so" -- :1234 /bin/true Debugger: # gdb-multiarch -ex 'set arc arm' -ex 'target remote :1234' ... For help, type "help". Type &...
user212942's user avatar
0 votes
1 answer
36 views

How to debug (gdb) a binary that is invoked with xvfb-run?

I have a binary that I usually run as follows: $ xvfb-run ./bin --param1 foo However, now that I need to debug it using GDB, I'm not able to do: $ gdb --args xvfb-run ./bin --param1 foo because &...
bert's user avatar
  • 255
0 votes
0 answers
45 views

quick-swap TUI mode while using vi keybindings in GDB

In the default mode of gdb, pressing ctrl+x a turns on and off the UI, and ctrl+x 2 cycles through different split views. There are a number of similar useful shortcuts. I can turn on vi emulation ...
Fraser's user avatar
  • 101
0 votes
0 answers
78 views

Run GDB on background

I'm working on a program where I have 2 ncurses window, one displaying my custom shell implemented with fork+exec and on the other I want show some info about command ran on my shell. For that, I'm ...
brunos098's user avatar
0 votes
1 answer
99 views

How can I remotely debug linux module using GDB?

I searched all over the internet but couldn't find proper steps to debug linux module remotely using gdb. I am tring qemu but facing many issues there. Is there any other tool that I can use or if not ...
Sumit Patil's user avatar
0 votes
1 answer
219 views

GDB fails to download debuginfo for math.h

I have a simple clock program that uses math.h functions. I am currently on Kubuntu 21.10, the GCC version is (Ubuntu 12.2.0-3ubuntu1) 12.2.0, and the GDB version is (Ubuntu 12.1-3ubuntu2) 12.1. The ...
L_R's user avatar
  • 43
1 vote
1 answer
143 views

Iterate through files and excute gdb command for each file in bash scripting

I'm trying to find a files with name and copy it into one text file using bash scripting What I need to do is I want to add one more command to it so that it is iterate through these files and execute ...
Angela's user avatar
  • 11
0 votes
1 answer
359 views

Finding the address of an environment variable with and without GDB

I am trying to do an exploit, which spawns a shell, the shellcode is inside an environment variable and I launch the program or GDB with a clean environment so the variable is at the top. env -i MYVAR=...
Josh's user avatar
  • 3
0 votes
2 answers
1k views

Permission error when attaching GDB to PID of running process

I have such a toy C++ program #include <iostream> int main() { int n{}; std::cin >> n; // waits for input std::cout << n << std::endl; } which pauses upon ...
Enlico's user avatar
  • 1,471
1 vote
1 answer
37 views

Start GDB with No Help Information

Every time I start gdb, the following information is displayed: GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later &...
Ziqi Fan's user avatar
  • 217
1 vote
1 answer
249 views

How to install gdb with no package manager?

I'm trying to reverse engineer some software on a system that runs embedded Linux. I've ssh-ed into it, and right now I'm trying to attach gdb to one of the processes so I can get some information on ...
Josh Tint's user avatar
0 votes
0 answers
229 views

debugger as a tool to get to root shell

according to the answer in the reference: Can gdb debug suid root programs? Claims that: "You can only debug a setuid or setgid program if the debugger is running as root. The kernel won't let ...
linuxbeginner's user avatar
3 votes
3 answers
16k views

How to Set up Environment Variables in "launch.json" Configuration When Using GDB Integration in VS Code

I have a setup in launch.json for vscode as follows: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information,...
Ziqi Fan's user avatar
  • 217
0 votes
1 answer
245 views

calling vim with mpiexec says "Warning: Output is not to a terminal / Warning: Input is not from a terminal"

My question is a bit technical. For specific reason, I need to call vim after mpiexec. Example : mpiexec -n 1 vim mytext.txt But this gives the following warning message: Vim: Warning: Output is not ...
Kiven Jecquas's user avatar
2 votes
0 answers
211 views

Debug & analyze pthread_mutex_lock issues

I've being recently facing some hardcore issues with Mutex lock for Linux, notably MySQL, memcache & APCu. Example: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting ...
Wiika's user avatar
  • 121
1 vote
1 answer
599 views

What does debug symbol actually mean on Arch linux for gdb debugging?

P.S. English is not my native language; please excuse typing errors. I've (maybe) understand the basically main idea of symbol in ELF file in dynamic link. Refering to textbooks, if I need dynamic ...
KSroido's user avatar
  • 13
1 vote
0 answers
256 views

Is it possible to get each thread's `comm` from a core dump with gdb?

I wrote a C program that uses multiple threads. For convenience I set the threads comm to some individual value for each thread, and that even might change depending on the state of the thread (a bit ...
U. Windl's user avatar
  • 1,104
2 votes
2 answers
2k views

How can I get glibc/libstdc++ sources and set them up for gdb to find?

I'm debugging this program which raises an exception. This makes my debugger look for some source code, e.g. ../sysdeps/unix/sysv/linux/raise.c - and fail to find it. Now, I realize it's not necessary ...
einpoklum's user avatar
  • 8,852
1 vote
0 answers
271 views

Can't compile linux kernel with -Og/-O0 option for debugging purpoces

Having custom hardware running embedded Linux (OpenWrt) like a charm. CPU - is IMX6ULL (ArmV7) so it is supported by Jlink to debug over JTAG interface. Starting GDB server and step by step debugging ...
user3583807's user avatar
1 vote
1 answer
351 views

How to have gdb start in vi mode by default?

I know that I can use CTRL+ALT+J in gdb to get vim keybindings but how do I get gdb to start in vi mode by default ?
cassepipe's user avatar
  • 172
0 votes
1 answer
296 views

How to catch and break on a Fortran 90 runtime error in GDB?

Is it possible to have Fortran 90 break at a runtime error in GDB? I show here a MWE for a simple routine test.f90 which throws an out of bounds error: program main implicit none integer ...
tdstoff's user avatar
0 votes
3 answers
365 views

GDB Disassemble: Print only raw binary data (using column and awk)

I'm trying to get only the raw binary data from the gdb disassemble output. My current output is the following: $ gdb -batch -ex "disassemble/r btif_set_adapter_property" libbluetooth_qti.so ...
dtrunk's user avatar
  • 103
0 votes
1 answer
542 views

Two processes mapped in the same address space

I have noticed that when I open two processes with GDB for debugging, /proc/PID/maps indicate the same address regions for the two : cat /proc/4170/maps 555555554000-555555555000 r--p 00000000 08:01 ...
Aramya's user avatar
  • 1
1 vote
1 answer
333 views

How to kill an orphan Terminal process

I have a java program that executes several shell files (one by each iteration). The shell file only has one command, start cross-gdb with a path to a gdbinit file. The program works fine, but (from ...
husin alhaj ahmade's user avatar
5 votes
2 answers
3k views

GDB Installed From homebrew on macOS Big Sur Fails to Load Symbols From elf32-i386 Binary

for the past little bit I've been slowly working on developing a hobbyist kernel, and for all that time I've been using GDB with QEMU to investigate memory locations and registers and what not. ...
aurxenon's user avatar
1 vote
0 answers
2k views

Ptrace: Function Not Implemented in GDB Installed on Multiarch/Qemu-User-Static Arm64v8/Alpine Docker Container

I want to debug an aarch64 ELF using GDB installed on an arm64v8/alpine docker on my x86_64 16.04 Ubuntu VirtualBox, which itself is installed on my Mac. In particular, to set up the docker I use the ...
Newbie's user avatar
  • 135
0 votes
1 answer
1k views

Emulating an AARCH64 Binary calling libgps on x86_64 Ubuntu using QEMU gives "Error relocating: symbol not found" Errors

This is similar to the issue posted here and here. I want to reverse engineer a binary called gpslogger but before debugging it using GDB, I wish to simply emulate it using QEMU (qemu-aarch64) since ...
Newbie's user avatar
  • 135
1 vote
0 answers
130 views

I'm having a hard time getting gdb to work on mojave

I'm running Mojave on my Macbook pro. I've installed gdb 8.3 via brew. I've codesigned it following the instructions given in https://sourceware.org/gdb/wiki/PermissionsDarwin I've also turned system ...
Richard Gostanian's user avatar
4 votes
1 answer
912 views

How to debug Linux kernel with JTAG + GDB?

I've successfully established a JTAG connection and serial port connection to my development board. I've followed the below diagram (with a little bit of difference). my GDB_client is on my Linux host ...
Mahyar Shokraeian's user avatar
0 votes
0 answers
256 views

How to debug a cpp file that's part of a so file in the software?

So I have this software which has multiple .so files. For one of the so file and I made some changes to the code but I want to see the line by line execution of file present in the so file. Just to ...
Himanshuman's user avatar
1 vote
1 answer
1k views

The memory dump of a process by using GDB inside a bash script - errors, problems

I want to dump some program's memory segment to a file. Because the working time of my program is milliseconds, I use named pipe to stop its execution and dump its memory content by gdb meanwhile. The ...
MiniMax's user avatar
  • 4,033
2 votes
0 answers
171 views

Fluke Etherscope stuck at loading kernel, Have JTAG Pins, and bootloader access

I had purchased two Fluke Etherscopes, these are stuck with the message 'Loading Kernel' on the screen. I was able to get a serial console, and access the bootloader using the serial port on the side ...
capnjck's user avatar
  • 21
2 votes
1 answer
131 views

How to debug application which is using /dev/port using gdb

I've got a simple C++ code to work with old ISA card fd = open("/dev/port", O_RDWR); if (fd == -1) { Error() << "Error fd = -1" << msg_show; return; } and also ...
qmor's user avatar
  • 121
1 vote
0 answers
86 views

gdb list step into targets

Is there a way in gdb to get a list of functions you could step into when the current line is composed of several function calls like foo(computeParam1(), computeParam2(), computeParam3())?
Trass3r's user avatar
  • 111
4 votes
1 answer
1k views

How to disassembly multiple functions using Linux utility objdump?

After a program is compiled and the binary file is generated, we can use objdump to disassemble the binary file and extract the assembly code and a lot of information. However, using -j .text with ...
husin alhaj ahmade's user avatar
2 votes
0 answers
223 views

How to debug Qt-application installed via Flatpak

I'm trying to enable debug for QOwnNotes application installed via Flatpak (following this tutorial: Debugging a Flatpak application). I have installed application itself and debug parts for its Sdk ...
anlar's user avatar
  • 4,096
1 vote
1 answer
1k views

How can we perform an arithmetic operation on a register using GDB? [closed]

I want to inject a bit-flip fault into a running program. For this purpose, I'm using gdb to insert a breakpoint into the target program and then flipping a single bit in a random-selected register. ...
husin alhaj ahmade's user avatar
0 votes
1 answer
119 views

Red hat vs Ubuntu compile and assembly Problem(Book reference)

Can you recommend me OS mentioned in Shellcoder's Handbook because I'm having frequent issues on running ELF files mentioned there(See the errors below). I know that to overcome those error I have to ...
Evil Dead's user avatar
2 votes
0 answers
4k views

Feed gdb stdin with multiple inputs from a file

This has been driving me crazy and it must be so simple! I've looked at many solutions but none seems to work with my application. I'm debugging a program in gdb. The program takes two inputs like ...
M P's user avatar
  • 21
4 votes
0 answers
1k views

Reload symbol table after recompilation in gdb

Lets say I have written a simple C++ program #include <stdexcept> int main(int argc, char *argv[]) { throw std::logic_error("Error"); return 0; } This program (compiled with g++ -O0 -ggdb ...
hfhc2's user avatar
  • 235
0 votes
1 answer
1k views

Error in dpkg when executing apt-get upgrade ( most of the commands )

Typing apt-get upgrade returns the following error: dpkg: error processing package gdb (--configure): package is in a very bad inconsistent state; you should reinstall it before attempting ...
M.vignesh raja's user avatar
0 votes
1 answer
550 views

(Ubuntu 16.04) How to prevent they greying-out of unresponsive windows?

I've got an application running on Ubuntu. Whenever it fails to respond to system events (because threads deadlocked, or busy-looping), the windows gets greyed out. I understand this is useful in most ...
Jeffrey's user avatar
  • 101
3 votes
1 answer
2k views

How can I install i386/x86 shared libraries on freebsd?

GDB is telling me, that the program compiled with gcc -m32 (i386 program) is incompatible with my shared libraries (i386:x86-64). Output of gdb: (gdb) r Starting program: /root/format warning: `/...
BitFriends's user avatar
0 votes
0 answers
471 views

gdb internals and setuid bit

I understand the fact that, in the case of setuid program, ptrace doesn't work well without root privilege. Then, how does gdb work with setuid bit enabled executable and non-root privilege? To ...
dnjsdnwja's user avatar
  • 111
2 votes
1 answer
161 views

How to pass zeroes in the argument to the program [duplicate]

I have this program in C. #include <stdio.h> #include <string.h> char * pwd = "pwd0"; void print_my_pwd() { printf("your pwd is: %s\n", pwd); } int check_pwd(char * uname, char * ...
Niklas Rosencrantz's user avatar