Home
Highly Reusable Software By activity User Interface Text Strings Math Processing
Stored Data
Communications
Hard World File System
|
librock_dumpmem - Function to dump memory to a FILE *.
#License - #Source code - #Example Use -
#include <librock/exec.h>NOTE: Caller has to #define or have a FILE *librock_ftrace in scope
void librock_dumpmem( FILE *f, const char *p, int c ); int librock_TRACE_MARK( const char *psz ); int librock_TRACE_FN( const char *pszFunctionName ); int librock_TRACE_FR( const char *pszFunctionName,const char *pszType ); int librock_TRACE_STRUCT_B(); int librock_TRACE_STRUCT_E(); int librock_TRACE_V_I( int i ); int librock_TRACE_V_MEM( void *p, int c ); int librock_TRACE_V_PSZ( const char *psz );
Return values are not useful.
librock_dumpmem() will URL encode (% escape) the c
bytes at p.
ASCII Spaces are converted to '+'. '+', '%' and any characters outside
the range 0x21-0x7f inclusive are escaped. Other characters appear
unchanged.
Typical use is to instrument code for debugging and regression testing. Here is an example of an instrumented function wrapper.
int librock_VSBInsert(struct librock_VSB_s *v,int loc,const char *buf,int len) { int ret; /* Show what function we just entered */ librock_TRACE_FN("librock_VSBInsert"); /* Show parameters (and initial state.) We dump the contents of the librock_VSB_s, not the memory pointer values. */ librock_TRACE_STRUCT_B(); librock_TRACE_V_I(v->inbuf); librock_TRACE_V_MEM(v->buf,v->inbuf); librock_TRACE_STRUCT_E(); librock_TRACE_V_I(loc); librock_TRACE_V_MEM(buf,len); /* Do the call */ ret = librock_body_VSBInsert(v,loc,buf,len); /* Note the function returned, and the return type, and value */ librock_TRACE_FR("librock_VSBInsert","int"); librock_TRACE_V_I(ret); /* Show the exit state. */ librock_TRACE_STRUCT_B(); librock_TRACE_V_I(v->inbuf); librock_TRACE_V_MEM(v->buf,v->inbuf); librock_TRACE_STRUCT_E(); return ret; }Typical use of dumpmem
#ifdef librock_TYPICAL_USE_dumpmem #include <stdio.h> #include <librock/exec.h> char buf[4] = { 'a', '\x04', '\x85', 'c'}; librock_dumpmem(stdout,buf,sizeof(buf)); printf("\n"); #endif
fprintf() librock_ftrace // Must be a FILE * in scope. Can be 0.
Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block. License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45
librock_TRACE_FN passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_FN passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_TRACE_FR passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_FR passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_TRACE_MARK passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_MARK passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_TRACE_STRUCT_B passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_STRUCT_B passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_TRACE_STRUCT_E passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_STRUCT_E passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_TRACE_V_I passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_V_I passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_TRACE_V_MEM passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_V_MEM passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_TRACE_V_PSZ passed tests in tvsbop (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_TRACE_V_PSZ passed tests in tvsbop_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_dumpmem passed tests in tfsil (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_dumpmem passed tests in tfsil_main (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)
Want to help? We welcome comments, patches. -- Need help? Request paid support.