Cosmos/Docs/Debugger/Index.html
kudzu_cp c59ecc3233
2010-09-03 00:41:37 +00:00

97 lines
4.8 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h3>
Introduction</h3>
<p>
The debugger is a monumental piece of work and one of the key enabling elements
of making Cosmos unique. We have put an immense amount of work into the debugger
and will continue to do so even though it takes a lot of time and detracts from
resources that could be used to develop Cosmos kernel code. We do this because
we believe that every hour put into the debugger will be returned in many times
as many hours saved in kernel development. Some users have criticized this
approach, but we stand firm in this belief and believe that Cosmos success rests
heavily on the debugger and tight Visual Studio integration.</p>
<h3>
Obstacles</h3>
<p>
The Visual Studio debugger is only lightly documented (lightly might be a kind
adjective). There are few if any samples and much of our progress is the result
of sheer determination and experimentation.</p>
<h3>
Debug Stub</h3>
<h3>
&nbsp;</h3>
<h3>
Communication</h3>
Communication currently uses the serial port. Other methods such as ethernet are
planned in the future.<h3>
Data Files</h3>
<p>
All files are generated in the output directory. Usually this is bin/debug or
bin/release.</p>
<h4>
CMAP file</h4>
The CMAP file maps assembler labels to physical memory locations. These labels
include data (internal data, static fields, string literals) and code locations
(method entry, points for each line of code, internal locations for exception
handling).<br />
<br />
The format is address, tab, label. A small excerpt is shown below.<pre>00500000 DebugTraceMode
00500004 DebugStatus
00500008 DebugRunning </pre>
<h4>
CXDB file</h4>
<p>
The CXDB contains a series of records with information about the methods. Each
record contains:</p>
<ul>
<li>LabelName (string) - Label as used in the ASM file to start the method. Each
label emitted exists, that is many labels for each method.</li>
<li>Address (uint) - Address in physical memory.</li>
<li>StackDifference (int) - Size of stack. Arguments only?</li>
<li>AssemblyFile (string) - .NET assmebly containing IL source.</li>
<li>TypeToken (int) - .NET token for the containing type.</li>
<li>MethodToken (int) - .NET token for the method.</li>
<li>ILOffset (int) - Offset into the .NET assembly file where the method resides.</li>
<li>MethodName (string) - Name of the method. Not unique, as many labels exist per
method.</li>
</ul>
Cosmos.Debug.Common.CDebugger.SourceInfos is a class for reading the CXDB file
(and the PDB too). Currently the CXDB is handled by a dataset and saved as an
XML file. However we never need the whole file in RAM, and in the future it
should be changed to a database such as embedded Firebird (SQL Express has size
limits we could forseeably encounter).<h4>
ASM file</h4>
<p>
The ASM file is actually generated by the Cosmos compiler, however in some cases
it can be useful to the debugger. Most notably to display the assembly during
interaction with GDB, or the given assembly for .NET code. Currently it is only
used by the Cosmos GDB client, however there are plans to integrate assembly
view and GDB debugging into Visual Studio.</p>
<h4>
PDB files</h4>
<p>
PDB files are debug files generated by the .NET compiler. (<a
href="http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx">More
info</a>, although its summed up as &quot;A .NET PDB only contains two pieces of
information, the source file names and their lines and the local variable names.
All the other information is already in the .NET metadata so there is no need to
duplicate the same information in a PDB file. &quot;)</p>
<p>
PDB maps methods to source file locations. Given a method name, the source file
and exact start and end locations can be determined. It also contains
&quot;SequencePoints&quot; which map to individual source code lines in a source file.</p>
<h4>
LOG.html</h4>
<p>
If logging is enabled, a log file containting the scan tree used by the Cosmos
compiler will be generated.</p>
</body>
</html>