Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
2006-02-23 Martin Baulig <martin@ximian.com>
Browse files Browse the repository at this point in the history
	Support multiple appdomains; this is only used when attaching to a
	process which is running without `-O=shared'; the API to insert a
	breakpoint in another appdomain is intentionally undocumented and
	will change in near future.

	* classes/SourceInfo.cs (SourceMethod.IsLoaded): Removed.
	(SourceMethod.Method): Replaced the property with a new
	GetMethod() method which takes a `domain' argument.
	(SourceMethod.GetMethod): New public method.
	(SourceMethod.Lookup): Removed.

	* classes/DebuggerSession.cs
	(DebuggerSession.InsertBreakpoint): Added `int domain' argument.

	* classes/Module.cs
	(SymbolFile.GetMethod): Added `int domain' argument.

	* classes/SourceLocation.cs
	(SourceLocation.GetAddress): Added `int domain' argument to
	support multiple application domains.

	* classes/BreakpointHandle.cs: Support multiple appdomains.

	* languages/mono/MonoSymbolFile.cs: Support multiple appdomains.


svn path=/trunk/debugger/; revision=57205
  • Loading branch information
Martin Baulig committed Feb 23, 2006
1 parent 8751e5c commit a7f45a3
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 93 deletions.
27 changes: 27 additions & 0 deletions ChangeLog
@@ -1,3 +1,30 @@
2006-02-23 Martin Baulig <martin@ximian.com>

Support multiple appdomains; this is only used when attaching to a
process which is running without `-O=shared'; the API to insert a
breakpoint in another appdomain is intentionally undocumented and
will change in near future.

* classes/SourceInfo.cs (SourceMethod.IsLoaded): Removed.
(SourceMethod.Method): Replaced the property with a new
GetMethod() method which takes a `domain' argument.
(SourceMethod.GetMethod): New public method.
(SourceMethod.Lookup): Removed.

* classes/DebuggerSession.cs
(DebuggerSession.InsertBreakpoint): Added `int domain' argument.

* classes/Module.cs
(SymbolFile.GetMethod): Added `int domain' argument.

* classes/SourceLocation.cs
(SourceLocation.GetAddress): Added `int domain' argument to
support multiple application domains.

* classes/BreakpointHandle.cs: Support multiple appdomains.

* languages/mono/MonoSymbolFile.cs: Support multiple appdomains.

2006-02-08 Martin Baulig <martin@ximian.com>

* backends/server/i386-arch.c: Use `guint32' instead of `long'
Expand Down
2 changes: 1 addition & 1 deletion arch/Bfd.cs
Expand Up @@ -563,7 +563,7 @@ public override SourceMethod[] GetMethods (SourceFile file)
throw new InvalidOperationException ();
}

public override Method GetMethod (long handle)
public override Method GetMethod (int domain, long handle)
{
if (dwarf != null)
return dwarf.GetMethod (handle);
Expand Down
6 changes: 3 additions & 3 deletions backends/Debugger.cs
Expand Up @@ -319,10 +319,10 @@ public void LoadLibrary (Process process, string filename)
get { return mono_language != null; }
}

public EventHandle InsertBreakpoint (TargetAccess target, Breakpoint bpt,
SourceLocation location)
public EventHandle InsertBreakpoint (TargetAccess target, int domain,
Breakpoint bpt, SourceLocation location)
{
return new BreakpointHandle (target, bpt, location);
return new BreakpointHandle (target, domain, bpt, location);
}

