LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Can’t run ARM’s gdb (Python problem?) (https://www.linuxquestions.org/questions/slackware-14/can%92t-run-arm%92s-gdb-python-problem-4175724434/)

colinh2 04-25-2023 04:22 AM

Can’t run ARM’s gdb (Python problem?)
 
I didn’t find an SBo for a recent aarch64-binutils etc. so I’ve downloaded ARM’s precompiled utils for Aarch64 cross-development on Linux-x86_64.

Binutils and gcc run fine, but gdb exits immediately:

Code:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to …

sys.executable = ‘/usr/local/bld-tools/bld-virtual-env/bin/python’

sys.path = [
  ‘/usr/lib/python38.zip’,

I have Slackware 15.0 installed, so Python 3.9 is in /lib64.

Is there some way to convince gdb to use the installed Python? Setting $PYTHONHOME didn’t help.

teckk 04-25-2023 08:02 AM

https://www.gnu.org/software/gdb/

Quote:

I have Slackware 15.0 installed, so Python 3.9 is in /lib64.
Your python executable is in /libx64?
Code:

whereis python
You did not post much info. Do you have a working python install? What do you get from python entered into a terminal?

Looks like gdb depend on:
glibc ncurses libncursesw.so=6-64 gcc-libs expat xz mpfr
source-highlight gdb-common=xx readline libreadline.so=xx
guile python libelf

What is the entire error when trying to run gdb?

Quote:

so I’ve downloaded ARM’s precompiled utils for Aarch64 cross-development on Linux-x86_64.
You put ARM executables onto a x86_64 machine?

You need to give a lot more info. The basic fix for this is to use your pacakge manager to install software. So that all depends will be resolved. If gdb is not in your repo, then you may need to build it against your machines libraries, then install it with your package manager. It's not clear what you are doing though.

colinh2 04-25-2023 09:27 AM

Ah, sorry I was so unclear -- I didn't have internet access on my laptop, so I posted the question from my phone.

Quote:

You put ARM executables onto a x86_64 machine?
The GNU programs (e.g. aarch64-none-elf-as, aarch64-none-elf-gdb etc.) are for cross-development; they run on x86_64 but generate code for bare-metal Aarch64.

Quote:

Your python executable is in /libx64?
Oops. No. The executable is in /usr/bin. Python's libraries (or modules, whatever they're called) are in /usr/lib64/python3.9.

Quote:

What is the entire error when trying to run gdb?
Code:

$ aarch64-none-elf-gdb
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/local/bld-tools/bld-tools-virtual-env/bin/python'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f22b466ec00 (most recent call first):
<no Python frame>

I have a fresh install of Slackware 15.0. I then just removed the kde stuff (with 'slackpkg remove kde').

Quote:

The basic fix for this is to use your pacakge manager to install software. So that all depends will be resolved. If gdb is not in your repo, then you may need to build it against your machines libraries, then install it with your package manager.
Yes, I'd have preferred to install using sbopkg. SBo only contains:

arm-binutils 2.35
arm-gcc 10.2.0
arm-gdb 10.1.

(ie. older versions, generating code for arm32).

The Arm GNU toolchain (https://developer.arm.com/downloads/...hain-downloads) (12.2.Rel1 from 22.12.2022) has

aarch64-none-elf-as 2.39
aarch64-none-elf-gcc 12.2.1
aarch64-none-elf-gdb 12

I wanted to avoid building the entire GNU toolchain, as I seem to remember it being fairly involved.

I just read the Release Notes:

Quote:

These toolchains are built on
and for RHEL7 on x86_64, and
will likely also be useable on
OS versions:

- RHEL8
- Ubuntu 18.04 or later

...

Known Dependencies

GDB's Python support on Linux hosts requires installation of Python3.8, Python3.8-dev or libpython3.8.
I was hoping it would be something trivial. If it's not, I'll try compiling everything myself. Python 3.9 isn't good enough if it wants Python 3.8 ?

teckk 04-25-2023 10:02 AM

Couple of thoughts.

Can your machine find python and friends? Does python run from the terminal?
Code:

python
Python 3.x.x (main, apr xx 2023, 17:35:49) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import encodings
>>>

And all of your python matches?
Does python give you python 2 or 3? Slack still uses python2. Also, you have a valid python path specified? Is that where gdb is looking for it?
Code:

python --version
Code:

python -c "import sys; print('\n'.join(sys.path))"
You can append to your python path if you have something in a weird location.
Code:

>>> import sys
>>> print(sys.path)
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/usr/lib/python3.10/site-packages']
>>> sys.path.append('/home/fred/flintstone')
>>> print(sys.path)
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/usr/lib/python3.10/site-packages', '/home/fred/flintstone']

If all of that is correct. You may have mismatched stuff. The gdb that you have doesn't like the python depends that it is looking for.

colinh2 04-25-2023 10:07 AM

Thanks for the help, teckk.

I've just downloaded and installed python-3.8.16 (from python.org).

Now, aarch64-none-elf-gdb runs ok.

Seems excessive to have to have every version of python installed though...


All times are GMT -5. The time now is 09:41 AM.