NVIDIA / nsight-vscode-edition

A Visual Studio Code extension for building and debugging CUDA applications.
Other
68 stars 11 forks source link

CUDA-GDB Pretty Print STL containers #9

Open bcaddy opened 2 years ago

bcaddy commented 2 years ago

With GDB and VS Code I can see the contents of STL containers fairly easily by setting up some setupCommands in my launch.json file. However with cuda-gdb those setup commands aren't doing anything and the STL containers contents are completely unreadable. How can I fix this?

steveulrich403 commented 1 year ago

Thanks for the bug report. We have some known issues with Python integration into CUDA GDB, and this issue might be related to that problem. Are you able to provide the precise setupCommands that you add to your launch.json file, so we can try to reproduce your results?

bcaddy commented 1 year ago

Here's my launch.json file. Honestly though, it's been over a year since I opened this and since then I've just switched to ARM DDT

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Cholla",
            "type": "cuda-gdb",
            "request": "launch",
            "program": "${workspaceFolder}/bin/cholla.mhd.c3po",
            "args": "${workspaceFolder}/examples/3D/constant.txt",
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "setupCommands": [
                {
                    "description": "Make STL containers readable",
                    "text": "python import sys; sys.path.insert(0, '/home/rcaddy/.gdb-stl-printing'); from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)",
                    "ignoreFailures": false
                },
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
sanannavyaa commented 1 year ago

Hi, we currently do not support "setup commands". In Nsight VS Code Edition, we use initCommands to list cuda-gdb commands sent before starting inferior. Hope using initCommands helps out!

qinggengaoshen commented 1 year ago

Hi, we currently do not support "setup commands". In Nsight VS Code Edition, we use initCommands to list cuda-gdb commands sent before starting inferior. Hope using initCommands helps out!

Hi,could you tell me how to make STL readable by editing initCommand?Much thanks.

sanannavyaa commented 1 year ago

Hi, for your python commands, you should be able to copy those into your .cuda-gdbinit file and they would work and as for the gdb command, you can add "initCommands": ["-enable-pretty-printing"] to your launch.json. Here is a sample launch.json with initCommands set:

{
    "configurations": [
        {
            "name": "CUDA C++: Launch",
            "type": "cuda-gdb",
            "request": "launch",
            "program": "${workspaceFolder}/matrixMul",
            "cwd": "${workspaceFolder}", 
            "initCommands": ["-enable-pretty-printing"],
            "logFile": "${workspaceFolder}/log.txt"
        }
    ]
}
qinggengaoshen commented 1 year ago

Hi, for your python commands, you should be able to copy those into your .cuda-gdbinit file and they would work and as for the gdb command, you can add "initCommands": ["-enable-pretty-printing"] to your launch.json. Here is a sample launch.json with initCommands set:

{
    "configurations": [
        {
            "name": "CUDA C++: Launch",
            "type": "cuda-gdb",
            "request": "launch",
            "program": "${workspaceFolder}/matrixMul",
            "cwd": "${workspaceFolder}", 
            "initCommands": ["-enable-pretty-printing"],
            "logFile": "${workspaceFolder}/log.txt"
        }
    ]
}

Well, when I write some python commands, It notes"Python scripting is not supported(libpython could not be found)"in cuda-gdb.How could I fix it?

qinggengaoshen commented 1 year ago

Hi, for your python commands, you should be able to copy those into your .cuda-gdbinit file and they would work and as for the gdb command, you can add "initCommands": ["-enable-pretty-printing"] to your launch.json. Here is a sample launch.json with initCommands set:

{
    "configurations": [
        {
            "name": "CUDA C++: Launch",
            "type": "cuda-gdb",
            "request": "launch",
            "program": "${workspaceFolder}/matrixMul",
            "cwd": "${workspaceFolder}", 
            "initCommands": ["-enable-pretty-printing"],
            "logFile": "${workspaceFolder}/log.txt"
        }
    ]
}

In .cuda-gdbinit,I write these:

set auto-load safe-path / python sys.path.insert(0, 'home/tyy/GLU_public-master/src/python') # python目录 from libstdcxx.v6.printers import register_libstdcxx_printers register_libstdcxx_printers (None) end

But I run those commands in gdb,It runs perfectly.

sanannavyaa commented 1 year ago

What version of python do you have installed? (the result of doing python3 --version). You also need to have the python-dev package installed