1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML LANG="en-us">
<HEAD>
<META name="Author" content="Carlo Wood">
<META http-equiv="content-type" content="text/html; charset=iso-8859-1">
<TITLE>libcwd: The C++ Debugging Support Library - Features</TITLE>
<SCRIPT TYPE="text/javascript" SRC="../scripts/break_out_of_frame.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../scripts/detect_browser.js"></SCRIPT>
<SCRIPT TYPE="text/javascript">need_style_tag_cw=1;</SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../scripts/load_style_sheets.js"></SCRIPT>
</HEAD>
<BODY>
<table border=0 cellspacing=15 cellpadding=0 width=100%>
<!-- *** Page Header *** -->
<tr>
<td class="tag-cw-main-header" colspan=4 align=middle><B><SPAN class="H1code">libcw<FONT color=red>d</FONT></SPAN></B></td>
</tr>
<tr>
<td colspan=2><H2>Features</H2></td>
</tr>
<tr>
<td width=50% valign=top>
<table border=0 cellspacing=5 cellpadding=0 width=100%>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
End-users of an application don't need to install libcwd.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
The use of namespaces prevents name collisions between debug channels of different libraries.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Debug channels and devices can be turned on or off on a per thread basis.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
All debug code can be omitted from the executable by not defining a single <SPAN class=code>CWDEBUG</SPAN> macro.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
<SPAN class="features">Code using libcwd looks clean and is surveyable as a result of using a few well-defined macros, avoiding the need
of disturbing <SPAN class=code>#ifdef CWDEBUG</SPAN> ... <SPAN class=code>#endif</SPAN> constructs.</SPAN>
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Debug output is written to an ostream and as such type-safe and customizable as is usual for C++ ostreams.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
An arbitrary number of debug channels and debug devices can be created without any penalty in terms of cpu usage.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Full support for all forms of iterative and recursive calls.
</td>
</tr>
</table>
</td>
<td width=50% valign=top>
<table border=0 cellspacing=5 cellpadding=0 width=100%>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Debug output is surveyable as a result of several possibilities to format the output, like
a margin string, a marker string, indentation and fixed-width channel labels.
All formatting is thread specific.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Printing the type of arbitrary variables in demangled form.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Printing addresses in <I>source file</I><SPAN class=code>:</SPAN><I>line number</I> presentation.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Deallocation pointer validation.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Magic numbers around allocated memory blocks in order to detect buffer overruns.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Printing an overview of current memory allocations, including
start address, size, type of allocated object, source file and line number of allocation and a user definable description.
</td>
</tr>
<tr>
<td width=16 valign=top><img width=16 height=16 src="../images/ball_neon_gimp.gif"></td>
<td width=100%>
Finding allocation information with only a pointer that points <EM>inside</EM> an allocated memory block,
in logarithmic time.
</td>
</tr>
</table>
</td>
</tr>
</table>
<A NAME="screenshot"></A>
<div class="screenshot">
<H2>"Screen shot"</H2>
<h5>code example</h5>
<pre class="code" STYLE="margin-left: 0">Dout(dc::notice|error_cf, "Hello World");</pre>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=10% class="margin" valign=middle align=middle>
<- margin ->
</td>
<td width=10% class="label" valign=top align=left>
<span class="output"><B>NOTICE</B></span>
</td>
<td width=10 class="marker" valign=top align=middle>
<- marker ->
</td>
<td width=10% class="indentation" valign=top align=middle>
<- indentation ->
</td>
<td width=60% class="text" valign=top align=left>
<span class="output"> <B>Hello World : </B></span><I>error string</I> <new-line>
</td>
</tr>
</table>
<h5>output example</h5>
<pre class="output" STYLE="margin-left: 0">
NOTICE : Entering exec_prog()
SYSTEM : pipe([3, 4]) = 0
SYSTEM : pipe([5, 6]) = 0
child MALLOC : operator new (size = 24) = <unfinished>
child BFD : Loading debug symbols from /home/carlo/c++/bfd/bfd... done
SYSTEM : fork() = 13078 [parent process]
SYSTEM : close(4) = 0
SYSTEM : close(6) = 0
child BFD : Loading debug symbols from /home/carlo/c++/libcw/lib/libcwd.so.0 (40013000) ... done
child BFD : Loading debug symbols from /usr/lib/libstdc++-libc6.1-2.so.3 (40057000) ... done
child BFD : Loading debug symbols from /lib/libm.so.6 (4009e000) ... done
child BFD : Loading debug symbols from /lib/libc.so.6 (400ba000) ... done
child BFD : Loading debug symbols from /usr/lib/libbfd-2.9.5.0.14.so (401ad000) ... done
child BFD : Loading debug symbols from /lib/ld-linux.so.2 (40000000) ... done
child BFD : 0x40082003 is at (streambuf.cc:211)
child MALLOC : <continued> 0x8053a68
SYSTEM : poll( [ { 3, POLLIN, 0 }, { 5, POLLIN, 0 }, { 7, POLLIN, POLLIN } ], 3, -1) = 1
child SYSTEM : fork() = 0 [child process]
child SYSTEM : close(3) = 0
child SYSTEM : close(5) = 0
child SYSTEM : close(1) = 0
child SYSTEM : close(2) = 0
child SYSTEM : dup2(4, 1) = 1
child SYSTEM : dup2(6, 2) = 2
child SYSTEM : close(4) = 0
SYSTEM : poll( [ { 3, POLLIN, POLLIN }, { 5, POLLIN, 0 }, { 7, POLLIN, 0 } ], 3, -1) = 1
SYSTEM : read(3, "\t", 128) = 1
SYSTEM : read(3, "libcwd.so.0", 128) = 11
SYSTEM : read(3, " => ", 128) = 4
SYSTEM : read(3, "/usr/lib/libcwd.so.0", 128) = 20
SYSTEM : read(3, " (0x", 128) = 4
SYSTEM : read(3, "40018000", 128) = 8
SYSTEM : read(3, ")\n", 128) = 2
NOTICE : child process stdout: "\tlibcwd.so.0 => /usr/lib/libcwd.so.0 (0x40018000)\n"
</pre>
<h5>code example</h5>
<pre class="code" STYLE="margin-left: 0">
template<typename T>
B<T>::~B(void)
{
Dout(dc::notice, "Calling the destructor of " <<
libcwd::type_info_of(*this).demangled_name() << " (this == " << this << ")");
libcwd::alloc_ct const* alloc = libcwd::find_alloc(this);
if (sizeof(*this) != alloc->size())
{
Debug(dc::malloc.off());
Debug(libcw_do.push_marker());
Debug(libcw_do.marker().assign(": | "));
Dout(dc::notice, "This is a base class of an object starting at " << alloc->start());
Dout(dc::notice, "The type of the pointer to the allocated object is " <<
alloc->type_info().demangled_name());
Debug(libcw_do.marker().assign(": ` "));
Dout(dc::notice, "The destructor was called from " << location_ct(builtin_return_address(0)));
Debug(dc::malloc.on());
Debug(libcw_do.pop_marker());
}
}
</pre>
<P>(<FONT size=-1>Click <A HREF="screenshot.cc">here</A> to download/view the complete program.</FONT>)</P>
<h5>output</h5>
<pre class="output" STYLE="margin-left: 0">
MALLOC : operator new (size = 4) = 0x80584d0 [screenshot.cc:56]
NOTICE : b is 0x80584d0
MALLOC : operator new (size = 12) = 0x8100fa0 [screenshot.cc:60]
NOTICE : c is 0x8100fa0
NOTICE : Calling the destructor of B<int> (this == 0x80584d0)
MALLOC : delete 0x80584d0 screenshot.cc:56 B<int>; (sz = 4) object `b'
NOTICE : Calling the destructor of B<B<char> > (this == 0x8100fa4)
NOTICE : | This is a base class of an object starting at 0x8100fa0
NOTICE : | The type of the pointer to the allocated object is C<double, B<char> >*
NOTICE : ` The destructor was called from screenshot.cc:65
MALLOC : delete 0x8100fa0 screenshot.cc:60 C<double, B<char> >; (sz = 12) object `c'
</pre>
<h5>Another output example</h5>
<pre class="output" STYLE="margin-left: 0">
MALLOC : malloc(10) = <unfinished>
WARNING : Object file /lib/ld-linux.so.2 does not have debug info. Address lookups inside this object file will result in a function name only, not a source file location.
MALLOC : <continued> 0x8125978 [ld-linux.so.2:open_path]
MALLOC : calloc(586, 1) = 0x8124f10 [ld-linux.so.2:_dl_new_object]
MALLOC : realloc(0x0, 138) = 0x8125170 [ld-linux.so.2:_dl_new_object]
MALLOC : malloc(52) = 0x8110fa0 [ld-linux.so.2:_dl_map_object_deps]
MALLOC : calloc(8, 16) = 0x8052c98 [ld-linux.so.2:_dl_check_map_versions]
MALLOC : malloc(68) = <unfinished>
WARNING : Object file /lib/tls/libc.so.6 does not have debug info. Address lookups inside this object file will result in a function name only, not a source file location.
MALLOC : <continued> 0x80569e0 [libc.so.6:dl_open_worker]
BFD : Loading debug symbols from module.so (0x40424000) ... done (179 symbols)
MALLOC : malloc(310) = <unfinished>
BFD : Loading debug info from module.so... done
BFD : address 0x4042bc90 corresponds to module.cc:24
MALLOC : <continued> 0x81ab7b0 [module.cc:24]
MALLOC : malloc(300) = <unfinished>
BFD : address 0x4042ba86 corresponds to module.cc:13
MALLOC : <continued> 0x81ab8f8 [module.cc:13]
MALLOC : Allocated memory: 1592 bytes in 8 blocks.
malloc 0x81ab8f8 module.cc:13 void*; (sz = 300) Allocated inside static_test_symbol
malloc 0x81ab7b0 module.cc:24 void*; (sz = 310) Allocated inside global_test_symbol
malloc 0x80569e0 dl_open_worker <unknown type>; (sz = 68)
malloc 0x8052c98 _dl_check_map_versions <unknown type>; (sz = 128)
malloc 0x8110fa0 _dl_map_object_deps <unknown type>; (sz = 52)
realloc 0x8125170 _dl_new_object <unknown type>; (sz = 138)
malloc 0x8124f10 _dl_new_object <unknown type>; (sz = 586)
malloc 0x8125978 open_path <unknown type>; (sz = 10)
MALLOC : free(0x81ab7b0) module.cc:24 void*; (sz = 310) Allocated inside global_test_symbol
MALLOC : free(0x81ab8f8) module.cc:13 void*; (sz = 300) Allocated inside static_test_symbol
MALLOC : free(0x8052c98) _dl_check_map_versions <unknown type>; (sz = 128)
MALLOC : free(0x8125170) _dl_new_object <unknown type>; (sz = 138)
MALLOC : free(0x8125978) open_path <unknown type>; (sz = 10)
MALLOC : Trying to free NULL - ignored.
MALLOC : Trying to free NULL - ignored.
MALLOC : free(0x8124f10) _dl_new_object <unknown type>; (sz = 586)
MALLOC : free(0x8110fa0) _dl_map_object_deps <unknown type>; (sz = 52)
NOTICE : Finished
</pre>
</div> <!-- screenshot -->
</BODY>
</HTML>
|