Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

2002-09-18 Martin Baulig <martin@gnome.org>

	* class/TargetException (TargetException): Made this abstract.

	* class/InternalError.cs: New exception class.

svn path=/trunk/debugger/; revision=7584
  • Loading branch information...
commit 7364827d36b57674b4823aae127671b417b05cc6 1 parent 96493f1
authored September 18, 2002
6  ChangeLog
... ...
@@ -1,5 +1,11 @@
1 1
 2002-09-18  Martin Baulig  <martin@gnome.org>
2 2
 
  3
+	* class/TargetException (TargetException): Made this abstract.
  4
+
  5
+	* class/InternalError.cs: New exception class.
  6
+
  7
+2002-09-18  Martin Baulig  <martin@gnome.org>
  8
+
3 9
 	* interfaces/ITargetMemoryAccess.cs (ITargetMemoryReader.BinaryReader):
4 10
 	Return a TargetBinaryReader instead of a BinaryReader.
5 11
 
4  arch/Bfd.cs
@@ -60,10 +60,10 @@ public Bfd (IInferior inferior, string filename, ISourceFileFactory factory)
60 60
 		{
61 61
 			bfd = bfd_openr (filename, null);
62 62
 			if (bfd == IntPtr.Zero)
63  
-				throw new TargetException ("Can't read symbol file: " + filename);
  63
+				throw new SymbolTableException ("Can't read symbol file: {0}", filename);
64 64
 
65 65
 			if (!bfd_glue_check_format_object (bfd))
66  
-				throw new TargetException ("Not an object file: " + filename);
  66
+				throw new SymbolTableException ("Not an object file: {0}", filename);
67 67
 
68 68
 			this.inferior = inferior;
69 69
 			this.filename = filename;
6  backends/Debugger.cs
@@ -573,7 +573,7 @@ void inferior_errors (string line)
573 573
 		public void Run ()
574 574
 		{
575 575
 			if (inferior != null)
576  
-				throw new TargetException ("Debugger already has an inferior.");
  576
+				throw new AlreadyHaveTargetException ();
577 577
 
578 578
 			bool native = application == null;
579 579
 
@@ -677,8 +677,6 @@ public void NextLine ()
677 677
 				return;
678 678
 			}
679 679
 
680  
-			Console.WriteLine ("RUNNING UNTIL: {0:x}", frame.End);
681  
-
682 680
 			inferior.Step (new StepFrame (
683 681
 				frame.Start, frame.End, null, StepMode.Finish));
684 682
 		}
@@ -693,7 +691,7 @@ public void Finish ()
693 691
 
694 692
 			IStackFrame frame = CurrentFrame;
695 693
 			if (frame.Method == null)
696  
-				throw new TargetException ("Can't find bounds of current method");
  694
+				throw new NoMethodException ();
697 695
 
698 696
 			inferior.Step (new StepFrame (
699 697
 				frame.Method.StartAddress, frame.Method.EndAddress, null, StepMode.Finish));
43  backends/ptrace/PTrace.cs
@@ -28,21 +28,19 @@ internal enum ChildMessageType {
28 28
 
29 29
 	internal enum CommandError {
30 30
 		NONE = 0,
  31
+		NO_INFERIOR,
  32
+		ALREADY_HAVE_INFERIOR,
  33
+		FORK,
31 34
 		IO,
32 35
 		UNKNOWN,
33 36
 		INVALID_COMMAND,
34  
-		NOT_STOPPED
  37
+		NOT_STOPPED,
  38
+		ALIGNMENT,
  39
+		RECURSIVE_CALL,
  40
+		NO_SUCH_BREAKPOINT,
  41
+		UNKNOWN_REGISTER
35 42
 	}
36 43
 	
37  
-	internal enum ServerCommand {
38  
-		GET_PC = 1,
39  
-		DETACH,
40  
-		SHUTDOWN,
41  
-		KILL,
42  
-		CONTINUE,
43  
-		STEP
44  
-	}
45  
-
46 44
 	internal delegate void ChildSetupHandler ();
47 45
 	internal delegate void ChildExitedHandler ();
48 46
 	internal delegate void ChildCallbackHandler (long argument, long data);
@@ -172,9 +170,24 @@ void handle_error (CommandError error)
172 170
 			case CommandError.NOT_STOPPED:
173 171
 				throw new TargetNotStoppedException ();
174 172
 
  173
+			case CommandError.NO_INFERIOR:
  174
+				throw new NoTargetException ();
  175
+
  176
+			case CommandError.ALREADY_HAVE_INFERIOR:
  177
+				throw new AlreadyHaveTargetException ();
  178
+
  179
+			case CommandError.FORK:
  180
+				throw new CannotStartTargetException ();
  181
+
  182
+			case CommandError.NO_SUCH_BREAKPOINT:
  183
+				throw new NoSuchBreakpointException ();
  184
+
  185
+			case CommandError.UNKNOWN_REGISTER:
  186
+				throw new NoSuchRegisterException ();
  187
+
175 188
 			default:
176  
-				throw new TargetException (
177  
-					"Got unknown error condition from inferior: " + error);
  189
+				throw new InternalError ("Got unknown error condition from inferior: {0}",
  190
+							 error);
178 191
 			}
