Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to import gdb #62

Open
AntoinePrv opened this issue Apr 4, 2023 · 2 comments
Open

How to import gdb #62

AntoinePrv opened this issue Apr 4, 2023 · 2 comments
Labels

Comments

@AntoinePrv
Copy link

Comment:

I'm trying to set up the pretty printing function from the following in my ~/.gdbinit to find the gdb and libstdcxx modules.

import sys
import shutil
import pathlib

gdb_path = pathlib.Path(shutil.which("gdb")).resolve()
share_path = gdb_path.parent.parent / "share"

sys.path.insert(0, str(share_path / "gdb/python"))

for p in share_path.glob("gcc*"):
    if p.is_dir() and (p / "python").exists():
        sys.path.insert(0, str(p / "python"))
        from libstdcxx.v6.printers import register_libstdcxx_printers
        register_libstdcxx_printers(None)
        break

However, I do get the error:

File $CONDA_PREFIX/share/gdb/python/gdb/__init__.py:19
     17 import os
     18 import sys
---> 19 import _gdb
     20 from contextlib import contextmanager
     22 # Python 3 moved "reload"

ModuleNotFoundError: No module named '_gdb'

Looking around, it seems like _gdb is a Python extension module. Is it shipping with gdb? I cannot find any such module in the gdb conda-forge package.

@phil-blain
Copy link
Contributor

Hi!

I'm trying to set up the pretty printing function from the following in my ~/.gdbinit to find the gdb and libstdcxx modules.

Usually if everything is configured correctly, the libstdcxx pretty printers should "work outside the box".

How are you installing GCC ?

@phil-blain
Copy link
Contributor

Also, providing the conda list and conda info as the issue template asks would help pinpoint where the issue is :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants