librdbg fix for PowerPC

Till Straumann strauman at SLAC.Stanford.EDU
Fri Jan 18 05:36:11 UTC 2002


Hi.

Today was RDBG day for me. I started using the debugger
for EPICS applications on PowerPC / SVGM5.

However, librdbg needed to be fixed - the out of the box
version didn't work (see comments in the patch file)

-- Till.
-------------- next part --------------
RTEMS librdbg patch (against rtems-ss-20011210)

Author: Till Straumann <strauman at slac.stanford.edu>

This patch addresses the following issues:
 - exception handler needs to enable MSR_FP if the
   interrupted thread is FP enabled.
 - printk message for MSR fixed and 
   added stacktrace
   NOTE: this requires the stacktrace
   patch to lib/libbsp/powerpc/shared/vectors/vector_init.c
   (#ifdef DDEBUG only, however)

Index: c/src/librdbg//src/powerpc/excep_f.c
===================================================================
RCS file: /afs/slac/g/spear/cvsrep/rtems/src/c/src/librdbg/src/powerpc/excep_f.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -c -r1.1.1.1 -r1.2
*** c/src/librdbg//src/powerpc/excep_f.c	2001/12/14 22:54:21	1.1.1.1
--- c/src/librdbg//src/powerpc/excep_f.c	2002/01/18 05:25:44	1.2
***************
*** 56,61 ****
--- 56,73 ----
    rtems_status_code status;
    rtems_id continueSemId;
  
+   /* T. Straumann, 1/16/2002: we must re-enable the floating point engine
+    *                          if the interrupted thread is FP. Otherwise,
+    *                          the semaphore primitives may crash when they
+    *                          try to save FP context while switching this
+    *                          thread...
+    */
+   if (ctx->EXC_SRR1 & 0x2000) {
+ 	register unsigned long msr;
+ 	__asm__ __volatile__("mfmsr %0":"=r"(msr));
+ 	__asm__ __volatile__("mtmsr %0"::"r"(msr|MSR_FP));
+   }
+ 
    if ( (justSaveContext) && (ctx->_EXC_number == ASM_SYS_VECTOR) ) {
      PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
      justSaveContext = 0;
***************
*** 114,120 ****
      printk("\t CTR = %x\n", ctx->EXC_CTR);
      printk("\t XER = %x\n", ctx->EXC_XER);
      printk("\t LR = %x\n", ctx->EXC_LR);
!     printk("\t MSR = %x\n", ctx->EXC_MSR);
  #endif
  
      status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
--- 126,132 ----
      printk("\t CTR = %x\n", ctx->EXC_CTR);
      printk("\t XER = %x\n", ctx->EXC_XER);
      printk("\t LR = %x\n", ctx->EXC_LR);
!     printk("\t MSR = %x\n", ctx->EXC_SRR1);
  #endif
  
      status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
***************
*** 151,156 ****
--- 163,173 ----
  
      default:
        DPRINTF((" OTHER EXCEPTION !!!\n"));
+ #ifdef DDEBUG
+ 	{ extern void BSP_printStackTrace();
+ 		BSP_printStackTrace(ctx);
+ 	}
+ #endif
        rtems_semaphore_release( wakeupEventSemId );
        break;
      }


More information about the users mailing list