Author: toshok
Date: 2005-04-11 19:53:08 -0400 (Mon, 11 Apr 2005)
New Revision: 42812
Added:
trunk/debugger/classes/TargetBinaryAccess.cs
Modified:
trunk/debugger/ChangeLog
trunk/debugger/classes/TargetBinaryReader.cs
trunk/debugger/classes/TargetBinaryWriter.cs
Log:
2005-04-11 Chris Toshok <[EMAIL PROTECTED]>
* classes/TargetBinaryAccess.cs: new file, move the base class
stuff out of TargetBinaryReader here, as well as TargetBlob.
* classes/TargetBinaryReader.cs: inherit from TargetBinaryAccess.
* classes/TargetBinaryWriter.cs: same. stop inheriting from
Reader.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2005-04-11 22:00:04 UTC (rev 42811)
+++ trunk/debugger/ChangeLog 2005-04-11 23:53:08 UTC (rev 42812)
@@ -1,5 +1,15 @@
2005-04-11 Chris Toshok <[EMAIL PROTECTED]>
+ * classes/TargetBinaryAccess.cs: new file, move the base class
+ stuff out of TargetBinaryReader here, as well as TargetBlob.
+
+ * classes/TargetBinaryReader.cs: inherit from TargetBinaryAccess.
+
+ * classes/TargetBinaryWriter.cs: same. stop inheriting from
+ Reader.
+
+2005-04-11 Chris Toshok <[EMAIL PROTECTED]>
+
* frontend/Expression.cs: clean up warnings.
* frontend/CSharpTokenizer.cs: same.
Added: trunk/debugger/classes/TargetBinaryAccess.cs
===================================================================
--- trunk/debugger/classes/TargetBinaryAccess.cs 2005-04-11 22:00:04 UTC
(rev 42811)
+++ trunk/debugger/classes/TargetBinaryAccess.cs 2005-04-11 23:53:08 UTC
(rev 42812)
@@ -0,0 +1,139 @@
+using System;
+using System.Text;
+
+namespace Mono.Debugger
+{
+
+ public sealed class TargetBlob
+ {
+ public readonly byte[] Contents;
+
+ public TargetBlob (byte[] contents)
+ {
+ this.Contents = contents;
+ }
+
+ public TargetBlob (int size)
+ {
+ this.Contents = new byte [size];
+ }
+
+ public int Size {
+ get { return Contents.Length; }
+ }
+ }
+
+
+ public class TargetBinaryAccess
+ {
+ protected ITargetInfo target_info;
+ protected TargetBlob blob;
+ protected int pos;
+ protected bool swap;
+
+ public TargetBinaryAccess (TargetBlob blob, ITargetInfo
target_info)
+ {
+ this.blob = blob;
+ this.target_info = target_info;
+ this.swap = target_info.IsBigEndian;
+ }
+
+ public int AddressSize {
+ get {
+ if (target_info == null)
+ throw new TargetMemoryException ("Can't
get target address size");
+
+ int address_size =
target_info.TargetAddressSize;
+ if ((address_size != 4) && (address_size != 8))
+ throw new TargetMemoryException (
+ "Unknown target address size "
+ address_size);
+
+ return address_size;
+ }
+ }
+
+ public ITargetInfo TargetInfo {
+ get {
+ return target_info;
+ }
+
+ set {
+ target_info = value;
+ }
+ }
+
+ public long Size {
+ get {
+ return blob.Contents.Length;
+ }
+ }
+
+ public long Position {
+ get {
+ return pos;
+ }
+
+ set {
+ pos = (int) value;
+ }
+ }
+
+ public bool IsEof {
+ get {
+ return pos == blob.Contents.Length;
+ }
+ }
+
+ public byte[] Contents {
+ get {
+ return blob.Contents;
+ }
+ }
+
+ public string HexDump ()
+ {
+ return HexDump (blob.Contents);
+ }
+
+ public static string HexDump (byte[] data)
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ sb.Append ("\n" + TargetAddress.FormatAddress (0) + "
");
+
+ for (int i = 0; i < data.Length; i++) {
+ if (i > 0) {
+ if ((i % 16) == 0)
+ sb.Append ("\n" +
TargetAddress.FormatAddress (i) + " ");
+ else if ((i % 8) == 0)
+ sb.Append (" - ");
+ else
+ sb.Append (" ");
+ }
+ sb.Append (String.Format ("{1}{0:x}", data [i],
data [i] >= 16 ? "" : "0"));
+ }
+ return sb.ToString ();
+ }
+
+ public static string HexDump (TargetAddress start, byte[] data)
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ sb.Append (String.Format ("{0} ", start));
+
+ for (int i = 0; i < data.Length; i++) {
+ if (i > 0) {
+ if ((i % 16) == 0) {
+ start += 16;
+ sb.Append (String.Format
("\n{0} ", start));
+ } else if ((i % 8) == 0)
+ sb.Append (" - ");
+ else
+ sb.Append (" ");
+ }
+ sb.Append (String.Format ("{1}{0:x}", data [i],
data [i] >= 16 ? "" : "0"));
+ }
+ return sb.ToString ();
+ }
+ }
+}
Modified: trunk/debugger/classes/TargetBinaryReader.cs
===================================================================
--- trunk/debugger/classes/TargetBinaryReader.cs 2005-04-11 22:00:04 UTC
(rev 42811)
+++ trunk/debugger/classes/TargetBinaryReader.cs 2005-04-11 23:53:08 UTC
(rev 42812)
@@ -1,100 +1,21 @@
using System;
-using System.Text;
namespace Mono.Debugger
{
- public sealed class TargetBlob
- {
- public readonly byte[] Contents;
-
- public TargetBlob (byte[] contents)
- {
- this.Contents = contents;
- }
-
- public TargetBlob (int size)
- {
- this.Contents = new byte [size];
- }
-
- public int Size {
- get { return Contents.Length; }
- }
- }
-
// <summary>
// This is a generic binary reader.
// </summary>
- public class TargetBinaryReader
+ public class TargetBinaryReader : TargetBinaryAccess
{
- ITargetInfo target_info;
- protected TargetBlob blob;
- protected int pos;
- protected bool swap;
-
public TargetBinaryReader (byte[] contents, ITargetInfo
target_info)
- : this (new TargetBlob (contents), target_info)
+ : base (new TargetBlob (contents), target_info)
{ }
public TargetBinaryReader (TargetBlob blob, ITargetInfo
target_info)
+ : base (blob, target_info)
{
- this.blob = blob;
- this.target_info = target_info;
- this.swap = target_info.IsBigEndian;
}
- public int AddressSize {
- get {
- if (target_info == null)
- throw new TargetMemoryException ("Can't
get target address size");
-
- int address_size =
target_info.TargetAddressSize;
- if ((address_size != 4) && (address_size != 8))
- throw new TargetMemoryException (
- "Unknown target address size "
+ address_size);
-
- return address_size;
- }
- }
-
- public ITargetInfo TargetInfo {
- get {
- return target_info;
- }
-
- set {
- target_info = value;
- }
- }
-
- public long Size {
- get {
- return blob.Contents.Length;
- }
- }
-
- public long Position {
- get {
- return pos;
- }
-
- set {
- pos = (int) value;
- }
- }
-
- public bool IsEof {
- get {
- return pos == blob.Contents.Length;
- }
- }
-
- public byte[] Contents {
- get {
- return blob.Contents;
- }
- }
-
public byte PeekByte (long pos)
{
return blob.Contents[pos];
@@ -379,50 +300,5 @@
}
}
- public string HexDump ()
- {
- return HexDump (blob.Contents);
- }
-
- public static string HexDump (byte[] data)
- {
- StringBuilder sb = new StringBuilder ();
-
- sb.Append ("\n" + TargetAddress.FormatAddress (0) + "
");
-
- for (int i = 0; i < data.Length; i++) {
- if (i > 0) {
- if ((i % 16) == 0)
- sb.Append ("\n" +
TargetAddress.FormatAddress (i) + " ");
- else if ((i % 8) == 0)
- sb.Append (" - ");
- else
- sb.Append (" ");
- }
- sb.Append (String.Format ("{1}{0:x}", data [i],
data [i] >= 16 ? "" : "0"));
- }
- return sb.ToString ();
- }
-
- public static string HexDump (TargetAddress start, byte[] data)
- {
- StringBuilder sb = new StringBuilder ();
-
- sb.Append (String.Format ("{0} ", start));
-
- for (int i = 0; i < data.Length; i++) {
- if (i > 0) {
- if ((i % 16) == 0) {
- start += 16;
- sb.Append (String.Format
("\n{0} ", start));
- } else if ((i % 8) == 0)
- sb.Append (" - ");
- else
- sb.Append (" ");
- }
- sb.Append (String.Format ("{1}{0:x}", data [i],
data [i] >= 16 ? "" : "0"));
- }
- return sb.ToString ();
- }
}
}
Modified: trunk/debugger/classes/TargetBinaryWriter.cs
===================================================================
--- trunk/debugger/classes/TargetBinaryWriter.cs 2005-04-11 22:00:04 UTC
(rev 42811)
+++ trunk/debugger/classes/TargetBinaryWriter.cs 2005-04-11 23:53:08 UTC
(rev 42812)
@@ -3,7 +3,7 @@
namespace Mono.Debugger
{
- public class TargetBinaryWriter : TargetBinaryReader
+ public class TargetBinaryWriter : TargetBinaryAccess
{
public TargetBinaryWriter (int size, ITargetInfo target_info)
: base (new TargetBlob (size), target_info)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches