Comments (7)
Thank you for the informative answer! It really helps me a lot!
from gdb-dashboard.
Does the commands in this wiki page work? They need to be executed within GDB.
Also what's the output of the following?
gdb --batch -ex 'python import sys; print(sys.version)'
from gdb-dashboard.
Hi @cyrus-and,
Here is the output:
(.venv) myname@debian12:~/learn/learn-gdb$ gdb --batch -ex 'python import sys; print(sys.version)'
3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
I tried the commands in this wiki page and error ModuleNotFoundError: No module named 'pygments'
occurs:
To make sure that I didn't forget to install pygments, I created a test.py file:
from pygments.styles import *
for style in get_all_styles():
print(style)
It runs successfully:
(.venv) myname@debian12:~/learn/learn-gdb$ which python3
/home/myname/.venv/bin/python3
(.venv) myname@debian12:~/learn/learn-gdb$ python3 test.py
abap
algol
algol_nu
arduino
autumn
bw
borland
colorful
default
dracula
emacs
friendly_grayscale
friendly
fruity
github-dark
gruvbox-dark
gruvbox-light
igor
inkpot
lightbulb
lilypond
lovelace
manni
material
monokai
murphy
native
nord-darker
nord
one-dark
paraiso-dark
paraiso-light
pastie
perldoc
rainbow_dash
rrt
sas
solarized-dark
solarized-light
staroffice
stata-dark
stata-light
tango
trac
vim
vs
xcode
zenburn
(.venv) myname@debian12:~/learn/learn-gdb$
from gdb-dashboard.
In a nutshell, Pygments must be available for the version of Python that runs inside GDB (in your case 3.11.2).
from gdb-dashboard.
Hi @cyrus-and,
Thank you so much! I was not familiar with Python integration in GDB and now I see where the problem is.
I didn't install Pygments system-wide, because the reason listed here.
In the Quickstart section of README.md of gdb-dashboard, it says we can install Pygments by pip install pygments
, but I did some search and found this. It says that the Python interpreter that GDB uses is linked into GDB, in the form of libpython3.4.a
or libpython3.4.so
, etc.
I'm very confused. Even if I run pip install pygments
system-wide, that would only install pygments in to the system Python, instead of the Python that runs inside GDB. How could I let Pygments be available for the Python that runs inside GDB?
Is there anything wrong with my understanding? I really appreciate it if you can correct me.
By the way, Python version in my system and in the venv are also 3.11.2:
myname@debian12:~/learn/learn-gdb$ which python3
/usr/bin/python3
myname@debian12:~/learn/learn-gdb$ python3
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
myname@debian12:~/learn/learn-gdb$ source ~/.venv/bin/activate
(.venv) myname@debian12:~/learn/learn-gdb$ which python3
/home/myname/.venv/bin/python3
(.venv) myname@debian12:~/learn/learn-gdb$ python3
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
(.venv) myname@debian12:~/learn/learn-gdb$
from gdb-dashboard.
OK so, the question is then, how to use Pygments in Python GDB using venv
? What I said holds for packages installed systemwide. And in fact, installing Pygments systemwide will fix your issue.
But if you want to use venv
, you just need to tell the GDB Python that you want to use that instead, apparently all you have to do is to add the venv
path to the sys.path
inside Python GDB, that is, in my case:
(.venv) user@cc547d5a0dfc:~$ python3 -c 'import sys; print(sys.path)'
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/user/.venv/lib/python3.10/site-packages']
So in GDB (this is the part that should be in your configuration file, something inside ~/.gdbinit.d/
, either a .py
file or a GDB file):
python import sys; sys.path += ['/home/user/.venv/lib/python3.10/site-packages']
After that, you should be able to import Pygments and all of that. Hope it helps!
from gdb-dashboard.
Feel free to post your exact solution so to help others, if you want.
from gdb-dashboard.
Related Issues (20)
- Don't know how to use gdb-dashboard HOT 3
- Color scheme for the bottom section HOT 1
- Disable gdb startup text HOT 5
- how to disable output / messages? or remove from source code? HOT 1
- doesn't work, when source the .gdb-dashboard HOT 1
- Clion GDB HOT 1
- armv8 registers cannot be displayed HOT 2
- Last command still fails on gdb 8.2-19.el8 on rocky 8 HOT 3
- Dashboard flickering due to unexpected disappear/re-appear of original one-line src code at the top
- How do you save the dashboard layout? HOT 3
- Not able to install HOT 22
- On gdb shell, print <var_nam> must wait for user to press enter for more and q for quit and c for continue to print till end. But not happening HOT 3
- [Enhancement] trace from born till death HOT 1
- Invalid escape sequence errors with new Python HOT 1
- Windows GDB is broken
- dashboard does not show up HOT 3
- Hardware Breakpoints (QEMU GDB) HOT 1
- Highlight HOT 1
- Incorrect display behaviour HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdb-dashboard.