<?xml version="1.0"?>
<rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007" xmlns:atom="http://www.w3.org/2005/Atom">
   <channel>
      <title>MOSA Dev Blogs</title>
      <description>Pipes Output</description>
      <link>http://pipes.yahoo.com/pipes/pipe.info?_id=5iW6r_4p3hGAgK6gDYSbGg</link>
      <atom:link rel="next" href="http://pipes.yahoo.com/pipes/pipe.run?_id=5iW6r_4p3hGAgK6gDYSbGg&amp;_render=rss&amp;page=2"/>
      <pubDate>Thu, 01 Oct 2015 11:36:58 +0000</pubDate>
      <generator>http://pipes.yahoo.com/pipes/</generator>
      <item>
         <title>Michael: Implications of ECMA-335 and Partition I, 12.1.2 and 12.</title>
         <link>http://www.michaelruck.de/2010/04/implications-of-ecma-335-and-partition.html</link>
         <description>As I&amp;#x2019;ve been spending quite some time this weekend to refactor parts of the MOSA compiler and fixing things small and large. I&amp;#x2019;ve stumbled once again over our memory model. I was refactoring our internal representation in order to make load and store operations explicit and broke almost all of our tests at once. Fixing them was pretty easy, except for the smaller types... Section 12.1.2 states:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&amp;#x201e;Loading from 1- or 2-byte locations (arguments, locals, fields, statics, pointers) expands to 4-byte values.&amp;#x201c;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Ouch. We&amp;#x2019;ve gone through a lot of trouble to ensure correct arithmetics on all types and have been badly missing the point: All smaller integral types are handled at 4 bytes in size on the evaluation stack.&lt;br /&gt;&lt;br /&gt;Next step was to change the CIL load instructions to correctly reflect this fact and fortunately we already had the appropriate instructions in the IR. So the current state of work is that most of our tests are passing again, but not all yet. Then I started wondering about the floating point specification. Looking at the section for floating point values (12.1.3), it states:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&amp;#x201e;The supported storage sizes are float32 and float64. Everywhere else (on the evaluation stack, as arguments, as return types, and as local variables) floating-point numbers are represented using an internal floating-point type. In each such instance, the nominal type of the variable or expression is either float32or float64, but its value can be represented internally with additional range and/or precision. The size of the internal floating- point representation is implementation-dependent, can vary, and shall have precision at least as great as that of the variable or expression being represented. An implicit widening conversion to the internal representation from float32 or float64 is performed when those types are loaded from storage. The internal representation is typically the native size for the hardware, or as required for efficient implementation of an operation.&amp;#x201c;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;So for floating point types we have exactly one stack type F, but the implementation is free to choose the precision of its operations as long as it is at least as large as the storage size of the floating point type. Since we&amp;#x2019;ve spent a great deal of time on single precision arithmetics, I&amp;#x2019;m inclined to keep the reduced precision operations there. Any opinions?&lt;br /&gt;&lt;br /&gt;I&amp;#x2019;ll continue fixing this in the next couple of days.</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-6561668006461690892</guid>
         <pubDate>Mon, 05 Apr 2010 12:23:00 +0000</pubDate>
      </item>
      <item>
         <title>Michael: Why the Switch Fixture has crashed on I2/U2 and others...</title>
         <link>http://www.michaelruck.de/2010/04/why-switch-fixture-has-crashed-on-i2u2.html</link>
         <description>The tests are run by .NET calling through a function pointer delegate using the stdcall calling convention. This calling convention is similar to cdecl. One of the similarities is that the EBX register must be saved by the callee and restored before it returns to the caller. We didn&amp;#x2019;t do that and thus corrupted the state of the .NET runtime on Windows. Bug fixed and commit following soon.</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-1863326071199471714</guid>
         <pubDate>Sun, 04 Apr 2010 02:50:00 +0000</pubDate>
      </item>
      <item>
         <title>Michael: The next step: Virtual methods and method tables</title>
         <link>http://www.michaelruck.de/2010/03/next-step-virtual-methods-and-method.html</link>
         <description>After the static object allocation, I&amp;#x2019;ve finished the next step for MOSA. The compiler now emits mtable (virtual method tables) records for compiled types and is able to properly call virtual functions. The test to check these is in CallVirtFixture. I&amp;#x2019;ll add a couple more tests there to check for proper hiding, base class calls and other things - hopefully the current code should handle all of those cases sufficiently well.&lt;br /&gt;&lt;br /&gt;In order to accomplish this I&amp;#x2019;ve had to add a fake System.Object implementation to the existing tests, as those classes wouldn&amp;#x2019;t compile anymore - the linker couldn&amp;#x2019;t create the vtable for them due to the 4 virtual methods every object inherits from System.Object: ToString, GetHashCode, Equals and Finalize.&lt;br /&gt;&lt;br /&gt;The good thing about this is of course we can now use virtual functions and use overrides to do OO-kernels, the down side of course is: Every kernel has to provide at least a fake implementation of System.Object.&lt;br /&gt;&lt;br /&gt;I&amp;#x2019;ve added a fake System.Object to the existing HelloWorld kernel. &lt;br /&gt;&lt;br /&gt;Let&amp;#x2019;s see what Phil and Simon can come up with in Hello World, now that this is out of the way.</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-4573515164397375233</guid>
         <pubDate>Sat, 27 Mar 2010 21:05:00 +0000</pubDate>
      </item>
      <item>
         <title>Michael: Making good on a promise I've made a long time ago.</title>
         <link>http://www.michaelruck.de/2010/03/making-good-on-promise-i-made-long-time.html</link>
         <description>After improving our test situation on the weekend, I&amp;#x2019;ve started on making good a promise I&amp;#x2019;ve given a long time ago. The promise was: Allocate static objects at compile time for core kernel services.&lt;br /&gt;&lt;br /&gt;The issue with writing a managed operating system or any operating system is memory management and moving to the OS way of working at boot time. The core problem is that there are assumptions about objects, which can&amp;#x2019;t be met easily as memory management is being initialized on the CPU(s) the OS will run on. MOSA is facing this problem too, with one addition: Writing non-OO code in an OO language feels broken.&lt;br /&gt;&lt;br /&gt;Classical operating systems solve this by having a reduced set of services while booting and initializing the OS services later in the OS specific fashion. We could&amp;#x2019;ve done this too, but why go for common ground if there&amp;#x2019;s new to explore.&lt;br /&gt;&lt;br /&gt;So what does this feature do? This feature detects all dynamic memory allocations happening in static constructors and allocates memory for the allocated objects at compile time in the bss segment of an executable. It replaces the call to new with a load of the address of the data segment location, making the position of the object fixed in memory relative to its load address. This allows core OS services to be written using C# classes right from the start and allows them to be used as such.&lt;br /&gt;&lt;br /&gt;There are some limitations though: The allocated object must be fixed in size, it must not have a complex structure and the field used to store the object must have the exact same type as used for the new operator. No casts allowed.&lt;br /&gt;&lt;br /&gt;There&amp;#x2019;re probably further limits to this feature, but I haven&amp;#x2019;t figured them out yet. It will certainly be interesting to explore our HelloWorld kernel with OO-features using the new MOSA compiler.&lt;br /&gt;&lt;br /&gt;Oh and before I forget: The feature must be turned on explicitly on the command line. Use --enable-static-alloc (or the shorter --sa) to enable it.&lt;br /&gt;&lt;br /&gt;I&amp;#x2019;ve update the HelloWorld projects CMOS and Boot classes to take advantage of this mechanism.</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-7858614625910372428</guid>
         <pubDate>Mon, 15 Mar 2010 21:55:00 +0000</pubDate>
      </item>
      <item>
         <title>Michael: Changes I've made to MOSA to support generics, Part I</title>
         <link>http://www.michaelruck.de/2010/03/changes-i-made-to-mosa-to-support.html</link>
         <description>Over the past couple of days I&amp;#x2019;ve made changes to MOSA to support generics. The first and primary change was to support a scheduled compilation model.&lt;br /&gt;&lt;br /&gt;Let me explain this: Up to these changes the MOSA compiler would just scan an assembly, locate all types and compile each method contained in them. The only exceptions to this rule were native methods, generic types and generic methods.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;The revised compilation scheduler stage&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;However skipping generics doesn&amp;#x2019;t work anymore - you want those generic types and methods compiled too. The issue you face is how to compile these methods and types without knowing the usage. So I basically kept the current compilation scheduler, but added the capability for the pipeline to schedule additional types and methods in the scheduler. In order to do this, there&amp;#x2019;s a new assembly compilation stage: The ICompilationSchedulerStage. This stage performs the type lookups that used to be done by the MethodCompilerBuilderStage.&lt;br /&gt;&lt;br /&gt;The compilation scheduler now maintains a schedule of methods and types to compile and executes these in order. Once all scheduled methods and types are compiled, the entire assembly including all of its generic usages has been compiled.&lt;br /&gt;</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-3563059652124509024</guid>
         <pubDate>Thu, 11 Mar 2010 20:44:00 +0000</pubDate>
      </item>
      <item>
         <title>Michael: MOSA: Generic method compilation, first test succeeded</title>
         <link>http://www.michaelruck.de/2010/03/mosa-generic-method-compilation-first.html</link>
         <description>After about 3 hours patching and fixing the last issues I finally completed the first successful test of generics in MOSA. The following C# fragment compiles successfully and passes all tests:&lt;br /&gt;&lt;br /&gt;static class Test&lt;br /&gt;{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;private static T GenericMethod&amp;lt;T&amp;gt;(T value)&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;return value;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;br /&gt;&lt;br /&gt;         public static bool TestCallGenericMethodWith(int value)&lt;br /&gt;         {&lt;br /&gt;         &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;return value == GenericMethod(value);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;It may not look like much, but this test is the ground for all other generic arguments and has moved forward not only the compiler, but also the assembly loader, the MOSA runtime and some other additions like cleaner error messages from mosacl.&lt;br /&gt;&lt;br /&gt;I&amp;#x2019;ll finish this test case tomorrow and push my changes to Github, I&amp;#x2019;ll probably need some help with that from fellow MOSA contributors. &lt;br /&gt;&lt;br /&gt;Good night.</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-3497195645254494643</guid>
         <pubDate>Thu, 11 Mar 2010 03:01:00 +0000</pubDate>
      </item>
      <item>
         <title>Michael: Debug Symbols for MOSA #3 - Accessing PDB files</title>
         <link>http://www.michaelruck.de/2009/01/debug-symbols-for-mosa-3-accessing-pdb.html</link>
         <description>&lt;p&gt;In the last post, I wrote about the &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.michaelruck.de/2009/01/debug-symbols-for-mosa-2-debug-symbol.html&quot;&gt;debug symbol formats&lt;/a&gt; used by Microsoft in recent years. This post is dedicated to tell you, where to look about accessing these files using official APIs. If the world consisted only of Windows, we could stop here. We wouldn't need to understand the file format itself or be able to read the files without the APIs described below. However the world isn't living in monoculture so I'll keep my goal to describe the PDB format in the next posts.&lt;/p&gt;&lt;p&gt;Essentially Microsoft only makes four APIs available to access debugging symbols:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/ms680321(VS.85).aspx&quot;&gt;Image Helper Library&lt;/a&gt; (included with Windows, not redistributable) &lt;/li&gt;&lt;li&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/ms679309%28VS.85%29.aspx&quot;&gt;Debug Help Library&lt;/a&gt; (included with Windows, redistributable, updated versions in the &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.microsoft.com/whdc/devtools/debugging/default.mspx&quot;&gt;Debugging Tools for Windows&lt;/a&gt;) &lt;/li&gt;&lt;li&gt;&lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/x93ctkx8%28VS.80%29.aspx&quot;&gt;Debug Interface Access SDK&lt;/a&gt; (included with Visual Studio) &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;and the only remaining API is in the .NET &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/system.diagnostics.symbolstore%28VS.71%29.aspx&quot;&gt;System.Diagnostics.SymbolStore&lt;/a&gt; namespace in mscorlib.&lt;/p&gt;&lt;p&gt;Of all of these APIs the Image Helper Library provides the most features, followed by the Debug Help Library. The later is used by the Microsoft Debuggers to load symbol information. While both of these libraries are regular Win32 DLLs with WINAPI entry points, the Debug Interface Access SDK provides COM objects to access the contents of symbol files. The library is very easy to work with.&lt;/p&gt;&lt;p&gt;As one can easily see these three options don't work outside the Microsoft world, well they don't except for maybe Wine or ReactOS. My first hope was that using the System.Diagnostics.SymbolStore namespace would be sufficient for our purpose of retrieving the symbol information, but again this quickly makes the code a Windows only option.&lt;/p&gt;&lt;p&gt;From &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://blogs.msdn.com/jmstall&quot;&gt;Mike Stall's .NET Debugging Blog&lt;/a&gt;, I've taken the following snippet from the &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://blogs.msdn.com/jmstall/pages/sample-pdb2xml.aspx&quot;&gt;sample code of PDB2XML&lt;/a&gt; tool - a tool, which uses ISymbolReader to read a PDB file and writes it in an XML file.&lt;/p&gt;&lt;pre&gt;&lt;span style=&quot;color:#008000;&quot;&gt;        // We demand Unmanaged code permissions because we're reading from the file system and calling out to the Symbol Reader&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// @TODO - make this more specific.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;        [System.Security.Permissions.&lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;SecurityPermission&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;(System.Security.Permissions.&lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;SecurityAction&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;.Demand,&lt;br /&gt;            Flags = System.Security.Permissions.&lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;SecurityPermissionFlag&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;.UnmanagedCode)]&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;ISymbolReader&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; GetSymbolReaderForFile(&lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;SymbolBinder&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; binder, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; pathModule, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; searchPath)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// Guids for imported metadata interfaces.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Guid&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; dispenserClassID = &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Guid&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;(0xe5cb7a31, 0x7512, 0x11d2, 0x89, 0xce, 0x00, 0x80, 0xc7, 0x92, 0xe5, 0xd8); &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// CLSID_CorMetaDataDispenser&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Guid&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; dispenserIID = &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Guid&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;(0x809c652e, 0x7396, 0x11d2, 0x97, 0x71, 0x00, 0xa0, 0xc9, 0xb4, 0xd5, 0x0c); &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// IID_IMetaDataDispenser&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Guid&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; importerIID = &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Guid&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;(0x7dac8207, 0xd3ae, 0x4c75, 0x9b, 0x67, 0x92, 0x80, 0x1a, 0x49, 0x7d, 0x44); &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// IID_IMetaDataImport&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// First create the Metadata dispenser.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; objDispenser;&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;NativeMethods&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;.CoCreateInstance(&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ref&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; dispenserClassID, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;, 1, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ref&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; dispenserIID, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; objDispenser);&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// Now open an Importer on the given filename. We'll end up passing this importer straight&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// through to the Binder.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; objImporter;&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;IMetaDataDispenser&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; dispenser = (&lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;IMetaDataDispenser&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;)objDispenser;&lt;br /&gt;            dispenser.OpenScope(pathModule, 0, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ref&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; importerIID, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; objImporter);&lt;br /&gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;IntPtr&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; importerPtr = &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;IntPtr&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;.Zero;&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;ISymbolReader&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; reader;&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;try&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style=&quot;color:#008000;&quot;&gt;// This will manually AddRef the underlying object, so we need to be very careful to Release it.&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;                importerPtr = &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Marshal&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;.GetComInterfaceForObject(objImporter, &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;typeof&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;IMetadataImport&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;));&lt;br /&gt;&lt;br /&gt;                reader = binder.GetReader(importerPtr, pathModule, searchPath);&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;finally&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; (importerPtr != &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;IntPtr&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;.Zero)&lt;br /&gt;                {&lt;br /&gt;                    &lt;/span&gt;&lt;span style=&quot;color:#008080;&quot;&gt;Marshal&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt;.Release(importerPtr);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color:#000000;&quot;&gt; reader;&lt;br /&gt;        }&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Ouch, that was a lot of code just to get the symbol reader - but wait a minute, what are the Guids doing there and the CoCreateInstance call? This screams trouble for cross platform code... It turns out that &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/system.diagnostics.symbolstore.isymbolreader.aspx&quot;&gt;ISymbolReader&lt;/a&gt; is not useful without an object, which implements the &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/ms230172.aspx&quot;&gt;IMetadataImport&lt;/a&gt; interface. This is a COM interface implemented by mscoree.dll, the Microsoft .NET Runtime Execution Engine. And you can't get an ISymbolReader without a &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/system.diagnostics.symbolstore.symbinder.aspx&quot;&gt;SymBinder&lt;/a&gt;, which is not even defined in the namespace. These GUIDs and the COM classes are defined in ISymWrapper.dll, a COM interop assembly.&lt;/p&gt;&lt;p&gt;But not enough, the &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/system.diagnostics.symbolstore.isymbolbinder1.aspx&quot;&gt;ISymbolBinder1&lt;/a&gt; (don't ask, look up &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://msdn.microsoft.com/en-us/library/system.diagnostics.symbolstore.isymbolbinder.aspx&quot;&gt;ISymbolBinder&lt;/a&gt; and ISymbolBinder1 and figure out the reason for ISymbolBinder1) interface uses an IntPtr to access this IMetadataImport interface. Essentially you're passing a COM interface in an unmanaged pointer (or native int in CIL speak) to another unmanaged COM object.&lt;/p&gt;&lt;p&gt;Somehow this is messed up. Really messed up. It looks like symbol information was an afterthought in the development of .NET and hasn't received any priority ever since .NET 1.0 - this mess has been this way since .NET 1.0 was released. I hope that things get better with .NET 4.0, but for some reason I doubt that.&lt;/p&gt;&lt;p&gt;Now we've collected lots of unusable APIs and we still can't read those PDB files anywhere outside of Windows. However this gives us something else: All of those APIs have documented some structures to pass symbol information to the calling application. These structures are very likely to be similar to what is stored on disk - at least these APIs give us some hints that the format is more complex than one might think. And finally the .NET namespace gives us some design guidelines to realize a PDB reader/writer using plain .NET.&lt;/p&gt;&lt;p&gt;More in the next post.&lt;/p&gt;</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-1455587601268712105</guid>
         <pubDate>Fri, 16 Jan 2009 02:14:00 +0000</pubDate>
      </item>
      <item>
         <title>Michael: Debug Symbols for MOSA #2 - Debug Symbol Formats</title>
         <link>http://www.michaelruck.de/2009/01/debug-symbols-for-mosa-2-debug-symbol.html</link>
         <description>This continues the series of Debug Symbols for MOSA, started in &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.michaelruck.de/2009/01/debug-symbols-for-mosa-1-why-we-need.html&quot;&gt;Why we need them&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;As the title says, there's a multitude of debug symbol formats out there. It usually depends on the operating system, the compiler, compiler switches and linker of choice what kind of symbols are emitted or even worse if any at all. I'm only going to talk about the Microsoft formats, as these are the ones I've actively been working with.&lt;br /&gt;&lt;br /&gt;Microsoft has created a multitude of symbol formats in the past, where even PDB files exist in multiple formats. This post sheds some light, which debug symbols are out there.&lt;br /&gt;&lt;br /&gt;The general history for Microsoft Symbol Formats is that there are mainly three kinds:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Pre-CodeView&lt;/li&gt;&lt;li&gt;CodeView&lt;/li&gt;&lt;li&gt;PDB&lt;/li&gt;&lt;/ul&gt;I will not dive into the Pre-CodeView era mainly because I don't have much knowledge about it.&lt;br /&gt;&lt;br /&gt;So why does Microsoft change the symbol format all the time? The &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://blogs.msdn.com/matt_pietrek/archive/2005/02/05/367836.aspx&quot;&gt;answer&lt;/a&gt; was given by Matt Pietrek. As the compilers and debuggers advanced more information was stored in the file. Some changes were performed due to the 16-&amp;gt;32 bit transition, but most changes can be attributed to advances in the debugger. Edit and Continue is an example of this.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;CodeView&lt;span style=&quot;font-weight:bold;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;CodeView is format developed by Microsoft sometime along with the CodeView debugger, which was later integrated into the Microsoft C to become the Visual Studio we know today. There are several revisions of CodeView, which adopt the format to the specific compiler version in use.&lt;br /&gt;&lt;br /&gt;There's even a public specification for the CodeView format available various &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.google.de/search?q=Microsoft+Symbol+and+Type+Information&quot;&gt;places on the internet&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The CodeView format was stored in various containers (files) over the years, namely the *.dbg files upto Windows 2000 and it is still in use today in the *.pdb files emitted by Visual Studio compilers since around 1997 and more importantly for MOSA: It is also emitted by the .NET compilers.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;PDB&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PDB files are in use for quite some time now, but even this file format has went through at least three transitions. There's at least one format for managed symbols produced by csc, vbc and the other .NET compilers - yes another format. Again.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;CILDB&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Microsoft has submitted the Common Language Infrastructure to the ECMA for standardization. The latest standardized edition I'm aware of is  ISO/IEC 23271, published on 2006-10-01. Partition V of this standardization defines a Debug Interchange Format, specifically called CILDB. The specification is available for &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.ecma-international.org/publications/standards/Ecma-335.htm&quot;&gt;download&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The specification introduction says this:&lt;br /&gt;&lt;blockquote&gt;Portable CILDB files provide a standard way to interchange debugging information between CLI producers and consumers. This partition serves to fill in gaps not covered by metadata, notably the names of local variables and source line correspondences.&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Even though Microsoft has pushed this format as part of the specification, no Microsoft tool included with the .NET Framework SDK, the Framework itself or Visual Studio is able to generate or consume these files. So the interchange aspect of this standard is not realized. There are both open and closed source apps, that are able to convert Microsoft PDB files to CILDB - all with a drawback I'll talk about in the next post.&lt;br /&gt;&lt;br /&gt;More in the next post. However one last format for managed code remains:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;MDB&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the mono debug format - it is used by mdb and MonoDevelop. There's integrated support in mono using a SymbolWriter/SymbolReader to produce and consume these files from managed code. Talk about fun!&lt;br /&gt;&lt;br /&gt;The MDB option is definitely one we should follow to debug applications on MOSA, but it is not one we are able to use for kernel debugging or debugging native code.&lt;br /&gt;&lt;br /&gt;Basically this means that mosacl (our ahead of time compiler) must be able to read PDB, MDB and CILDB files in order to map the source code to appropriate places in the native code. Again - more in another post.</description>
         <author>Michael</author>
         <guid isPermaLink="false">tag:blogger.com,1999:blog-6043482.post-4213120108239773981</guid>
         <pubDate>Thu, 15 Jan 2009 14:16:00 +0000</pubDate>
      </item>
   </channel>
</rss>
<!-- fe3.yql.bf1.yahoo.com compressed/chunked Thu Oct  1 11:36:57 UTC 2015 -->
