This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA/Windows] Fix Ada task switching on Windows...
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 12 Mar 2009 13:44:13 -0700
- Subject: [RFA/Windows] Fix Ada task switching on Windows...
Hello,
Switching to a different Ada task triggers an internal-error on Windows.
Any program using tasking should allow us to reproduce the problem.
The fix is very simple, and just involves adding a target-specfic
routine.
Here is a transcript of a session where the problem occurs:
| (gdb) b break_me
| Breakpoint 1 at 0x401c27: file task_switch.adb, line 43.
| (gdb) run
| Starting program: c:\[...]/task_switch.exe
| [New Thread 484.0xb70]
| [New Thread 484.0x884]
| [New Thread 484.0x480]
| [Switching to Thread 484.0x480]
|
| Breakpoint 1, task_switch.break_me () at task_switch.adb:43
| 43 end Break_Me;
| (gdb) info tasks
| ID TID P-ID Pri State Name
| 1 3e4318 0 15 Child Activation Wait main_task
| 2 3e4b48 1 15 Accept Statement my_callee
| 3 3e7c60 1 15 Runnable my_caller
| (gdb) task 1
| /home/brobecke/act/gdb-public.cvs/gdb/thread.c:538: internal-error: is_thread_state: Assertion `tp' failed.
| A problem internal to GDB has been detected,
| further debugging may prove unreliable.
The first indication of a problem is the fact that none of the entries
in the "info tasks" listing is marked as the "current" task. The second
one is more obvious, since it's an internal error. After the patch is
applied, here is what the output looks like:
| (gdb) b break_me
| Breakpoint 1 at 0x401c27: file task_switch.adb, line 43.
| (gdb) run
| Starting program: c:\[...]/task_switch.exe
| [New Thread 1284.0xbd0]
| [New Thread 1284.0xfdc]
| [New Thread 1284.0xbe0]
| [Switching to Thread 1284.0xbe0]
|
| Breakpoint 1, task_switch.break_me () at task_switch.adb:43
| 43 end Break_Me;
| (gdb) info tasks
| ID TID P-ID Pri State Name
| 1 3e4330 0 15 Child Activation Wait main_task
| 2 3e4b60 1 15 Accept Statement my_callee
| * 3 3e7c78 1 15 Running my_caller
| (gdb) task 1
| [Switching to task 1]
| 0x7c90e4f4 in ntdll!LdrAccessResource () from C:\WINDOWS\system32\ntdll.dll
2009-03-12 Joel Brobecker <brobecker@adacore.com>
* windows-nat.c (+windows_get_ada_task_ptid): New function.
(init_windows_ops): Set windows_ops.to_get_ada_task_ptid.
OK to checkin?
Thanks,
--
Joel
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.183
diff -u -p -r1.183 windows-nat.c
--- windows-nat.c 8 Mar 2009 21:01:52 -0000 1.183
+++ windows-nat.c 12 Mar 2009 20:34:56 -0000
@@ -2128,6 +2128,12 @@ windows_xfer_partial (struct target_ops
}
}
+static ptid_t
+windows_get_ada_task_ptid (long lwp, long thread)
+{
+ return ptid_build (ptid_get_pid (inferior_ptid), 0, lwp);
+}
+
static void
init_windows_ops (void)
{
@@ -2169,6 +2175,7 @@ init_windows_ops (void)
windows_ops.to_has_registers = 1;
windows_ops.to_has_execution = 1;
windows_ops.to_pid_to_exec_file = windows_pid_to_exec_file;
+ windows_ops.to_get_ada_task_ptid = windows_get_ada_task_ptid;
i386_use_watchpoints (&windows_ops);
windows_ops.to_magic = OPS_MAGIC;