Tracepoint does not work in gdb and shows that "Trace can only be run on remote objects"

I want to use trace points to debug a program on a local computer, where I have full access. I can set the trace and its bandwidth, and using info tr gives me

(gdb) info tr

Num Enb Address PassC StepC What

1 y 0x080b7529 2 0 in search_tcp on tcp_pkt.c: 412

Actions for trace point 1: collect thread end

Then I run the program, it works as usual, and in the end, when I give tfind or tdump to collect the necessary data, it shows:

(gdb) tfind 1

Tracing can only be performed on remote objects.

(gdb) tdump

Tracing can only be performed on remote objects.

Even I tried using "tstart", but it again shows "Tracing can only be performed on remote objects."

Any idea what this message means? Tracing not currently supported? OR is it for debugging a remote machine on a local network or some other network? Any help would be greatly appreciated.

thanks vikas

+4
source share
1 answer

Any idea what this message means?

The meaning is exactly what the message says: the tracer is implemented only in gdbserver , and not in GDB itself, so you cannot use tstart when debugging initially (when GDB controls the bottom one (is debugged) directly).

Instead, you need to set up a remote debugging session (which can still be done on the same machine):

 gdbserver :10000 ./a.out # start gdbserver listening on port 10000 

In another window:

 gdb -ex 'target remote :10000' ./a.out 

Now you will have GDB with the remote target (which is located on gdbserver on the same host), and tstart , etc. will work.

Update:

But now I see the following messages:
(gdb) tstart
Target does not support this command.
(gdb) r
The "remote" target does not support "run".

Before you can use tstart , you need to set up the trace and actions as described here .

And you cannot run , because the lower process is already running. Use continue instead.

Update 2:

 (gdb) trace testprog.c:273 Tracepoint 1 at 0x4578f7: file testprog.c, line 273. (gdb) passcount 2 1 Setting tracepoint 1 passcount to 2 (gdb) actions 1 Enter actions for tracepoint 1, one per line. End with a line saying just "end". > collect id1 > end (gdb) tstart Target does not support this command 

It looks like your gdbserver old and does not actually support tracing.

What to do

 gdb --version gdbserver --version 

produce?

Update 3:

Apparently your gdbserver too old.

Although GDB itself supported trace points from version 4.17, gdbserver only just begun to support trace points with version 7.2

Update 4:

where to specify this option "-f filename", which my program accepts as input

Simple You can read the documentation for gdbserver, but I believe you are looking for this call:

 gdbserver :10000 ./a.out -f filename 
+11
source

Source: https://habr.com/ru/post/1394176/


All Articles