ARM Technical Support Knowledge Articles

SCRIPT TO OUTPUT CIRCULAR BUFFER

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

I have a circular buffer in my program that I access using next_in and next_out indexes. Is there a way I can create a debugger script to output the contents of the buffer in order?

ANSWER

Yes.

The following script print_circ_buf accepts the address of the buffer, the length, and the next out and next in indexes. It outputs the address along with its contents.

func void print_circ_buf (
  unsigned long array,
  unsigned length,
  unsigned n_out,
  unsigned n_in) {

unsigned i;

if (n_in >= n_out)
  length = n_in;

for (i=n_out; i<length; i++)
  {
  printf ("[%4.4X] = %2.2X %c
",
          (unsigned) array + i,
          (unsigned) _rbyte(array + i),
          (unsigned char) _rbyte(array + i));
  }

if (i != n_in)
  {
  for (i = 0; i<n_in; i++)
    {
    printf ("[%4.4X] = %2.2X %c
",
            (unsigned) array + i,
            (unsigned) _rbyte(array + i),
            (unsigned char) _rbyte(array + i));
    }
  }
}

You may wish to define a toolbox button to automatically call this function. For example:

define button "PrintBuffer", "print_circ_buf(circ_buffer, 17, next_out, next_in)"

SEE ALSO

Article last edited on: 2005-12-15 08:04:24

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential