Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352493

Summary: [tracepoint] Trace control buttons are disabled after a start trace failure
Product: [Tools] CDT Reporter: Marc Khouzam <marc.khouzam>
Component: cdt-debug-dsf-gdbAssignee: Marc Khouzam <marc.khouzam>
Status: RESOLVED FIXED QA Contact: Marc Khouzam <marc.khouzam>
Severity: normal    
Priority: P3 CC: cdtdoug, nobody, pawel.1.piech
Version: 8.0Flags: nobody: review+
Target Milestone: 8.0.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Fix marc.khouzam: iplog-

Description Marc Khouzam CLA 2011-07-19 13:26:31 EDT
When pressing the start tracing button in the TraceControl view, it is possible that GDB will reject the request.  In that case, the buttons are not properly refreshed and their enablement is wrong.

For example, if I try to start tracing but I didn't create tracepoints:

398,325 [MI]  93-trace-start
398,326 [MI]  93^error,msg="No tracepoints defined, not starting trace"

We need to be prepared for such a failure.
Comment 1 CDT Genie CLA 2011-07-19 14:19:40 EDT
*** cdt git genie on behalf of 352493 ***

    Bug 352493:Trace control buttons are disabled after a start trace
    failure

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=163a57b8b7ea789cbec84e578c9992243579767a
Comment 2 CDT Genie CLA 2011-07-19 14:19:42 EDT
*** cdt git genie on behalf of 352493 ***

    Bug 352493:Trace control buttons are disabled after a start trace
    failure

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=cbffe1484b064cb5b971ed0a3887f6c4b5f0be82
Comment 3 Marc Khouzam CLA 2011-07-19 14:56:32 EDT
Created attachment 199936 [details]
Fix

When getting an ^error after a -trace-start, we now trigger an event to refresh the button to the current state of tracing.