public EventHandle InsertBreakpoint (TargetAccess target, Breakpoint bpt,
Expand Down
22 changes: 15 additions & 7 deletions classes/BreakpointHandle.cs
Expand Up @@ -15,21 +15,23 @@ public sealed class BreakpointHandle : EventHandle
TargetAddress address = TargetAddress.Null;
int breakpoint_id = -1;
IDisposable load_handler;
int domain;

private BreakpointHandle (Breakpoint breakpoint)
: base (breakpoint.ThreadGroup, breakpoint.Name)
{
this.breakpoint = breakpoint;
}

internal BreakpointHandle (TargetAccess target, Breakpoint breakpoint,
internal BreakpointHandle (TargetAccess target, int domain, Breakpoint breakpoint,
SourceLocation location)
: this (breakpoint)
{
this.domain = domain;
this.location = location;

if (location.Method.IsLoaded)
address = location.GetAddress ();
address = location.GetAddress (domain);

Enable (target);
}

Expand Down Expand Up @@ -125,15 +127,21 @@ void DisableBreakpoint (TargetAccess target)
// The method has just been loaded, lookup the breakpoint
// address and actually insert it.
// </summary>
void method_loaded (ITargetMemoryAccess target, SourceMethod method,
void method_loaded (ITargetMemoryAccess target, SourceMethod source,
object data)
{
load_handler = null;

Method method = source.GetMethod (domain);

if (location != null)
address = location.GetAddress ();
else
address = method.Method.StartAddress;
address = location.GetAddress (domain);
else {
if (method == null)
return;

address = method.StartAddress;
}

if (address.IsNull)
return;
Expand Down
6 changes: 3 additions & 3 deletions classes/DebuggerSession.cs
Expand Up @@ -144,11 +144,11 @@ public void InsertBreakpoints (Process thread)
handle.Enable (thread.TargetAccess);
}

public EventHandle InsertBreakpoint (TargetAccess target, SourceLocation location,
Breakpoint breakpoint)
public EventHandle InsertBreakpoint (TargetAccess target, int domain,
SourceLocation location, Breakpoint breakpoint)
{
EventHandle handle = target.Debugger.InsertBreakpoint (
target, breakpoint, location);
target, domain, breakpoint, location);
if (handle == null)
return handle;

Expand Down
6 changes: 3 additions & 3 deletions classes/Module.cs
Expand Up @@ -41,7 +41,7 @@ internal abstract class SymbolFile : MarshalByRefObject

public abstract SourceMethod[] GetMethods (SourceFile file);

public abstract Method GetMethod (long handle);
public abstract Method GetMethod (int domain, long handle);

public abstract SourceMethod FindMethod (string name);

Expand Down Expand Up @@ -261,9 +261,9 @@ public SourceMethod[] GetMethods (SourceFile file)
return SymbolFile.GetMethods (file);
}

public Method GetMethod (long handle)
public Method GetMethod (int domain, long handle)
{
return SymbolFile.GetMethod (handle);
return SymbolFile.GetMethod (domain, handle);
}

// <summary>
Expand Down
43 changes: 5 additions & 38 deletions classes/SourceInfo.cs
Expand Up @@ -122,30 +122,9 @@ public class SourceMethod
}
}

// <summary>
// Whether this method is current loaded in memory. For managed
// methods, this returns whether the method has already been JITed.
// </summary>
public bool IsLoaded {
get {
return module.GetMethod (handle) != null;
}
}

// <summary>
// May only be used while the method is loaded and return's the Method.
//
// Throws:
// InvalidOperationException - IsLoaded is false.
// </summary>
public Method Method {
get {
Method method = module.GetMethod (handle);
if (method == null)
throw new InvalidOperationException ();

return method;
}
public Method GetMethod (int domain)
{
return module.GetMethod (domain, handle);
}

// <summary>
Expand All @@ -162,22 +141,10 @@ public class SourceMethod
}
}

public TargetAddress Lookup (int SourceLine)
{
Method method = module.GetMethod (handle);
if (method == null)
throw new InvalidOperationException ();

if (method.HasSource)
return method.Source.Lookup (SourceLine);
else
return TargetAddress.Null;
}

public override string ToString ()
{
return String.Format ("Method ({0}:{1}:{2}:{3}:{4})", Name, SourceFile,
StartRow, EndRow, IsLoaded);
return String.Format ("Method ({0}:{1}:{2}:{3})", Name, SourceFile,
StartRow, EndRow);
}

Module module;
Expand Down
44 changes: 24 additions & 20 deletions classes/SourceLocation.cs
Expand Up @@ -12,7 +12,7 @@ namespace Mono.Debugger
public class SourceLocation
{
Module module;
SourceMethod method;
SourceMethod source;
ISourceBuffer buffer;
int line;

Expand All @@ -21,7 +21,7 @@ public class SourceLocation
}

public bool HasSourceFile {
get { return method != null; }
get { return source != null; }
}

public ISourceBuffer SourceBuffer {
Expand All @@ -38,7 +38,7 @@ public class SourceLocation
if (!HasSourceFile)
throw new InvalidOperationException ();

return method.SourceFile;
return source.SourceFile;
}
}

