Why would gdb hang?
I'd say the debugged process wouldn't sit idle if it was the cause of the hang. Every time GDB has completed a step, it has to update any expressions you required to print. It may include following pointers and so, and in some case, it may fail there (although I don't remind of a real "hang"). It also typically try to update your stack trace. If the stack trace has been corrupted and is no longer coherent, it could be trapped into an endless loop. Attaching gdb to strace
to see what kind of activity is going on during the hang could be a good way to go one step further into figuring out the problem.
(e.g. accessing sources through a no-longer-working NFS/SSHFS mount is one of the most frequent reason for gdb to hang, here :P)
gdb hanging when attaching to java process
Finally found out what was going on. Java uses SIGSEGV during garbage collection, which is intercepted by gdb causing an apparently crash. To solve this I added handle SIGSEGV pass nostop
to my ~/.gdbinit
file.
GDB hangs during remote debugging, library version mismatches
Upgrading versions, while a very large headache, could be possible but probably should not be necessary...
This is the right option. All of the other issues you are encountering are because of this.
I've tried this in another virtual machine and I even built a fresh dedicated linux install (so no vm), rebuilt the software, and I get the same behavior. So it appears the issue is probably on the target machine's configuration.
You should build on the same version, architecture, etc. as the system you are attempting to deploy your code to.
But then when I try to set breakpoints, I get Error accessing memory address 0xb5eb60: Input/output error.
Per this answer,
Can be caused by 32/64 bit mixups. Check, for example, that you didn't attach to a 32-bit binary with a 64-bit process' ID, or vice versa.
I also tried putting the libc from the host computer onto the target machine, and it won't even boot, it gets a segfault in libc.
Don't do that. As you've found out, it won't work.
So how do I get gdb to load different libraries?
Per this question, you can use LD_LIBRARY_PATH
.
Related Topics
Disable CPU Caches (L1/L2) on Armv8-A Linux
Find' (Command) Finds Nothing with -Wholename
Need Some Advise to Begin Programming on Arm (With Linux) Platform
Where Is G_Multi Configured in Beaglebone Black
Sort a File Based on a Column in Another File
How to Selectively Create Symbolic Links to Specific Files in Another Directory in Linux
Reading Memory Pointed by Register with Gdb
How to Remove File with Special Characters
Elf File Tls and Load Program Sections
How to Use Opengl Without a Window Manager in Linux
Combine Two Audio Files with a Command Line Tool
Access Podman Rest API from Testcontainer