2

I am getting python exception when I step the line of code. What I want is to step into or step over but I am getting this exception when I type (gdb) step and bang throws exception. I compiled the code with -g flag. throwing this exception

Python Exception <class 'NameError'> Installation error: gdb._execute_unwinders function is missing:

Thread 3 "s1.o" hit Breakpoint 2, get_payload_to_send (Python Exception <class 'NameError'> Installation error: gdb._execute_unwinders function is missing: p=0x55555555a2c0, pay=0x7ffff75bfe78) at ServerHi1.c:679 warning: Source file is more recent than executable.

679 char c[20]; (gdb) step

Python Exception <class 'NameError'> Installation error: gdb._execute_unwinders function is missing:

Python Exception <class 'NameError'> Installation error: gdb._execute_unwinders function is missing:

Python Exception <class 'NameError'> Installation error: gdb._execute_unwinders function is missing:

Python Exception <class 'NameError'> Installation error: gdb._execute_unwinders function is missing:

__inet_addr (Python Exception <class 'NameError'> Installation error: gdb._execute_unwinders function is missing: cp=0x55555555a6d2 "192.168.10.25") at inet_addr.c:210 210 inet_addr.c: No such file or directory.

(gdb)

What I want is step into/ step over single line. Coding in C

gdb version: GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git

2
  • This sounds like you gdb installation is broken. gdb._execute_unwinders should be in share/gdb/python/gdb/__init__.py. Commented Apr 5, 2021 at 11:58
  • How to fix the installation? Commented Nov 24, 2021 at 20:01

1 Answer 1

1

I installed gdb 11.1 from source and I was having the same error. I fixed by manually copying the python files into /usr/share/gdb/python, i.e.:

  1. cd gdb-11.1
  2. make
  3. make install
  4. cp -r ./gdb/python/lib/gdb/ /usr/share/gdb/python

Extra: Full steps for installing gcc 11.1 from source on Debian 10 as gdb111 instead of gdb (i.e., not overriding your system gdb):

apt update &&
apt install texinfo subversion wget \
    libgmp-dev python3-dev libncurses5-dev libsource-highlight &&
wget http://ftp.gnu.org/gnu/gdb/gdb-11.1.tar.gz &&
tar xvzf gdb-11.1.tar.gz &&
cd gdb-11.1 &&
./configure --prefix=/usr/local/gdb111 \
    --program-suffix=111 --with-python=python3 \
    --enable-tui=yes --with-curses --enable-gold=yes \
    --enable-ld=yes --enable-libada --enable-libssp \
    --enable-lto --enable-vtable-verify --enable-werror \
    --enable-source-highlight &&
make -j `nproc` &&
make install &&
rsync --recursive ./gdb/python/lib/gdb/ /usr/share/gdb/python/gdb/ &&
perl -pi -e '!$x && s/function black b;/function b;/i && ($x=1)' \
    /usr/share/source-highlight/esc.style &&
printf 'set debug-file-directory /usr/lib/debug/\n' >> ~/.gdbinit &&
cp /usr/local/gdb111/bin/gdb111 /bin/

Alternatively, instead of copy the files manually into your system, you cold run gdb with the parameter, e.g., gdb111 -p $(pidof someprocess) --data-directory /path/to/source/gdb-11.1/gdb/data-directory.

If you are not installing from source like this, you can reinstall/restore your gdb installation with sudo apt install --reinstall gdb

Update

Inside a Dockerfile recipe, you need to run perl in a separate step:

RUN perl -pi -e '!$x && s/function black b;/function b;/i && ($x=1)' /usr/share/source-highlight/esc.style
RUN svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python /root/gdb_stl_python \
    && printf 'python \nimport sys \nsys.path.insert(0, "/root/gdb_stl_python") \nfrom libstdcxx.v6.printers import register_libstdcxx_printers \nregister_libstdcxx_printers (None) \nend \n' >> /root/.gdbinit

References:

  1. https://superuser.com/questions/102449/how-to-reinstall-a-package-using-apt-get
  2. https://askubuntu.com/questions/32507/how-do-i-get-a-list-of-installed-files-from-a-package
  3. https://bugzilla.redhat.com/show_bug.cgi?id=1688372 - New gdb terminal colors are unreadable on GNOME Terminal "dark" theme
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.