summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-01-31 19:12:46 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-01-31 19:12:46 +0000
commit379d2ed5a965fc1bdb2785bcd0fe0f95cf4a59d9 (patch)
treeb427e8abd37c0f2edfbcbd7d7bb8248674e0ec16 /cpukit/libmisc
parentPatch from Eric Norum <eric@skatter.usask.ca> to avoid dereferencing a (diff)
downloadrtems-379d2ed5a965fc1bdb2785bcd0fe0f95cf4a59d9.tar.bz2
New files added to ease debugging.
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r--cpukit/libmisc/dumpbuf/dumpbuf.c75
-rw-r--r--cpukit/libmisc/dumpbuf/dumpbuf.h21
2 files changed, 96 insertions, 0 deletions
diff --git a/cpukit/libmisc/dumpbuf/dumpbuf.c b/cpukit/libmisc/dumpbuf/dumpbuf.c
new file mode 100644
index 0000000000..1e41f52bbf
--- /dev/null
+++ b/cpukit/libmisc/dumpbuf/dumpbuf.c
@@ -0,0 +1,75 @@
+/*
+ * COPYRIGHT (c) 1997.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may in
+ * the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <rtems/dumpbuf.h>
+
+/*
+ * Put the body below Dump_Buffer so it won't get inlined.
+ */
+
+static inline void Dump_Line(
+ unsigned char *buffer,
+ int length
+);
+
+void Dump_Buffer(
+ unsigned char *buffer,
+ int length
+)
+{
+
+ int i, mod, max;
+
+ if ( !length ) return;
+
+ mod = length % 16;
+
+ max = length - mod;
+
+ for ( i=0 ; i<max ; i+=16 )
+ Dump_Line( &buffer[ i ], 16 );
+
+ if ( mod )
+ Dump_Line( &buffer[ max ], mod );
+}
+
+static inline void Dump_Line(
+ unsigned char *buffer,
+ int length
+)
+{
+
+ int i;
+ char line_buffer[120];
+
+ line_buffer[0] = '\0';
+
+ for( i=0 ; i<length ; i++ )
+ sprintf( line_buffer, "%s%02x ", line_buffer, buffer[ i ] );
+
+ for( ; i<16 ; i++ )
+ strcat( line_buffer, " " );
+
+ strcat( line_buffer, "|" );
+ for( i=0 ; i<length ; i++ )
+ sprintf( line_buffer, "%s%c", line_buffer,
+ isprint( buffer[ i ] ) ? buffer[ i ] : '.' );
+
+ for( ; i<16 ; i++ )
+ strcat( line_buffer, " " );
+
+ strcat( line_buffer, "|\n" );
+
+ printf( line_buffer );
+}
diff --git a/cpukit/libmisc/dumpbuf/dumpbuf.h b/cpukit/libmisc/dumpbuf/dumpbuf.h
new file mode 100644
index 0000000000..3af196e8d1
--- /dev/null
+++ b/cpukit/libmisc/dumpbuf/dumpbuf.h
@@ -0,0 +1,21 @@
+/*
+ * COPYRIGHT (c) 1997.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may in
+ * the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#ifndef __DUMP_BUFFER_h
+#define __DUMP_BUFFER_h
+
+void Dump_Buffer(
+ unsigned char *buffer,
+ int length
+);
+
+#endif
+/* end of include file */