For some reason cuda-gdb from cuda sdk gives on my machine list of errors like
Traceback (most recent call last):
so I decided rebuild it with python version installed in system - and this turned out to be a difficult task
File "/usr/share/gdb/python/gdb/__init__.py", line 169, in _auto_load_packages
__import__(modname)
File "/usr/share/gdb/python/gdb/command/explore.py", line 746, in <module>
Explorer.init_env()
File "/usr/share/gdb/python/gdb/command/explore.py", line 135, in init_env
gdb.TYPE_CODE_RVALUE_REF : ReferenceExplorer,
AttributeError: 'module' object has no attribute 'TYPE_CODE_RVALUE_REF'
The first question is where the source code? Seems that official repository does not contain cuda specific code - so raison d'être of these repo is totally unclear. I extracted from cuda sdk .deb archive cuda-gdb-13.1.68.src.tar.gz and proceed with it
Second - process of configuring is extremely fragile - if you point single wrong option you will know about it only after 30-40 min. Also it seems that you just can't run configure in sub-dirs, bcs in that case linker will claims about tons of missed symbols. So configuration found by trial and errorconfigure --with-python=/usr/bin/python3 --enable-cuda
And finally we got file gdb/gdb having size 190 Mb. And after running I got stack trace beginning witharch-utils.c:1374: internal-error: gdbarch: Attempt to register unknown architecture (2)
This all raises some questions for nvidia:
- do they testing their cuda sdk before releasing?
- do they have QA at all or like microsoft just test their ai shit directly on users?
- from which sources was built original cuda-gdb in fact?
Well, at least having some suspicious source code we can fix this build
Let's see at function gdbarch_register in arch-utils.c - it just call bfd_lookup_arch with value 2 for bfd_architecture
Function bfd_lookup_arch located in file bfd/archures.c and from enum bfd_architecture we can realize that 2 correspond to bfd_arch_m68k. What the hell Motorola m68k needed for cuda debugger?
Some grepping gives the answer in file cuda/cuda-tdep.c:
void
_initialize_cuda_tdep ()
{
gdbarch_register (bfd_arch_m68k, cuda_gdbarch_init); nvidia is too lazy to add their own arch and they just rewriting the existing one m68k. Btw Motorola still haven't sued them?
So we can fix this just by adding m64 into bfd/archures.c like:static const bfd_arch_info_type * const bfd_archures_list[] =
{
#ifdef SELECT_ARCHITECTURES
#ifdef NVIDIA_CUDA_GDB
&bfd_m68k_arch,
#endif
SELECT_ARCHITECTURES,
#else
Also let's check what value has SELECT_ARCHITECTURES in bfd/Makefile:
-DSELECT_ARCHITECTURES='&bfd_i386_arch,&bfd_iamcu_arch'
Wonderful, they forgot to add dependency from m68k in their configuration patch. However we also need to add support for m68k too, so I just find all places in bfd/Makefile where cpu-iamcu was used and add cpu-m68k.lo - see patched Makefile
And finally I got new binary:
gdb/gdb --version
NVIDIA (R) cuda-gdb 13.1
Portions Copyright (C) 2007-2025 NVIDIA Corporation
Based on GNU gdb 14.2
Комментариев нет:
Отправить комментарий