RTEMS gdb

Stephen Holford SHolford at WESCAM.com
Thu Dec 6 19:29:17 UTC 2001


Hi Eric

That patch makes sense. I had tried using enterRgdb() in my code and due to
the unhandled exception it produced I assumed that it was for private use
only in the  MyThreadIdle code.

My initial patches are below, as I mentioned I'm not 100% happy with how
things work. Your document "RTEMS Remote Debugger Server Specifications"
does mention the current limitations. This is why I asked if anyone is
actively working on this code, because if they are I am probably wasting my
time, but if not, I may be able to contribute some useful patches.  I am
also including the raw diff file as an attachment so you don't have to
de-munge it. And as I mentioned, I'm working with the 20011025 snapshot.

----------------------------------------------------------------------------
-------------------------------------
1. I needed to add ASM_PROG_VECTOR  (#7) to the list of allowable exceptions
or RPT_CONT in ptrace.c will lock us out when these occur by setting
CannotRestart to 1.
----------------------------------------------------------------------------
-------------------------------------

diff -ur
/home/rtems/archive/rtems-ss-20011025/c/src/librdbg/include/rdbg/powerpc/rdb
g_f.h ./librdbg/include/rdbg/powerpc/rdbg_f.h
---
/home/rtems/archive/rtems-ss-20011025/c/src/librdbg/include/rdbg/powerpc/rdb
g_f.h Tue Aug 10 12:41:10 1999
+++ ./librdbg/include/rdbg/powerpc/rdbg_f.h Fri Nov 23 17:04:31 2001
@@ -21,6 +21,7 @@
 {
   if (
       ctx->ctx->_EXC_number != ASM_SYS_VECTOR &&
+      ctx->ctx->_EXC_number != ASM_PROG_VECTOR &&
       ctx->ctx->_EXC_number != ASM_TRACE_VECTOR
       ) return 0;
   else return 1;

----------------------------------------------------------------------------
-------------------------------------
2: I need to make the debugId task id available to RPT_CONT to ensure this
task is continued if you have switched currentTargetThread after the first
attach. Also in TgtAttach I check for and delete the eventTask and the two
debugging semaphores just in case we are attaching after GDB did a segfault
and died without a proper detach.
----------------------------------------------------------------------------
-------------------------------------

diff -ur /home/rtems/archive/rtems-ss-20011025/c/src/librdbg/src/_servtgt.c
./librdbg/src/_servtgt.c
--- /home/rtems/archive/rtems-ss-20011025/c/src/librdbg/src/_servtgt.c Thu
Oct 19 11:35:21 2000
+++ ./librdbg/src/_servtgt.c Thu Dec  6 13:34:24 2001
@@ -29,6 +29,7 @@
 rtems_id eventTaskId;
 rtems_id serializeSemId;
 rtems_id wakeupEventSemId;
+rtems_id debugId;

 CPU_Exception_frame Idle_frame;

@@ -120,7 +121,6 @@
 {
   rtems_name task_name;
   rtems_status_code status;
-  rtems_id debugId;

   errno = 0;

@@ -136,7 +136,24 @@
   connect_rdbg_exception();

   /*
-   * Create the attach debuger task
+   * Search for and remove debugging tasks / semaphores left over from
+   * a previous attach without a detach.
+   */
+
+  if (rtems_task_ident(rtems_build_name( 'E', 'v', 'n', 't' ),
+                  RTEMS_SEARCH_ALL_NODES, &eventTaskId) ==
RTEMS_SUCCESSFUL)
+    rtems_task_delete(eventTaskId);
+
+  if (rtems_semaphore_ident(rtems_build_name('D', 'B', 'G', 's'),
+               RTEMS_SEARCH_ALL_NODES, &serializeSemId) ==
RTEMS_SUCCESSFUL)
+    rtems_semaphore_delete(serializeSemId);
+
+  if (rtems_semaphore_ident(rtems_build_name('D', 'B', 'G', 'w'),
+             RTEMS_SEARCH_ALL_NODES, &wakeupEventSemId) ==
RTEMS_SUCCESSFUL)
+    rtems_semaphore_delete(wakeupEventSemId);
+
+  /*
+   * Create the attach debugger task
    */
   task_name = rtems_build_name( 'E', 'v', 'n', 't' );
   if ((status = rtems_task_create( task_name, 10, 24576,

----------------------------------------------------------------------------
------------------------------------------
3: This one was the show stopper. In RPT_CONT, If you used "thread target"
and switched away from the thread that the last breakpoint stopped in, and
then tried to continue,  the line  "if (!isRdbgException(ctx))" would
attempt do de-reference a NULL ctx pointer, causing total loss of target
control. So I am checking for the NULL case now, and also if I get a NULL
context I try and find the context for the debugId task, which ensures that
this task will continue and taskDelete itself no matter what on the first
continue.

With these changes I can now attach, thread target, set breakpoints and
continue without any major problems as long as I keep it simple.
----------------------------------------------------------------------------
-------------------------------------

diff -ur /home/rtems/archive/rtems-ss-20011025/c/src/librdbg/src/ptrace.c
./librdbg/src/ptrace.c
--- /home/rtems/archive/rtems-ss-20011025/c/src/librdbg/src/ptrace.c Fri Sep
21 13:51:44 2001
+++ ./librdbg/src/ptrace.c Thu Dec  6 13:37:45 2001
@@ -19,6 +19,7 @@
 extern rtems_id serializeSemId;
 extern rtems_id wakeupEventSemId;
 extern rtems_id eventTaskId;
+extern rtems_id debugId;
 extern Exception_context *FirstCtx;
 extern Exception_context *LastCtx;
 extern CPU_Exception_frame SavedContext;
@@ -162,21 +163,23 @@
      }

      ctx = GetExceptCtx (currentTargetThread);
+     if (ctx == NULL)
+       ctx = GetExceptCtx (debugId);

-     if (!isRdbgException(ctx)) {
-       CannotRestart = 1;
-       setErrno (EIO);
-       return -1;
-     }
+     if (ctx != NULL) {
+
+       if (!isRdbgException(ctx)) {
+         CannotRestart = 1;
+         setErrno (EIO);
+         return -1;
+       }

-     assert (data == 0);
-     assert (ExitForSingleStep == 0);
+       assert (data == 0);
+       assert (ExitForSingleStep == 0);

-     rtems_semaphore_release( serializeSemId );
-
-     if ((ctx = GetExceptCtx (currentTargetThread)) != NULL) {
        rtems_semaphore_release( ctx->semaphoreId );
      }
+     rtems_semaphore_release( serializeSemId );
      return 0;
    }

----------------------------------------------------------------
Stephen F. Holford, P.Eng.
Wescam
(905) 633-4000 x2119



-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtemsrdbg.diff
Type: application/octet-stream
Size: 3317 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20011206/ad158283/attachment-0001.obj>


More information about the users mailing list