<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Tutorial</title><link>https://sourceforge.net/p/peter-dwarf/wiki/Tutorial/</link><description>Recent changes to Tutorial</description><atom:link href="https://sourceforge.net/p/peter-dwarf/wiki/Tutorial/feed" rel="self"/><language>en</language><lastBuildDate>Sun, 15 Mar 2015 09:39:16 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/peter-dwarf/wiki/Tutorial/feed" rel="self" type="application/rss+xml"/><item><title>Tutorial modified by Peter</title><link>https://sourceforge.net/p/peter-dwarf/wiki/Tutorial/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,137 +1,137 @@
 A Java library to read dwarf
 It is a java version of libdwarf, if you want to read out information from dwarf. please use it.

-!!! Please always use the latest code from SVN, rather than download the jar
-
 Usage :

-~~~~~
-final Vector&amp;lt;Dwarf&amp;gt; dwarfVector = DwarfLib.init(file, meoryOffset);
-~~~~~
+    :::java
+    final Vector&amp;lt;Dwarf&amp;gt; dwarfVector = DwarfLib.init(file, meoryOffset);
+
 All dwarf information will be in dwarfVector

 To add a JPanel to display dwarf information :

-~~~~~
-PeterDwarfPanel peterDwarfPanel1 = new PeterDwarfPanel();
-File file = new File("/Users/peter/workspace/PeterI/kernel/kernel");
-peterDwarfPanel1.init(file.getAbsolutePath());
+    :::java
+    PeterDwarfPanel peterDwarfPanel1 = new PeterDwarfPanel();
+    File file = new File("/Users/peter/workspace/PeterI/kernel/kernel");
+    peterDwarfPanel1.init(file.getAbsolutePath());
+
+
 Then just add peterDwarfPanel1 to any swing container.
-~~~~~

 contact : mcheung63@hotmail.com, my name is Peter

 full example:
-~~~~~
-package com.peterdwarf;

-import java.io.File;
-import java.util.Enumeration;
-import java.util.Vector;

