eclipse-cdt-cloud / cdt-gdb-adapter

CDT GDB Debug Adapter
Eclipse Public License 2.0
28 stars 40 forks source link

Add a test executable with a broken shared library #241

Closed jonahgraham closed 1 year ago

jonahgraham commented 1 year ago

This is based on the usecase described in #239 and will form the basis of a test to make sure we don't lose such error messages.

To show the error in GDB outside of the adapter, do this:

$ make BrokenSO
gcc -shared -o libsomea.so -fPIC -g3 BrokenSO_libsomea.c
gcc -shared -o libsomeb.so -fPIC -g3 BrokenSO_libsomeb.c
gcc -o BrokenSO BrokenSO_main.c -g3 -L. -lsomea
mv libsomeb.so libsomea.so

$ LD_LIBRARY_PATH=$PWD gdb --quiet BrokenSO
Reading symbols from BrokenSO...
(gdb) b main
Breakpoint 1 at 0x1151: file BrokenSO_main.c, line 4.
(gdb) r
Starting program: /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO
/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO: symbol lookup error: /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO: undefined symbol: a
[Inferior 1 (process 212237) exited with code 0177]
(gdb)
jonahgraham commented 1 year ago

I don't think this test code adds anything valuable to the mix as there is no additional info returned by gdb, this code is pretty much equivalent of:

int main() {
    fprintf(stderr, "error message\n");
    return 0177;
}

The big difference is that the code doesn't get to main.