0

New to docker/qemu/gdb.

I am able to "make debug" and "make gdb" and debug from CLI. However, I got an error (no executable specified) when I try to use VSCode debugger to attach to a running qemu target.

I am running a x86/64 machine and running within an ubuntu docker dev container.

Need help getting vscode to recognize that I am attaching to qemu target rather than running the elf on local machine, which seems to be the problem.

File build/arm-start.elf:

root@6d0880bb1ed3:/work/RapidPatch/VulDevices/qemu-stm32-p103/build# file ./arm-start.elf 
./arm-start.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

Launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "useExtendedRemote": true,
            "name": "Attach to QEMU (GDB Remote)",
            "type": "cppdbg",
            "request": "attach",
            "MIMode": "gdb",
            "miDebuggerServerAddress": "localhost:1234",
            "miDebuggerPath": "${workspaceFolder}/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gdb",
            "program": "${workspaceFolder}/RapidPatch/VulDevices/qemu-stm32-p103/build/arm-start.elf"
        }
    ]
}

1 Answer 1

0

You don't have cwd (Current working directory) and exact program location, please refer to the modification below:

{
    "version": "0.2.0",
    "configurations": [
        {
            "useExtendedRemote": true,
            "name": "Attach to QEMU (GDB Remote)",
            "type": "cppdbg",
            "request": "attach",
            "MIMode": "gdb",
            "miDebuggerServerAddress": "localhost:1234",
            "miDebuggerPath": "${workspaceFolder}/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gdb",
            "program": "${workspaceFolder}/RapidPatch/VulDevices/qemu-stm32-p103/build/arm-start.elf",
            "cwd":"/home/<path to your current working directory>",  // Host machine not container
            "program": "/home/<path to your current working directory>/a.out", // Host machine not container, the exe/out file path

        }
    ]
}

Note: I am taking /home just as a reference to depict, you need to mention the exact path.

Further please check the logs of docker container, you need to install both gdb and gdb server

sudo apt-get install gdbserver && sudo apt-get install gdb

Also make sure you are exposing the same port in dockerfile and the container has same Ubuntu version running, for me when I was having different version of Ubuntu in my PC and docker container, there was error in connecting.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.