Using "Connect to gdbserver" option overwrites/corrupts input binary
- Dominant language
- TypeScript
- Stars
- 10.4k
- Forks
- 521
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
As noted, I just tried gdbgui, I followed the guide and typed in my binary path (which is in the current working directory), and hit "Load binary". The md5sum of the binary then changes, and attempting to run it shows it's been corrupted.
**To Reproduce**
Steps to reproduce the behavior:
1. Type in a path to a binary
2. Hit "Load Binary"
3. Hit "Connect to gdbserver"
4. Compare contents/hashes of the binary before and after
5. Observe that they are different
In this case, with a simple C hello world:
```$ md5sum g g.bak
e69083542e702b7f5a8feb304a958d8a g # corrupted by gdbgui
36690ecdd2b375e200ce03a7870d1e09 g.bak # backed up original
```
**Expected behavior**
Not modifying the input binary
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Please complete the following information:**
* OS: Linux
* gdbgui version (`gdbgui -v`): 0.14.0.2
* gdb version (`gdb -v`): GNU gdb (Ubuntu 8.3-0ubuntu1) 8.3
* browser [e.g. chrome, safari]: Firefox
* python packages (`pip freeze`):
**Additional context**
The gdb console says:
> Remote connection closed
And that's it.
It overwrites the ELF header with:
```
0000h: 2B 24 71 53 75 70 70 6F 72 74 65 64 3A 6D 75 6C +$qSupported:mul
0010h: 74 69 70 72 6F 63 65 73 73 2B 3B 73 77 62 72 65 tiprocess+;swbre
0020h: 61 6B 2B 3B 68 77 62 72 65 61 6B 2B 3B 71 52 65 ak+;hwbreak+;qRe
0030h: 6C 6F 63 49 6E 73 6E 2B 3B 66 6F 72 6B 2D 65 76 locInsn+;fork-ev
0040h: 65 6E 74 73 2B 3B 76 66 6F 72 6B 2D 65 76 65 6E ents+;vfork-even
0050h: 74 73 2B 3B 65 78 65 63 2D 65 76 65 6E 74 73 2B ts+;exec-events+
0060h: 3B 76 43 6F 6E 74 53 75 70 70 6F 72 74 65 64 2B ;vContSupported+
0070h: 3B 51 54 68 72 65 61 64 45 76 65 6E 74 73 2B 3B ;QThreadEvents+;
0080h: 6E 6F 2D 72 65 73 75 6D 65 64 2B 3B 78 6D 6C 52 no-resumed+;xmlR
0090h: 65 67 69 73 74 65 72 73 3D 69 33 38 36 23 36 61 egisters=i386#6a
```
Contributor guide
Assessment
This issue has not been assessed yet.