Expand All @@ -47,14 +47,14 @@ public class SourceLocation
if (!HasSourceFile)
throw new InvalidOperationException ();

return method;
return source;
}
}

public int Line {
get {
if (line == -1)
return method.StartRow;
return source.StartRow;
else
return line;
}
Expand All @@ -63,25 +63,25 @@ public class SourceLocation
public string Name {
get {
if (line == -1)
return method.Name;
return source.Name;
else if (HasSourceFile)
return String.Format ("{0}:{1}", SourceFile.FileName, line);
else
return String.Format ("{0}:{1}", SourceBuffer.Name, line);
}
}

public SourceLocation (SourceMethod method)
: this (method, -1)
public SourceLocation (SourceMethod source)
: this (source, -1)
{ }

public SourceLocation (SourceMethod method, int line)
public SourceLocation (SourceMethod source, int line)
{
this.module = method.SourceFile.Module;
this.method = method;
this.module = source.SourceFile.Module;
this.source = source;
this.line = line;

if (method == null)
if (source == null)
throw new InvalidOperationException ();
}

Expand All @@ -92,17 +92,21 @@ public SourceLocation (Module module, ISourceBuffer buffer, int line)
this.line = line;
}

internal TargetAddress GetAddress ()
internal TargetAddress GetAddress (int domain)
{
if (!method.IsLoaded)
throw new InvalidOperationException ();
Method method = source.GetMethod (domain);
if (method == null)
return TargetAddress.Null;

if (line != -1)
return method.Lookup (line);
else if (method.Method.HasMethodBounds)
return method.Method.MethodStartAddress;
if (line != -1) {
if (method.HasSource)
return method.Source.Lookup (line);
else
return TargetAddress.Null;
} else if (method.HasMethodBounds)
return method.MethodStartAddress;
else
return method.Method.StartAddress;
return method.StartAddress;
}

public override string ToString ()
Expand Down
15 changes: 13 additions & 2 deletions frontend/Command.cs
Expand Up @@ -1907,6 +1907,7 @@ protected override void DoExecute (ScriptingContext context)
public class BreakCommand : SourceCommand, IDocumentableCommand
{
string group;
int domain = 0;
int process_id = -1;
TargetFunctionType func;
Process process;
Expand All @@ -1917,6 +1918,11 @@ public class BreakCommand : SourceCommand, IDocumentableCommand
set { group = value; }
}

public int Domain {
get { return domain; }
set { domain = value; }
}

public int Process {
get { return process_id; }
set { process_id = value; }
Expand Down Expand Up @@ -1978,15 +1984,20 @@ protected override void DoExecute (ScriptingContext context)
location = new SourceLocation (method);

int index = context.Interpreter.InsertBreakpoint (
process.TargetAccess, tgroup, location);
process.TargetAccess, tgroup, domain, location);
context.Print ("Breakpoint {0} at {1}", index, location.Name);
}
return;
} else if (location != null) {
int index = context.Interpreter.InsertBreakpoint (
process.TargetAccess, tgroup, location);
process.TargetAccess, tgroup, domain, location);
context.Print ("Breakpoint {0} at {1}", index, location.Name);
} else if (func != null) {
if (domain != 0) {
context.Error ("Can't insert function breakpoints in " +
"other appdomains.");
return;
}
int index = context.Interpreter.InsertBreakpoint (
process.TargetAccess, tgroup, func);
context.Print ("Breakpoint {0} at {1}", index, func.Name);
Expand Down
5 changes: 3 additions & 2 deletions frontend/Interpreter.cs
Expand Up @@ -604,12 +604,13 @@ public void RemoveFromThreadGroup (string name, Process[] threads)
group.RemoveThread (process.ID);
}

public int InsertBreakpoint (TargetAccess target, ThreadGroup group,
public int InsertBreakpoint (TargetAccess target, ThreadGroup group, int domain,
SourceLocation location)
{
Breakpoint breakpoint = new SimpleBreakpoint (location.Name, group);

EventHandle handle = session.InsertBreakpoint (target, location, breakpoint);
EventHandle handle = session.InsertBreakpoint (
target, domain, location, breakpoint);
if (handle == null)
throw new ScriptingException ("Could not insert breakpoint.");

Expand Down

0 comments on commit a7f45a3

Please sign in to comment.