Open jimklo opened 1 year ago
The error is comming from GDB.
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Couldn't get registers: Input/output error.
This may be an issue with devcontainers or how GDB works within them. You can file a bug on GDB at https://sourceware.org/bugzilla/
When I tried to run gdb
inside of the container (which is built on x86_64), I got the same error Couldn't write debug register: Input/output error.
Not a GDB bug...but GDB does get a little confused in this case since rosetta
is involved.
I was able to get it working inside a container by following this excellent blog post: https://sporks.space/2023/04/12/debugging-an-x86-application-in-rosetta-for-linux/
ROSETTA_DEBUGSERVER_PORT=1234 node app.js &
gdb
(gdb) set architecture i386:x86-64
(gdb) file /usr/bin/node
(gdb) target remote localhost:1234
(gdb) continue
I am sure there's a way to convert the above to a VSCode launch configuration (exercise left to the reader). I am using macOS M2, Ventura 13.4, stock ubuntu:20.04
container --platform=linux/amd64
via colima v0.5.5 w/ Virtualization.Framework & rosetta enabled. Hope this helps!
Not a GDB bug...but GDB does get a little confused in this case since
rosetta
is involved.I was able to get it working inside a container by following this excellent blog post: https://sporks.space/2023/04/12/debugging-an-x86-application-in-rosetta-for-linux/
ROSETTA_DEBUGSERVER_PORT=1234 node app.js & gdb (gdb) set architecture i386:x86-64 (gdb) file /usr/bin/node (gdb) target remote localhost:1234 (gdb) continue
I am sure there's a way to convert the above to a VSCode launch configuration (exercise left to the reader). I am using macOS M2, Ventura 13.4, stock
ubuntu:20.04
container--platform=linux/amd64
via colima v0.5.5 w/ Virtualization.Framework & rosetta enabled. Hope this helps!
Nice workaround. But I'm still struggling debbugging my cpp. I replaced your command with my-binary
instead of /usr/bin/node
. Apparently GDB loads all the symbols correctly but then I receive a segmentation fault when running continue
.
Still not sure where the problem is, since running my executable without gdb I don't have seg faults.
Same configuration: M2, macOS 13.4, colima 0.5.5
A segfault under gdb doesn't sound like OP's issue. We were simply seeing the error Couldn't write debug register: Input/output error.
from gdb and the workaround above gets past that error.
If it's crashing for you it could be a different issue. I'd say make sure you are starting Colima with colima start --arch aarch64 --vm-type=vz --vz-rosetta
(otherwise it uses qemu by default).
Hi @KOConchobhair,
yes, I'm investigating and apparently the segfault comes from some multithreaded libraries messing around in our code. Still don't now if this issue comes for rosetta emulation or not, but definitely not a gdb issue. Actually your workaround works: I'm able to perform gdb commands such as printing frames and break the code where I want.
Thank you very much!
P.s.: for reference your link doesn't not work anymore, here the archived version https://web.archive.org/web/20230419045554/https://sporks.space/2023/04/12/debugging-an-x86-application-in-rosetta-for-linux/
Not a GDB bug...but GDB does get a little confused in this case since
rosetta
is involved.I was able to get it working inside a container by following this excellent blog post: https://sporks.space/2023/04/12/debugging-an-x86-application-in-rosetta-for-linux/
ROSETTA_DEBUGSERVER_PORT=1234 node app.js & gdb (gdb) set architecture i386:x86-64 (gdb) file /usr/bin/node (gdb) target remote localhost:1234 (gdb) continue
I am sure there's a way to convert the above to a VSCode launch configuration (exercise left to the reader). I am using macOS M2, Ventura 13.4, stock
ubuntu:20.04
container--platform=linux/amd64
via colima v0.5.5 w/ Virtualization.Framework & rosetta enabled. Hope this helps!
I tried this in Visual Studio Code, but I couldn't find a suitable way to convert these instructions to Microsoft's C++ extension. After some effort, I discovered an extension that could address this issue.
Start by installing the "Native Debug" extension.
Next, add a configuration in your launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Attach to gdbserver",
"executable": "./your/executable/path", //relative to your workspace
"target": "localhost:1234",
"remote": true,
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText"
}
]
}
Now, execute your program in the terminal:
ROSETTA_DEBUGSERVER_PORT=1234 ./your/executable/path
Finally, attach to the program through Visual Studio Code:
Now, you're all set to debug your program.
Not a GDB bug...but GDB does get a little confused in this case since
rosetta
is involved. I was able to get it working inside a container by following this excellent blog post: https://sporks.space/2023/04/12/debugging-an-x86-application-in-rosetta-for-linux/ROSETTA_DEBUGSERVER_PORT=1234 node app.js & gdb (gdb) set architecture i386:x86-64 (gdb) file /usr/bin/node (gdb) target remote localhost:1234 (gdb) continue
I am sure there's a way to convert the above to a VSCode launch configuration (exercise left to the reader). I am using macOS M2, Ventura 13.4, stock
ubuntu:20.04
container--platform=linux/amd64
via colima v0.5.5 w/ Virtualization.Framework & rosetta enabled. Hope this helps!Nice workaround. But I'm still struggling debbugging my cpp. I replaced your command with
my-binary
instead of/usr/bin/node
. Apparently GDB loads all the symbols correctly but then I receive a segmentation fault when runningcontinue
. Still not sure where the problem is, since running my executable without gdb I don't have seg faults.Same configuration: M2, macOS 13.4, colima 0.5.5
idk what is wrong with my setup, this does not work for me, I am running a centos(x86) docker image with docker desktop on M3 pro, it still gives me
Couldn't get registers: Input/output error. Couldn't get registers: Input/output error.
Can u pls help?
Not a GDB bug...but GDB does get a little confused in this case since
rosetta
is involved. I was able to get it working inside a container by following this excellent blog post: https://sporks.space/2023/04/12/debugging-an-x86-application-in-rosetta-for-linux/ROSETTA_DEBUGSERVER_PORT=1234 node app.js & gdb (gdb) set architecture i386:x86-64 (gdb) file /usr/bin/node (gdb) target remote localhost:1234 (gdb) continue
I am sure there's a way to convert the above to a VSCode launch configuration (exercise left to the reader). I am using macOS M2, Ventura 13.4, stock
ubuntu:20.04
container--platform=linux/amd64
via colima v0.5.5 w/ Virtualization.Framework & rosetta enabled. Hope this helps!Nice workaround. But I'm still struggling debbugging my cpp. I replaced your command with
my-binary
instead of/usr/bin/node
. Apparently GDB loads all the symbols correctly but then I receive a segmentation fault when runningcontinue
. Still not sure where the problem is, since running my executable without gdb I don't have seg faults. Same configuration: M2, macOS 13.4, colima 0.5.5idk what is wrong with my setup, this does not work for me, I am running a centos(x86) docker image with docker desktop on M3 pro, it still gives me
Couldn't get registers: Input/output error. Couldn't get registers: Input/output error.
Can u pls help?
Hi, have you tried the setup I posted? I think it might be helpful.
Environment
OS and version: MacOS Ventura, 13.3 (22E252)
VS Code:
Version: 1.77.1 (Universal) Commit: b7886d7461186a5eac768481578c1d7ca80e2d21 Date: 2023-04-04T23:23:33.779Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Darwin arm64 22.4.0 Sandboxed: No
C/C++ extension: C++ v1.14.5
OS and version of remote machine (if applicable): Using devcontainer: mcr.microsoft.com/devcontainers/cpp:0-ubuntu-22.04 Build and running as platform linux/amd64
GDB / LLDB version: GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1 lldb version 14.0.0
Bug Summary and Steps to Reproduce
Attaching sample workspace: sample-cpp.zip
Steps:
Debugger Configurations
tasks.json
Terminal