GDB fails with "Unable to find Mach task port for process-id 23330: (os/kern) failure " error - gdb

I installed GDB 12.1 on my mac OS Monterey 12.4. However, when I type start after typing gdb main, it shows
Unable to find Mach task port for process-id 23330: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
What should I do for using gdb?

Related

GDB remote debugging fails with error E01

I use this (http://cs.baylor.edu/~donahoo/tools/gdb/tutorial.html) guide to learn how GDB works.
After compiling and uploading the code to my embedded linux arm platform I use a remote connection to connect with the gdbserver on my target:
Target:
root#zedboard-zynq7:/Software# gdbserver HOST:1234 broken
Process broken created; pid = 1103
Listening on port 1234
Remote debugging from host 192.168.178.32
Host (Ubuntu 14.04 running in a virtual machine):
Remote debugging using 192.168.178.33:1234
warning: A handler for the OS ABI "GNU/Linux" is not built into this
configuration of GDB. Attempting to continue with the default arm settings.
Cannot access memory at address 0x0
0x43330d40 in ?? ()
(gdb)
I set the breakpoint to line 43 and continue the program until it stops at the breakpoint:
(gdb) b 43
Breakpoint 1 at 0x8b68: file broken.cpp, line 43.
(gdb) continue
Continuing.
Breakpoint 1, main () at broken.cpp:43
43 double seriesValue = ComputeSeriesValue(x, n);
(gdb)
But after a step call on my host I got this error:
Host:
warning: Remote failure reply: E01
Ignoring packet error, continuing...
Target:
ptrace: Input/output error.
input_interrupt, count = 1 c = 36 ('$')
What does it mean and how can I fix it?
Thanks for help.
Host (Ubuntu 14.04 running in a virtual machine):
Remote debugging using 192.168.178.33:1234
warning: A handler for the OS ABI "GNU/Linux" is not built into this
configuration of GDB. Attempting to continue with the default arm settings.`
This says that your (host) GDB has not been built with support for the target you want to debug.
What does it mean and how can I fix it?
You need to either get a different build of (host) GDB, or build one yourself with correct --target setting.
Usually a correct host GDB is included with the cross-gcc that you use to build for your target. So a fix may be as simple as running /path/to/cross-gdb instead of gdb.

Remote GDB disconnects whenever I press control + c

I am remote debugging a Stellaris Launchpad. I use OpenOCD to connect to the stellaris and then connect GDB to the server provided by openOCD. I use Open On-Chip Debugger 0.10.0-dev-00002-g79fdeb3 (2015-07-09-23:28). GDB is the one from arm-gcc-none-eabi, the 4_9-2015q1 release.
I invoke openOCD like this:
/usr/local/bin/openocd --file \
/usr/local/share/openocd/scripts/board/ek-lm4f120xl.cfg \
>> openocdLog.txt 2>&1 &
And then GDB like this:
arm-none-eabi-gdb proj//debug/exec -x gdb//gdb.script
gdb/gdb.script contains:
set remotetimeout 10000
target extended-remote :3333
monitor reset halt
load
monitor reset init
The problem is that whenever I hit control+c GDB disconnects. Normally this would halt the remote, but GDB just disconnects:
(gdb) cont
Continuing.
^CError detected on fd 6
Remote communication error. Target disconnected.: Interrupted system call.
(gdb)
OpenOCD has the following things to say, this one while GDB is launching:
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1258). Workaround: increase "set remotetimeout" in GDB
Which is weird, considering the gdb/gdb.script file forces remotetimeout to an insanly large number.
And when pressing control+c openOCD says:
Debug: 2602 5089 hla_interface.c:119 hl_interface_quit(): hl_interface_quit
So, how do I resolve this? How can I make GDB halt the remote instead of disconnecting when pressing control+c?
The problem was OpenOCD being too bleeding edge. I had issues with 0.6.1, but version 0.7.0 of OpenOCD works great.

Debugging with gdbserver using serial connection (Not TCP) doesn't work

I'm trying to debug a program on my board which runs an embedded linux and I have Ubuntu as host system. I have a big problem with gdbserver. You see the thing is that my board doesn't have an Ethernet interface but a serial device which I'm using for console and I noticed that you can use a serial device for debugging in gdbserver although I couldn't find an example of this considering everyone that used gdbserver in videos or books used it in TCP mode which I can't do that.
So What I did was simply running gdbserver on the board this way:
root#DM368# gdbserver /dev/ttyS0 hello
Process hello created; pid = 472
On the host side I'm using ddd program and I ran:
root#mosi-VirtualBox:~# ddd --debugger arm-linux-gdb
And in ddd window terminal I entered:
(gdb) cd /root/home/mySimpleHello/hello
(gdb) target remote /dev/ttyUSB0
(gdb) file hello
And /dev/ttyUSB0 is connected to the board's /dev/ttyS0
But I don't get anything back in gdb and there is nothing in gdbserver output which is kind of weird. I mean not a single message like a "host connected" or "remote debugging from ..." or things like that. And in ddd when I ran:
(gdb) b main
Breakpoint 1 at 0x83ac: file hello.c, line 10.
(gdb) run
Then gdb says:
the program in not being run
I tried with gdb on Ubuntu's terminal directly (whitout ddd) and the same thing happened. I even tried with eclipse and I setup a debugging profile in eclipse and I installed gdb-multiarch program and used that in eclipse with its .gdbinit file set to arm. Nothing happens and I have no idea why this simple procedure wouldn't work.
Does somebody have any idea? What am I doing wrong? How can I debug a program using a serial connection?

gdb connecting target by default

When debugging on remote target by using gdbserver, at client normally I do
$ gdb <enter>
(gdb) target remote <IP>:<PORT>
Is there an option for gdb that I can do this by giving gdb a proper argument?
Just something like: gdb -ex "target remote ..."

Eclipse: Error in final launch sequence Failed to execute MI command

When I try to debug the HelloWorld C++ application, I get the following error. The gdb specified in the debug configuration for HelloWorld looks correct. What's up?
Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Unable to find Mach task port for process-id 43655: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))
Unable to find Mach task port for process-id 43655: (os/kern) failure (0x5).\n (please check gdb is codesigned - see taskgated(8))