-import com.peterdwarf.dwarf.CompileUnit;
-import com.peterdwarf.dwarf.DebugInfoAbbrevEntry;
-import com.peterdwarf.dwarf.DebugInfoEntry;
-import com.peterdwarf.dwarf.Dwarf;
-import com.peterdwarf.dwarf.DwarfDebugLineHeader;
-import com.peterdwarf.dwarf.DwarfHeaderFilename;
-import com.peterdwarf.dwarf.DwarfLib;
-import com.peterdwarf.dwarf.DwarfLine;
-
-public class TestPeterDwarf {
-﻿  public static void main(String[] args) {
-﻿  ﻿  if (args.length == 0) {
-﻿  ﻿  ﻿  System.out.println("java -jar peter-dwarf.jar &amp;lt;your elf="" file="" path=""&amp;gt;");
-﻿  ﻿  ﻿  System.exit(6);
-﻿  ﻿  }
-
-﻿  ﻿  for (String str : args) {
-﻿  ﻿  ﻿  if (str.contains("-debug")) {
-﻿  ﻿  ﻿  ﻿  DwarfGlobal.debug = true;
-﻿  ﻿  ﻿  }
-﻿  ﻿  }
-
-﻿  ﻿  Dwarf dwarf = new Dwarf();
-﻿  ﻿  File file = new File(args[0]);
-
-﻿  ﻿  if (file.isDirectory()) {
-﻿  ﻿  ﻿  return;
-﻿  ﻿  }
-
-﻿  ﻿  Vector&amp;lt;Dwarf&amp;gt; dwarfLib = DwarfLib.init(file, 0);
-﻿  ﻿  if (dwarfLib == null) {
-﻿  ﻿  ﻿  System.err.println("dwarf init fail");
-﻿  ﻿  ﻿  //$hide&amp;gt;&amp;gt;$
-﻿  ﻿  ﻿  System.exit(1);
-﻿  ﻿  ﻿  //$hide&amp;lt;&amp;lt;$
-﻿  ﻿  } else if (DwarfGlobal.debug) {
-﻿  ﻿  ﻿  System.out.println(".debug_info:");
-﻿  ﻿  ﻿  for (CompileUnit compileUnit : dwarf.compileUnits) {
-﻿  ﻿  ﻿  ﻿  System.out.printf("Compilation Unit @ offset 0x%x\n", compileUnit.offset);
-﻿  ﻿  ﻿  ﻿  System.out.printf("Length: 0x%x\n", compileUnit.length);
-﻿  ﻿  ﻿  ﻿  System.out.println("Version: " + compileUnit.version);
-﻿  ﻿  ﻿  ﻿  System.out.printf("Abbrev Offset: 0x%x\n", compileUnit.offset);
-﻿  ﻿  ﻿  ﻿  System.out.println("Pointer Size: " + compileUnit.addr_size);
-
-﻿  ﻿  ﻿  ﻿  for (DebugInfoEntry debugInfoEntry : compileUnit.debugInfoEntries) {
-﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("&amp;lt;" + debugInfoEntry.position + "&amp;gt; Abbrev Number: " + debugInfoEntry.abbrevNo + " (" + debugInfoEntry.name + ")");
-
-﻿  ﻿  ﻿  ﻿  ﻿  Enumeration&amp;lt;String&amp;gt; e = debugInfoEntry.debugInfoAbbrevEntries.keys();
-﻿  ﻿  ﻿  ﻿  ﻿  while (e.hasMoreElements()) {
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  String key = e.nextElement();
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  DebugInfoAbbrevEntry debugInfoAbbrevEntry = debugInfoEntry.debugInfoAbbrevEntries.get(key);
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  if (debugInfoAbbrevEntry.value == null) {
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\tnull\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name);
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof String) {
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t%s\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name, debugInfoAbbrevEntry.value);
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof Byte || debugInfoAbbrevEntry.value instanceof Integer || debugInfoAbbrevEntry.value instanceof Long) {
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t%x\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name, debugInfoAbbrevEntry.value);
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof byte[]) {
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  byte[] bytes = (byte[]) debugInfoAbbrevEntry.value;
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name);
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  for (byte b : bytes) {
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("%x ", b);
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  }
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println();
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else {
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("not support value format : " + debugInfoAbbrevEntry.value.getClass().toString());
-﻿  ﻿  ﻿  ﻿  ﻿  ﻿  }
-﻿  ﻿  ﻿  ﻿  ﻿  }
-﻿  ﻿  ﻿  ﻿  }
-﻿  ﻿  ﻿  }
-
-﻿  ﻿  ﻿  System.out.println();
-
-﻿  ﻿  ﻿  for (DwarfDebugLineHeader header : dwarf.headers) {
-﻿  ﻿  ﻿  ﻿  System.out.println();
-﻿  ﻿  ﻿  ﻿  System.out.println(header);
-﻿  ﻿  ﻿  ﻿  System.out.println();
-
-﻿  ﻿  ﻿  ﻿  System.out.println("dirnames:");
-﻿  ﻿  ﻿  ﻿  for (String s : header.dirnames) {
-﻿  ﻿  ﻿  ﻿  ﻿  System.out.println(s);
-﻿  ﻿  ﻿  ﻿  }
-﻿  ﻿  ﻿  ﻿  System.out.println();
-
-﻿  ﻿  ﻿  ﻿  System.out.println("entry\tdir\ttime\tlen\tfilename");
-﻿  ﻿  ﻿  ﻿  for (DwarfHeaderFilename filename : header.filenames) {
-﻿  ﻿  ﻿  ﻿  ﻿  System.out.println(filename.entryNo + "\t" + filename.dir + "\t" + filename.time + "\t" + filename.len + "\t" + filename.file.getAbsolutePath());
-﻿  ﻿  ﻿  ﻿  }
-﻿  ﻿  ﻿  ﻿  System.out.println();
-
-﻿  ﻿  ﻿  ﻿  System.out.println("address\tfile no.\tline no.\tcolumn no.\taddress");
-
-﻿  ﻿  ﻿  ﻿  for (DwarfLine line : header.lines) {
-﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("\t" + line.file_num + "\t\t" + line.line_num + "\t\t" + line.column_num + "\t\t" + line.address.toString(16));
-﻿  ﻿  ﻿  ﻿  }
-﻿  ﻿  ﻿  ﻿  System.out.println();
-﻿  ﻿  ﻿  ﻿  System.out.println();
-﻿  ﻿  ﻿  }
-
-﻿  ﻿  }
-﻿  ﻿  // DwarfLib.printMappedByteBuffer(dwarf.byteBuffer);
-
-﻿  ﻿  // dwarf.printHeader();
-﻿  }
-}
-~~~~~
+    :::java
+    package com.peterdwarf;
+    
+    import java.io.File;
+    import java.util.Enumeration;
+    import java.util.Vector;
+    
+    import com.peterdwarf.dwarf.CompileUnit;
+    import com.peterdwarf.dwarf.DebugInfoAbbrevEntry;
+    import com.peterdwarf.dwarf.DebugInfoEntry;
+    import com.peterdwarf.dwarf.Dwarf;
+    import com.peterdwarf.dwarf.DwarfDebugLineHeader;
+    import com.peterdwarf.dwarf.DwarfHeaderFilename;
+    import com.peterdwarf.dwarf.DwarfLib;
+    import com.peterdwarf.dwarf.DwarfLine;
+    
+    public class TestPeterDwarf {
+    ﻿  public static void main(String[] args) {
+    ﻿  ﻿  if (args.length == 0) {
+    ﻿  ﻿  ﻿  System.out.println("java -jar peter-dwarf.jar &amp;lt;your elf="" file="" path=""&amp;gt;");
+    ﻿  ﻿  ﻿  System.exit(6);
+    ﻿  ﻿  }
+    
+    ﻿  ﻿  for (String str : args) {
+    ﻿  ﻿  ﻿  if (str.contains("-debug")) {
+    ﻿  ﻿  ﻿  ﻿  DwarfGlobal.debug = true;
+    ﻿  ﻿  ﻿  }
+    ﻿  ﻿  }
+    
+    ﻿  ﻿  Dwarf dwarf = new Dwarf();
+    ﻿  ﻿  File file = new File(args[0]);
+    
+    ﻿  ﻿  if (file.isDirectory()) {
+    ﻿  ﻿  ﻿  return;
+    ﻿  ﻿  }
+    
+    ﻿  ﻿  Vector&amp;lt;Dwarf&amp;gt; dwarfLib = DwarfLib.init(file, 0);
+    ﻿  ﻿  if (dwarfLib == null) {
+    ﻿  ﻿  ﻿  System.err.println("dwarf init fail");
+    ﻿  ﻿  ﻿  //$hide&amp;gt;&amp;gt;$
+    ﻿  ﻿  ﻿  System.exit(1);
+    ﻿  ﻿  ﻿  //$hide&amp;lt;&amp;lt;$
+    ﻿  ﻿  } else if (DwarfGlobal.debug) {
+    ﻿  ﻿  ﻿  System.out.println(".debug_info:");
+    ﻿  ﻿  ﻿  for (CompileUnit compileUnit : dwarf.compileUnits) {
+    ﻿  ﻿  ﻿  ﻿  System.out.printf("Compilation Unit @ offset 0x%x\n", compileUnit.offset);
+    ﻿  ﻿  ﻿  ﻿  System.out.printf("Length: 0x%x\n", compileUnit.length);
+    ﻿  ﻿  ﻿  ﻿  System.out.println("Version: " + compileUnit.version);
+    ﻿  ﻿  ﻿  ﻿  System.out.printf("Abbrev Offset: 0x%x\n", compileUnit.offset);
+    ﻿  ﻿  ﻿  ﻿  System.out.println("Pointer Size: " + compileUnit.addr_size);
+    
+    ﻿  ﻿  ﻿  ﻿  for (DebugInfoEntry debugInfoEntry : compileUnit.debugInfoEntries) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("&amp;lt;" + debugInfoEntry.position + "&amp;gt; Abbrev Number: " + debugInfoEntry.abbrevNo + " (" + debugInfoEntry.name + ")");
+    
+    ﻿  ﻿  ﻿  ﻿  ﻿  Enumeration&amp;lt;String&amp;gt; e = debugInfoEntry.debugInfoAbbrevEntries.keys();
+    ﻿  ﻿  ﻿  ﻿  ﻿  while (e.hasMoreElements()) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  String key = e.nextElement();
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  DebugInfoAbbrevEntry debugInfoAbbrevEntry = debugInfoEntry.debugInfoAbbrevEntries.get(key);
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  if (debugInfoAbbrevEntry.value == null) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\tnull\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name);
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof String) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t%s\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name, debugInfoAbbrevEntry.value);
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof Byte || debugInfoAbbrevEntry.value instanceof Integer || debugInfoAbbrevEntry.value instanceof Long) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t%x\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name, debugInfoAbbrevEntry.value);
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof byte[]) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  byte[] bytes = (byte[]) debugInfoAbbrevEntry.value;
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name);
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  for (byte b : bytes) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("%x ", b);
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  }
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println();
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else {
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("not support value format : " + debugInfoAbbrevEntry.value.getClass().toString());
+    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  }
+    ﻿  ﻿  ﻿  ﻿  ﻿  }
+    ﻿  ﻿  ﻿  ﻿  }
+    ﻿  ﻿  ﻿  }
+    
+    ﻿  ﻿  ﻿  System.out.println();
+    
+    ﻿  ﻿  ﻿  for (DwarfDebugLineHeader header : dwarf.headers) {
+    ﻿  ﻿  ﻿  ﻿  System.out.println();
+    ﻿  ﻿  ﻿  ﻿  System.out.println(header);
+    ﻿  ﻿  ﻿  ﻿  System.out.println();
+    
+    ﻿  ﻿  ﻿  ﻿  System.out.println("dirnames:");
+    ﻿  ﻿  ﻿  ﻿  for (String s : header.dirnames) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println(s);
+    ﻿  ﻿  ﻿  ﻿  }
+    ﻿  ﻿  ﻿  ﻿  System.out.println();
+    
+    ﻿  ﻿  ﻿  ﻿  System.out.println("entry\tdir\ttime\tlen\tfilename");
+    ﻿  ﻿  ﻿  ﻿  for (DwarfHeaderFilename filename : header.filenames) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println(filename.entryNo + "\t" + filename.dir + "\t" + filename.time + "\t" + filename.len + "\t" + filename.file.getAbsolutePath());
+    ﻿  ﻿  ﻿  ﻿  }
+    ﻿  ﻿  ﻿  ﻿  System.out.println();
+    
+    ﻿  ﻿  ﻿  ﻿  System.out.println("address\tfile no.\tline no.\tcolumn no.\taddress");
+    
+    ﻿  ﻿  ﻿  ﻿  for (DwarfLine line : header.lines) {
+    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("\t" + line.file_num + "\t\t" + line.line_num + "\t\t" + line.column_num + "\t\t" + line.address.toString(16));
+    ﻿  ﻿  ﻿  ﻿  }
+    ﻿  ﻿  ﻿  ﻿  System.out.println();
+    ﻿  ﻿  ﻿  ﻿  System.out.println();
+    ﻿  ﻿  ﻿  }
+    
+    ﻿  ﻿  }
+    ﻿  ﻿  // DwarfLib.printMappedByteBuffer(dwarf.byteBuffer);
+    
+    ﻿  ﻿  // dwarf.printHeader();
+    ﻿  }
+    }
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter</dc:creator><pubDate>Sun, 15 Mar 2015 09:39:16 -0000</pubDate><guid>https://sourceforge.net294f45cf36d0f1386b732121df699f657c196e67</guid></item><item><title>Tutorial modified by Peter</title><link>https://sourceforge.net/p/peter-dwarf/wiki/Tutorial/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;A Java library to read dwarf&lt;br /&gt;
It is a java version of libdwarf, if you want to read out information from dwarf. please use it.&lt;/p&gt;
&lt;p&gt;!!! Please always use the latest code from SVN, rather than download the jar&lt;/p&gt;
&lt;p&gt;Usage :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="nx"&gt;final&lt;/span&gt; &lt;span class="nx"&gt;Vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Dwarf&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;dwarfVector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DwarfLib.init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;meoryOffset&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;All dwarf information will be in dwarfVector&lt;/p&gt;
&lt;p&gt;To add a JPanel to display dwarf information :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;PeterDwarfPanel&lt;/span&gt; &lt;span class="n"&gt;peterDwarfPanel1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;PeterDwarfPanel&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;File&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/Users/peter/workspace/PeterI/kernel/kernel"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;peterDwarfPanel1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getAbsolutePath&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;Then&lt;/span&gt; &lt;span class="n"&gt;just&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;peterDwarfPanel1&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;any&lt;/span&gt; &lt;span class="n"&gt;swing&lt;/span&gt; &lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;contact : mcheung63@hotmail.com, my name is Peter&lt;/p&gt;
&lt;p&gt;full example:&lt;br /&gt;
    package com.peterdwarf;&lt;br /&gt;