179 192
 		}
180 193
 
@@ -203,7 +216,7 @@ public long CallMethod (TargetAddress method, long method_argument)
203 216
 				method, method_argument, null, null);
204 217
 			mono_debugger_server_wait (server_handle);
205 218
 			if (!result.IsCompleted)
206  
-				throw new TargetException ("Call not completed");
  219
+				throw new InternalError ("Call not completed");
207 220
 			return (long) result.AsyncResult;
208 221
 		}
209 222
 
@@ -243,7 +256,7 @@ void insert_temporary_breakpoint (TargetAddress address)
243 256
 
244 257
 			server_handle = mono_debugger_server_initialize ();
245 258
 			if (server_handle == IntPtr.Zero)
246  
-				throw new TargetException ("Can't get server handle");
  259
+				throw new InternalError ("mono_debugger_server_initialize() failed.");
247 260
 
248 261
 			check_error (mono_debugger_server_spawn (
249 262
 				server_handle, working_directory, argv, envp, true,
@@ -269,7 +282,7 @@ public Inferior (int pid, string[] envp, ISourceFileFactory factory)
269 282
 
270 283
 			server_handle = mono_debugger_server_initialize ();
271 284
 			if (server_handle == IntPtr.Zero)
272  
-				throw new TargetException ("Can't get server handle");
  285
+				throw new InternalError ("mono_debugger_server_initialize() failed.");
273 286
 
274 287
 			check_error (mono_debugger_server_attach (
275 288
 				server_handle, pid, new ChildExitedHandler (child_exited),
19  classes/InternalError.cs
... ...
@@ -0,0 +1,19 @@
  1
+using System;
  2
+
  3
+namespace Mono.Debugger
  4
+{
  5
+	public class InternalError : Exception
  6
+	{
  7
+		public InternalError ()
  8
+			: base ("Internal error.")
  9
+		{ }
  10
+
  11
+		public InternalError (string message, params object[] args)
  12
+			: base (String.Format (message, args))
  13
+		{ }
  14
+
  15
+		public InternalError (Exception inner, string message, params object[] args)
  16
+			: base (String.Format (message, args), inner)
  17
+		{ }
  18
+	}
  19
+}
43  classes/TargetException.cs
@@ -2,17 +2,31 @@
2 2
 
3 3
 namespace Mono.Debugger
4 4
 {
5  
-	public class TargetException : Exception
  5
+	public abstract class TargetException : Exception
6 6
 	{
7 7
 		public TargetException (string message)
8 8
 			: base (message)
9 9
 		{ }
10 10
 	}
11 11
 
  12
+	public class CannotStartTargetException : TargetException
  13
+	{
  14
+		public CannotStartTargetException ()
  15
+			: base ("Cannot start target")
  16
+		{ }
  17
+	}
  18
+
  19
+	public class AlreadyHaveTargetException : TargetException
  20
+	{
  21
+		public AlreadyHaveTargetException ()
  22
+			: base ("I already have a program to debug, can't debug a second one.")
  23
+		{ }
  24
+	}
  25
+
12 26
 	public class NoTargetException : TargetException
13 27
 	{
14 28
 		public NoTargetException ()
15  
-			: base ("There is no program to debug")
  29
+			: base ("There is no program to debug.")
16 30
 		{ }
17 31
 	}
18 32
 
@@ -20,18 +34,35 @@ public class TargetNotStoppedException : TargetException
20 34
 	{
21 35
 		public TargetNotStoppedException ()
22 36
 			: base ("The target is currently running, but it must be stopped to perform " +
23  
-				"the requested operation")
  37
+				"the requested operation.")
24 38
 		{ }
25 39
 	}
26 40
 
27 41
 	public class NoStackException : TargetException
28 42
 	{
29 43
 		public NoStackException ()
30  
-			: this ("No stack")
  44
+			: base ("No stack.")
31 45
 		{ }
  46
+	}
32 47
 
33  
-		public NoStackException (string message)
34  
-			: base (message)
  48
+	public class NoMethodException : TargetException
  49
+	{
  50
+		public NoMethodException ()
  51
+			: base ("Cannot get bounds of current method.")
  52
+		{ }
  53
+	}
  54
+
  55
+	public class NoSuchBreakpointException : TargetException
  56
+	{
  57
+		public NoSuchBreakpointException ()
  58
+			: base ("No such breakpoint.")
  59
+		{ }
  60
+	}
  61
+
  62
+	public class NoSuchRegisterException : TargetException
  63
+	{
  64
+		public NoSuchRegisterException ()
  65
+			: base ("No such registers.")
35 66
 		{ }
36 67
 	}
37 68
 }

0 notes on commit 7364827

Please sign in to comment.
Something went wrong with that request. Please try again.