Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339456 - [event] Thread created event with wrong id after restart for GDB < 7.0
Summary: [event] Thread created event with wrong id after restart for GDB < 7.0
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on: 313372
Blocks:
  Show dependency tree
 
Reported: 2011-03-09 21:29 EST by Marc Khouzam CLA
Modified: 2011-05-13 11:23 EDT (History)
2 users (show)

See Also:
marc.khouzam: review? (john.cortell)


Attachments
Proposed fix (1.53 KB, patch)
2011-05-08 22:27 EDT, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff
More generic fix (3.72 KB, patch)
2011-05-13 11:01 EDT, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Khouzam CLA 2011-03-09 21:29:46 EST
+++ This bug was initially created as a clone of Bug #313372 +++

I know that the commit of Bug 237308 broke the fix to Bug 313372.  However, this can be resolved after API freeze, while Bug 237308 could not, which is why I felt it was acceptable.
Comment 1 Marc Khouzam CLA 2011-05-08 22:27:12 EDT
Created attachment 195032 [details]
Proposed fix

This bug only happens for GDB < 7.0 since it is for those versions that we need to keep our own thread counter.

This patch makes use of the printout

  [Thread debugging using libthread_db enabled]

which seems to happen only when the program starts or restarts.  In that case, we reset the thread counter.

This fix works well on Linux but I'm not sure about Windows.

I'll commit it as it is an improvement from the current situation, but I'll try to verify it for Windows.
Comment 2 CDT Genie CLA 2011-05-08 23:23:05 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 339456: Thread created event with wrong id after restart for GDB &lt; 7.0

[*] CLIEventProcessor.java 1.9 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java?root=Tools_Project&r1=1.8&r2=1.9
Comment 3 CDT Genie CLA 2011-05-09 15:23:06 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 339456: Thread created event with wrong id after restart for GDB &lt; 7.0

[*] GDBControl.java 1.30 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java?root=Tools_Project&r1=1.29&r2=1.30
Comment 4 Marc Khouzam CLA 2011-05-12 06:40:36 EDT
(In reply to comment #1)
> This patch makes use of the printout
> 
>   [Thread debugging using libthread_db enabled]
>
> I'll commit it as it is an improvement from the current situation, but I'll try
> to verify it for Windows.

There is no such printout on Windows, so this fix does not work there.  The output looks like:

624,853 [MI]  15-break-insert -t -f main
624,871 [MI]  15^done,bkpt={number="4",type="breakpoint",disp="del",enabled="y",addr="0x00401399",fu\
nc="main",file="..\\src\\TestDSFGDB.cpp",fullname="C:\\Users\\Marc\\runtime-DSFGDB\\TestDSFGDB\\Debu\
g/..\\src\\TestDSFGDB.cpp",line="193",times="0"}
624,872 [MI]  (gdb) 
624,875 [MI]  16-exec-run
624,883 [MI]  16^running
624,884 [MI]  (gdb) 
624,921 [MI]  ~"[New thread 2424.0x1f94]\n"
624,948 [MI]  &"Error: dll starting at 0x76e20000 not found.\n"
624,950 [MI]  &"Error: dll starting at 0x76390000 not found.\n"
624,954 [MI]  &"Error: dll starting at 0x76e20000 not found.\n"
624,956 [MI]  &"Error: dll starting at 0x76f40000 not found.\n"
625,026 [MI]  16*stopped,thread-id="1",frame={addr="0x00401399",func="main",args=[],file="..\\src\\T\
estDSFGDB.cpp",fullname="C:\\Users\\Marc\\runtime-DSFGDB\\TestDSFGDB\\Debug/..\\src\\TestDSFGDB.cpp"\
,line="193"}

I'll have to come up with something else, that is not based on GDB output.
Comment 5 Marc Khouzam CLA 2011-05-12 08:02:38 EDT
A better solution for both Linux and Windows is probably to listen for IStartedEvent for a container, which indicates the start/restart of a process.

Since this change is for GDB < 7.0, we don't have to worry about multi-process, so this solution should work.
Comment 6 Marc Khouzam CLA 2011-05-13 11:01:05 EDT
Created attachment 195598 [details]
More generic fix

I should have doe this from the start.

This fix simply listens for an IStartedDMEvent for a container which indicates a start/restart, and resets the thread counter.

Committed to HEAD.
Comment 7 Marc Khouzam CLA 2011-05-13 11:01:25 EDT
John, can you review?
Comment 8 CDT Genie CLA 2011-05-13 11:23:07 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 339456: Thread created event with wrong id after restart for GDB &lt; 7.0

[*] CLIEventProcessor.java 1.10 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java?root=Tools_Project&r1=1.9&r2=1.10