&lt;br /&gt;
    import java.io.File;&lt;br /&gt;
    import java.util.Enumeration;&lt;br /&gt;
    import java.util.Vector;&lt;br /&gt;
&lt;br /&gt;
    import com.peterdwarf.dwarf.CompileUnit;&lt;br /&gt;
    import com.peterdwarf.dwarf.DebugInfoAbbrevEntry;&lt;br /&gt;
    import com.peterdwarf.dwarf.DebugInfoEntry;&lt;br /&gt;
    import com.peterdwarf.dwarf.Dwarf;&lt;br /&gt;
    import com.peterdwarf.dwarf.DwarfDebugLineHeader;&lt;br /&gt;
    import com.peterdwarf.dwarf.DwarfHeaderFilename;&lt;br /&gt;
    import com.peterdwarf.dwarf.DwarfLib;&lt;br /&gt;
    import com.peterdwarf.dwarf.DwarfLine;&lt;br /&gt;
&lt;br /&gt;
    public class TestPeterDwarf {&lt;br /&gt;
    ﻿  public static void main(String[] args) {&lt;br /&gt;
    ﻿  ﻿  if (args.length == 0) {&lt;br /&gt;
    ﻿  ﻿  ﻿  System.out.println("java -jar peter-dwarf.jar &amp;lt;your elf="" file="" path=""&amp;gt;");&lt;br /&gt;
    ﻿  ﻿  ﻿  System.exit(6);&lt;br /&gt;
    ﻿  ﻿  }&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  for (String str : args) {&lt;br /&gt;
    ﻿  ﻿  ﻿  if (str.contains("-debug")) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  DwarfGlobal.debug = true;&lt;br /&gt;
    ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  }&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  Dwarf dwarf = new Dwarf();&lt;br /&gt;
    ﻿  ﻿  File file = new File(args&lt;span&gt;[0]&lt;/span&gt;);&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  if (file.isDirectory()) {&lt;br /&gt;
    ﻿  ﻿  ﻿  return;&lt;br /&gt;
    ﻿  ﻿  }&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  Vector&amp;lt;Dwarf&amp;gt; dwarfLib = DwarfLib.init(file, 0);&lt;br /&gt;
    ﻿  ﻿  if (dwarfLib == null) {&lt;br /&gt;
    ﻿  ﻿  ﻿  System.err.println("dwarf init fail");&lt;br /&gt;
    ﻿  ﻿  ﻿  //$hide&amp;gt;&amp;gt;$&lt;br /&gt;
    ﻿  ﻿  ﻿  System.exit(1);&lt;br /&gt;
    ﻿  ﻿  ﻿  //$hide&amp;lt;&amp;lt;$&lt;br /&gt;
    ﻿  ﻿  } else if (DwarfGlobal.debug) {&lt;br /&gt;
    ﻿  ﻿  ﻿  System.out.println(".debug_info:");&lt;br /&gt;
    ﻿  ﻿  ﻿  for (CompileUnit compileUnit : dwarf.compileUnits) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.printf("Compilation Unit @ offset 0x%x\n", compileUnit.offset);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.printf("Length: 0x%x\n", compileUnit.length);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println("Version: " + compileUnit.version);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.printf("Abbrev Offset: 0x%x\n", compileUnit.offset);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println("Pointer Size: " + compileUnit.addr_size);&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  for (DebugInfoEntry debugInfoEntry : compileUnit.debugInfoEntries) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("&amp;lt;" + debugInfoEntry.position + "&amp;gt; Abbrev Number: " + debugInfoEntry.abbrevNo + " (" + debugInfoEntry.name + ")");&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  Enumeration&amp;lt;String&amp;gt; e = debugInfoEntry.debugInfoAbbrevEntries.keys();&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  while (e.hasMoreElements()) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  String key = e.nextElement();&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  DebugInfoAbbrevEntry debugInfoAbbrevEntry = debugInfoEntry.debugInfoAbbrevEntries.get(key);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  if (debugInfoAbbrevEntry.value == null) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\tnull\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof String) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t%s\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name, debugInfoAbbrevEntry.value);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof Byte || debugInfoAbbrevEntry.value instanceof Integer || debugInfoAbbrevEntry.value instanceof Long) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t%x\n", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name, debugInfoAbbrevEntry.value);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else if (debugInfoAbbrevEntry.value instanceof byte[]) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  byte[] bytes = (byte[]) debugInfoAbbrevEntry.value;&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("&amp;lt;%x&amp;gt;\t%s\t", debugInfoAbbrevEntry.position, debugInfoAbbrevEntry.name);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  for (byte b : bytes) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.printf("%x ", b);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  } else {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("not support value format : " + debugInfoAbbrevEntry.value.getClass().toString());&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  ﻿  }&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  for (DwarfDebugLineHeader header : dwarf.headers) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println(header);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println("dirnames:");&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  for (String s : header.dirnames) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println(s);&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println("entry\tdir\ttime\tlen\tfilename");&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  for (DwarfHeaderFilename filename : header.filenames) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println(filename.entryNo + "\t" + filename.dir + "\t" + filename.time + "\t" + filename.len + "\t" + filename.file.getAbsolutePath());&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println("address\tfile no.\tline no.\tcolumn no.\taddress");&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  for (DwarfLine line : header.lines) {&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  ﻿  System.out.println("\t" + line.file_num + "\t\t" + line.line_num + "\t\t" + line.column_num + "\t\t" + line.address.toString(16));&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
    ﻿  ﻿  ﻿  ﻿  System.out.println();&lt;br /&gt;
    ﻿  ﻿  ﻿  }&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  }&lt;br /&gt;
    ﻿  ﻿  // DwarfLib.printMappedByteBuffer(dwarf.byteBuffer);&lt;br /&gt;
&lt;br /&gt;
    ﻿  ﻿  // dwarf.printHeader();&lt;br /&gt;
    ﻿  }&lt;br /&gt;
    }&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Peter</dc:creator><pubDate>Sun, 15 Mar 2015 09:33:29 -0000</pubDate><guid>https://sourceforge.netdb13f56463dbc59d033f9d871939994c682a1549</guid></item></channel></rss>