cs01 / cs01/gdbgui

Fetch disassembly broken for source files that are symlinks. (sends link-target to gdb)

Open
#111 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10.4k
Forks
521
PR merge metrics
No merged PRs in 30d

Description

I'm on x86-64 Arch Linux (rolling release, updated last week), using python-gdbgui 0.7.9.5-1 built from https://aur.archlinux.org/packages/python-gdbgui/.

I have gdb 8.0 (from the Arch binary package), and my browser is Chromium 60.0.3112.101 (Developer Build) (64-bit) from the Arch binary package.

----

Disassembly output works with a hello world compiled with gcc, clang, g++, or clang++.

Disassembly output fails when the source file is a symlink. For example:

```
ln -s hello.c hello-link.c
gcc -g hello-link.c -o hello-link
```

Clicking "fetch disassembly" (even before the running the program) produces an error message in the gdb console:
`-data-disassemble: Invalid filename.` The message is also displayed in upper bar next to the a red "error" tag.

This happens with gcc7.1.1 / clang4.0.1 / g++ and clang++.

I used `strace -s1024 -p $(pidof gdb)` to see what command gdb actually received.

```
$ pgrep ...
/usr/bin/python /usr/bin/gdbgui ./hello-link
$ strace -s1024 -p $(pidof gdb)
strace: Process 16662 attached
restart_syscall(<... resuming interrupted restart_syscall ...>) = 1
read(0, "-", 1) = 1
read(0, "d", 1) = 1
read(0, "a", 1) = 1
read(0, "t", 1) = 1
read(0, "a", 1) = 1
read(0, "-", 1) = 1
read(0, "d", 1) = 1
read(0, "i", 1) = 1
read(0, "s", 1) = 1
read(0, "a", 1) = 1
read(0, "s", 1) = 1
read(0, "s", 1) = 1
read(0, "e", 1) = 1
read(0, "m", 1) = 1
read(0, "b", 1) = 1
read(0, "l", 1) = 1
read(0, "e", 1) = 1
read(0, " ", 1) = 1
read(0, "-", 1) = 1
read(0, "f", 1) = 1
read(0, " ", 1) = 1
read(0, "/", 1) = 1
read(0, "h", 1) = 1
read(0, "o", 1) = 1
read(0, "m", 1) = 1
read(0, "e", 1) = 1
read(0, "/", 1) = 1
read(0, "p", 1) = 1
read(0, "e", 1) = 1
read(0, "t", 1) = 1
read(0, "e", 1) = 1
read(0, "r", 1) = 1
read(0, "/", 1) = 1
read(0, "s", 1) = 1
read(0, "r", 1) = 1
read(0, "c", 1) = 1
read(0, "/", 1) = 1
read(0, "e", 1) = 1
read(0, "x", 1) = 1
read(0, "p", 1) = 1
read(0, "e", 1) = 1
read(0, "r", 1) = 1
read(0, "i", 1) = 1
read(0, "m", 1) = 1
read(0, "e", 1) = 1
read(0, "n", 1) = 1
read(0, "t", 1) = 1
read(0, "s", 1) = 1
read(0, "/", 1) = 1
read(0, "h", 1) = 1
read(0, "e", 1) = 1
read(0, "l", 1) = 1
read(0, "l", 1) = 1
read(0, "o", 1) = 1
read(0, ".", 1) = 1
read(0, "c", 1) = 1
read(0, " ", 1) = 1
read(0, "-", 1) = 1
read(0, "l", 1) = 1
read(0, " ", 1) = 1
read(0, "3", 1) = 1
read(0, " ", 1) = 1
read(0, "-", 1) = 1
read(0, "n", 1) = 1
read(0, " ", 1) = 1
read(0, "1", 1) = 1
read(0, "0", 1) = 1
read(0, "0", 1) = 1
read(0, " ", 1) = 1
read(0, "-", 1) = 1
read(0, "-", 1) = 1
read(0, " ", 1) = 1
read(0, "4", 1) = 1
read(0, "\n", 1) = 1
lstat("/home", {st_mode=S_IFDIR|0755, st_size=10, ...}) = 0
lstat("/home/peter", {st_mode=S_IFDIR|0755, st_size=1636, ...}) = 0
lstat("/home/peter/src", {st_mode=S_IFDIR|0755, st_size=214, ...}) = 0
lstat("/home/peter/src/experiments", {st_mode=S_IFDIR|0755, st_size=3284, ...}) = 0
lstat("/home/peter/src/experiments/hello.c", {st_mode=S_IFREG|0644, st_size=64, ...}) = 0
write(1, "^error,msg=\"-data-disassemble: Invalid filename.\"\n(gdb) \n", 57) = 57
read(7, 0x7ffc9861fcd7, 1) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}, {fd=7, events=POLLIN}, {fd=0, events=POLLIN}], 3, 0) = 0 (Timeout)
poll([{fd=3, events=POLLIN}, {fd=7, events=POLLIN}, {fd=0, events=POLLIN}], 3, -1
^Cstrace: Process 16662 detached

```

**So gdbgui sent the symlink-target filename, not the original source filename given to the compiler.**

The bar next to the "fetch disassembly" button says /home/peter/src/experiments/hello.c, but `strings -a hello-link` shows that `hello-link.c` appears in the file, but `hello.c` doesn't.

So gdb doesn't think hello.c is involved at all, but that's the file gdbgui is asking it for disassembly of.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.