Committed to master and 8_0
Comment 4 Marc Khouzam CLA 2011-07-19 14:57:05 EDT
Fixed.
Mikhail, can you review?
Comment 5 Nobody - feel free to take it CLA 2011-07-19 15:27:27 EDT
(In reply to comment #4)
> Fixed.
> Mikhail, can you review?

I'll try. What do I need to use tracepoints? Can you point me to a wiki page is there is one?
Comment 6 Marc Khouzam CLA 2011-07-19 15:30:54 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > Fixed.
> > Mikhail, can you review?
> 
> I'll try. What do I need to use tracepoints? Can you point me to a wiki page is
> there is one?

There is an outdated wiki page at http://wiki.eclipse.org/CDT/designs/Tracepoints but it does not contain everything and some things have not been implemented.

I've been meaning to write a new FAQ section for Tracepoints.  I'll try to do it this week and let you know when it is available.
Comment 7 Marc Khouzam CLA 2011-07-20 08:28:35 EDT
(In reply to comment #6)

> I've been meaning to write a new FAQ section for Tracepoints.  I'll try to do
> it this week and let you know when it is available.

That was the motivation I needed:

http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_trace_my_application_using_C.2FC.2B.2B_Tracepoints.3F

I hope it is clear enough.  Please let me know, as a user, if you find something confusing.
Comment 8 Nobody - feel free to take it CLA 2011-07-22 15:51:52 EDT
Marc,
It seems that I'm doing everything according to your instructions, but the actions in the trace control are always disabled. The reason is the "trace-status" command always returns "supported=0". I am using gdb 7.2, is there anything else I should do to make tracing available?
Comment 9 Marc Khouzam CLA 2011-07-22 15:54:15 EDT
(In reply to comment #8)
> Marc,
> It seems that I'm doing everything according to your instructions, but the
> actions in the trace control are always disabled. The reason is the
> "trace-status" command always returns "supported=0". I am using gdb 7.2, is
> there anything else I should do to make tracing available?

Thanks for trying Mikhail.

Did you run a remote session using gdbserver?  Tracing is not supported in GDB with a local session.
Comment 10 Nobody - feel free to take it CLA 2011-07-22 15:57:05 EDT
(In reply to comment #9)
> Did you run a remote session using gdbserver?  Tracing is not supported in GDB
> with a local session.

Yes, I'm using Remote Launcher with RSE. I can set tracepoints, but can not start tracing.
Comment 11 Marc Khouzam CLA 2011-07-22 16:01:46 EDT
(In reply to comment #10)
> (In reply to comment #9)
> > Did you run a remote session using gdbserver?  Tracing is not supported in GDB
> > with a local session.
> 
> Yes, I'm using Remote Launcher with RSE. I can set tracepoints, but can not
> start tracing.

Are you running on linux?  Windows won't work.  If you get "supported=0" it is GDB that can't trace.

Try running just GDB like this:

> gdbserver.7.2 :9999 a.out

> gdb.7.2 a.out
[...]
(gdb) target remote :9999
Remote debugging using :9999
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
0x00686850 in ?? () from /lib/ld-linux.so.2
Created trace state variable $trace_timestamp for target's variable 1.
(gdb) interpreter-exec mi "-trace-status"
^done,supported="1",running="0",frames="0",frames-created="0",buffer-size="5242880",buffer-free="5242880",disconnected="0",circular="0"

I get "supported=1"
Comment 12 Nobody - feel free to take it CLA 2011-07-22 16:10:34 EDT
Thanks Marc. I didn't set the right path and it was starting an old version of gdbserver. It is working now.
Comment 13 Nobody - feel free to take it CLA 2011-07-22 17:10:32 EDT
Marc, your fix works fine for this particular issue, but I have a couple of questions.
1.Wouldn't it be better to disable "Start Tracing" when there is no tracepoints set?
2."Start Tracing" remains enabled when the trace is running. Is it intentional?

I also found an unrelated bug - most of the Debug view actions (Resume, Step, etc.) remain disabled when switching from "visualization" mode back to "debug" mode. Seems the Debug view needs to be refreshed, selecting anything in it enables the actions. Just want to check with before creating a bugzilla for it.
Comment 14 Marc Khouzam CLA 2011-07-25 08:09:42 EDT
(In reply to comment #13)
> Marc, your fix works fine for this particular issue, but I have a couple of
> questions.

I'm glad you got it working.  It is nice that at least two of us can set it up :-)

> 1.Wouldn't it be better to disable "Start Tracing" when there is no tracepoints
> set?

I never thought about it before.  It is a good idea but I wonder how valuable it will be.  If there is any tracepoint defined in the workspace, even for another project/target, that tracepoint will be marked as pending for the current debug session, and "Start tracing" will need to be enabled.

So, the only time we could turn off "Start tracing" is if there are no tracepoints defined in the workspace.

If you find it is something a user would expect, then we can do that.  Can we make that a new bug?

> 2."Start Tracing" remains enabled when the trace is running. Is it intentional?

If you change/add/delete a tracepoint, it does not affect the running trace experiment.  To get those changes to apply, one needs to restart the tracing experiment.  You can do that without stopping the experiment, that is why "start tracing" stays enabled.  Note that you will loose any collected data when you do that.

> I also found an unrelated bug - most of the Debug view actions (Resume, Step,
> etc.) remain disabled when switching from "visualization" mode back to "debug"
> mode. Seems the Debug view needs to be refreshed, selecting anything in it
> enables the actions. Just want to check with before creating a bugzilla for it.

I have added a fix for that in Bug 347514, which I should be committing soon, I hope.

If you have any more suggestions for usability of C/C++ Tracpoints, please don't hesitate.
Comment 15 Nobody - feel free to take it CLA 2011-07-25 09:41:34 EDT
(In reply to comment #14)
> > 1.Wouldn't it be better to disable "Start Tracing" when there is no tracepoints
> > set?
> 
> I never thought about it before.  It is a good idea but I wonder how valuable
> it will be.  If there is any tracepoint defined in the workspace, even for
> another project/target, that tracepoint will be marked as pending for the
> current debug session, and "Start tracing" will need to be enabled.
> 
> So, the only time we could turn off "Start tracing" is if there are no
> tracepoints defined in the workspace.
> 
> If you find it is something a user would expect, then we can do that.  Can we
> make that a new bug?
>

I forgot about it. In this case my suggestion would make things more confusing. Let keep it as it is now and wait for feedback from real users.