RTEMS gdb script

Joel Sherrill joel.sherrill at OARcorp.com
Wed Dec 11 22:36:53 UTC 2002


Hi,

I have mentioned this a few times over the years but
it never seems to get anywhere.  Attached is a gdb script
I conjured up a while back to define macro commands for
gdb that dump some internal RTEMS structures in a meaningful
way.  

It is a hack in process.  The top is a bunch of directory 
commands to point back to the source tree I was using
at the time.

The commands of interest are:

  dump_tasks	   - prints classic API tasks
  dump_pthread	   - prints pthreads
  dump_all_tasks   - prints internal, classic, and pthreads
  dump_ticks_chain - prints ticks chain (ISR serviced watchdog timers)
  dumps_ticks_tasks_chain - print ticks chain (task serviced watchdog
timers)

I am throwing this out for a handful of reasons.

  1.  It needs feedback.
  2.  The command names are VERY bad!  Suggestions desired.
  3.  More commands are needed.  These are good examples for
      creating ones that run the other object chains.
  4.  Now they are in the mailing list archive so I won't 
      misplace them again. :)

Ideally I would like to see a robust set of these commands
defined from a user's point of view.  Then we could add them
as "not implemented" and everyone could write them as needed.

These run as macros in gdb so in theory are pretty target 
independent.  You have to source this file to get the commands.

Feedback, comments welcomed.

--joel
-------------- next part --------------
directory /usr1/rtems/work/rtems/c/src/exec/rtems/src
directory /usr1/rtems/work/rtems/c/src/exec/posix/src
directory /usr1/rtems/work/rtems/c/src/exec/sapi/src
directory /usr1/rtems/work/rtems/c/src/exec/score/src
directory /usr1/rtems/work/rtems/c/src/exec/score/cpu/powerpc
directory /usr1/rtems/work/rtems/c/src/lib/libbsp/powerpc/psim/clock
directory /usr1/rtems/work/rtems/c/src/lib/libbsp/powerpc/psim/startup
directory /usr1/rtems/work/rtems/c/src/lib/libbsp/shared
directory /opt/gnatrtems/powerpc-rtems/psim/lib/include/rtems/score
directory /opt/gnatrtems/powerpc-rtems/psim/lib/include/rtems/rtems

define dump_tasks_support
  set $index = 1
  while $index <= $arg0.maximum
    set $pt = (Thread_Control *)$arg0.local_table[$index]
    if $pt != 0
      printf "thread 0x%x: state=0x%x pri=%d ", \
        $pt->Object.id, $pt->current_state, $pt->current_priority
      printf "ticks_executed=%d \n", $pt->ticks_executed
    end

    set $index = $index + 1
  end
end

define dump_internal_tasks
  dump_tasks_support  _Thread_Internal_information
end

define dump_tasks
  dump_tasks_support  _RTEMS_tasks_Information
end

define dump_pthread
  dump_tasks_support  _POSIX_Threads_Information
end

define dump_all_tasks
  printf "Executing: 0x%x, Heir: 0x%x\n", _Thread_Executing->Object.id, \
    _Thread_Heir.Object.id
  dump_tasks_support  _Thread_Internal_information
  dump_tasks_support  _RTEMS_tasks_Information
  dump_tasks_support  _POSIX_Threads_Information
end

define dump_watchdog_chain
  set $permt = &$arg0.permanent_null
  set $node = $arg0.first
  while $node != $permt
   set $wnode = (Watchdog_Control *)$node
   #printf "0x%x, %d, 0x%x -- ", $wnode, $wnode.delta_interval, $wnode.routine
   printf "======================\n"
   print $wnode
   print *$wnode
   set $node = $node.next
  end
end

define dump_ticks_chain
  dump_watchdog_chain _Watchdog_Ticks_chain
end

define dump_ticks_task_chain
  dump_watchdog_chain _Timer_Ticks_chain
end

#d
#b _Thread_Delay_ended
#r


More information about the users mailing list