Hello,

I am looking into adding support to the capture engine to trace interrupts. One possible way, which seems generic and would not require any changes to the BSPs, is to replace the ISR for a specific interrupt with a wrapper that adds a record to the capture log before and after it calls the original ISR. I have attached some code below to show how it could be done. The wrapper could be installed/uninstalled using rtems_interrupt_catch(). Would this be an acceptable solution or can you see any immediate problems with this approach?
rtems_isr_entry original_vector_table[CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER];

static void record_interrupt(rtems_vector_number vector)
{
  void* rec;
  Thread_Control* tcb = _Thread_Get_executing();

  if (!rtems_capture_task_recorded (tcb))
    rtems_capture_record_task (tcb);

  rtems_capture_begin_add_record(tcb, RTEMS_CAPTURE_INTERRUPT_ENTER,
      sizeof(rtems_capture_interrupt_record_t), &rec);
rtems_capture_append_to_record(rec, &vector, sizeof(rtems_vector_number));
  rtems_capture_end_add_record(rec);

  original_vector_table[vector](vector);

  rtems_capture_begin_add_record(tcb, RTEMS_CAPTURE_INTERRUPT_EXIT,
      sizeof(rtems_capture_interrupt_record_t), &rec);
rtems_capture_append_to_record(rec, &vector, sizeof(rtems_vector_number));
  rtems_capture_end_add_record(rec);
}

void capture_interrupt(rtems_vector_number vector)
{
rtems_interrupt_catch(record_interrupt, vector, &original_vector_table[vector]);
}

--
Daniel Cederman
Software Engineer
Aeroflex Gaisler AB
Aeroflex Microelectronic Solutions – HiRel
Kungsgatan 12
SE-411 19 Gothenburg, Sweden
ceder...@gaisler.com
www.Aeroflex.com/Gaisler
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to