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

Commit

Permalink
Merge branch 'master' into mono-2-6-branch
Browse files Browse the repository at this point in the history
svn path=/branches/mono-2-6/debugger/; revision=147682
  • Loading branch information
Martin Baulig committed Dec 4, 2009
1 parent 8005b59 commit 4d20e1f
Show file tree
Hide file tree
Showing 26 changed files with 408 additions and 166 deletions.
75 changes: 75 additions & 0 deletions ChangeLog
@@ -1,3 +1,78 @@
2009-12-04 Martin Baulig <martin@ximian.com>

* backend/BreakpointHandle.cs
(FunctionBreakpointHandle): Make this class abstract.

* languages/TargetFunctionType.cs
(TargetFunctionType): Replace InsertBreakpoint() and
RemoveBreakpoint() with a new GetBreakpointHandle() API which
returns a `FunctionBreakpointHandle'.

2009-11-29 Martin Baulig <martin@ximian.com>

* classes/DebuggerConfiguration.cs
(DebuggerConfiguration.LoadConfigurationFromStream): Use
Report.Error() to report errors instead of throwing an exception.
(DebuggerConfiguration.UserNotifications): New public property.
(DebuggerConfiguration.NotifyUser_ThreadCreation): Mark as obsolete.
(DebuggerConfiguration.UserNotificationType): New public enum.

* frontend/Command.cs
(ConfigCommand): Add `user-notifications' option to modify the new
`DebuggerConfiguration.UserNotifications'.

2009-11-25 Martin Baulig <martin@ximian.com>

* classes/DebuggerConfiguration.cs
(DebuggerConfiguration.IsCLI): New public property to check
whether we're running the CLI or a GUI.

* classes/DebuggerSession.cs
(DebuggerSession.ctor): Only auto-insert the
`MainMethodBreakpoint' in the CLI.

2009-11-25 Martin Baulig <martin@ximian.com>

* classes/DebuggerSession.cs
(DebuggerSession.GetEvent): Return null if the event doesn't
exist, don't throw any exception.

* frontend/ScriptingContext.cs
(ScriptingContext.ActivatePendingBreakpoint): New internal method;
activate pending breakpoints and wait for its completion.

* frontend/Command.cs
(BreakpointDeleteCommand.ActionDone): Call it here ...
(BreakCommand.DoExecute): ... and here.

* test/testsuite/TestMethodLookup.cs: This fixes a race condition here.

2009-11-25 Martin Baulig <martin@ximian.com>

Hardware breakpoints are per-thread and not per-process; allow
having both a hardware and a regular breakpoint on the same
instruction.

* backend/server/x86_64-arch.c
(ArchInfo): Add `BreakpointManager *hw_bpm'.
(server_ptrace_current_insn_is_bpt): Check both `arch->hw_bpm' and
`handle->bpm'; we may now have both a hardware and a regular
breakpoint on the same instruction.
(lookup_breakpoint): New static function to look in both
`arch->hw_bpm' and `handle->bpm'; use this everywhere instead of
calling mono_debugger_breakpoint_manager_lookup_by_id() directly.

2009-11-25 Martin Baulig <martin@ximian.com>

Don't activate address breakpoints twice.

* classes/AddressBreakpoint.cs
(AddressBreakpoint.NeedsActivation): Overwrite and return `false'.

* frontend/Command.cs
(BreakCommand.DoExecute): Check `Breakpoint.NeedsActivation' before
calling Activate() on it.

2009-10-19 Martin Baulig <martin@ximian.com>

* backend/Inferior.cs
Expand Down
56 changes: 10 additions & 46 deletions backend/BreakpointHandle.cs
Expand Up @@ -111,22 +111,17 @@ public override void Remove (Inferior inferior)
}
}

internal class FunctionBreakpointHandle : BreakpointHandle
internal abstract class FunctionBreakpointHandle : BreakpointHandle
{
TargetFunctionType function;
bool has_load_handler;
int line = -1, column;

internal int Index {
get; private set;
}

public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function, int line)
: this (bpt, function, line, -1)
{ }

public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function,
int line, int column)
protected FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function,
int line, int column)
: base (bpt)
{
this.function = function;
Expand All @@ -140,56 +135,25 @@ public FunctionBreakpointHandle (Breakpoint bpt, TargetFunctionType function, in
get { return function; }
}

public override void Insert (Inferior target)
{
throw new InternalError ();
public int Line {
get { return line; }
}

public override void Insert (Thread target)
{
if (has_load_handler)
return;

has_load_handler = function.InsertBreakpoint (target, this);
public int Column {
get { return column; }
}

internal void MethodLoaded (TargetAccess target, Method method)
public override void Insert (Inferior target)
{
TargetAddress address;
if (line != -1) {
if (method.HasLineNumbers)
address = method.LineNumberTable.Lookup (line, column);
else
address = TargetAddress.Null;
} else if (method.HasMethodBounds)
address = method.MethodStartAddress;
else
address = method.StartAddress;

if (address.IsNull)
return;

try {
target.InsertBreakpoint (this, address, method.Domain);
} catch (TargetException ex) {
Report.Error ("Can't insert breakpoint {0} at {1}: {2}",
Breakpoint.Index, address, ex.Message);
}
throw new InternalError ();
}

public override void Remove (Inferior target)
{
throw new InternalError ();
}

public override void Remove (Thread target)
{
target.RemoveBreakpoint (this);

if (has_load_handler)
function.RemoveBreakpoint (target);
has_load_handler = false;
}
internal abstract void MethodLoaded (TargetAccess target, Method method);

public override string ToString ()
{
Expand Down
19 changes: 10 additions & 9 deletions backend/ProcessServant.cs
Expand Up @@ -419,10 +419,12 @@ internal void InitializeThreads (Inferior inferior, bool resume_threads)

thread_db = ThreadDB.Create (this, inferior);
if (thread_db == null) {
if (IsManaged)
Report.Error ("Failed to initialize thread_db on {0}",
start.CommandLine);
return;
if (!IsManaged)
return;

Report.Error ("Failed to initialize thread_db on {0}", start.CommandLine);
throw new TargetException (TargetError.CannotStartTarget,
"Failed to initialize thread_db on {0}", start.CommandLine);
}

int[] threads = inferior.GetThreads ();
Expand All @@ -435,8 +437,7 @@ internal void InitializeThreads (Inferior inferior, bool resume_threads)
thread_db.GetThreadInfo (inferior, delegate (int lwp, long tid) {
SingleSteppingEngine engine = (SingleSteppingEngine) thread_hash [lwp];
if (engine == null) {
Report.Error ("Unknown thread {0} in {1}", lwp,
start.CommandLine);
Report.Error ("Unknown thread {0} in {1}", lwp, start.CommandLine);
return;
}
engine.SetTID (tid);
Expand Down Expand Up @@ -485,9 +486,9 @@ internal SingleSteppingEngine GetEngineByTID (Inferior inferior, long tid)
}

if (thread_db == null) {
Report.Error ("Failed to initialize thread_db on {0}: {1} {2}",
start.CommandLine, start, Environment.StackTrace);
throw new InternalError ();
Report.Error ("Failed to initialize thread_db on {0}: {1}",
start.CommandLine, start);
return null;
}

SingleSteppingEngine result = null;
Expand Down
32 changes: 27 additions & 5 deletions backend/SingleSteppingEngine.cs
Expand Up @@ -434,15 +434,27 @@ protected void DoProcessEvent (Inferior.ChildEvent cevent)

remove_temporary_breakpoint ();

Breakpoint bpt = lookup_breakpoint (arg);
//
// Lookup again using the current address since `arg' points to the hardware breakpoint,
// but there may be a user breakpoint on the current instruction as well.
//

int idx;
bool is_enabled;
BreakpointHandle handle = process.BreakpointManager.LookupBreakpoint (
inferior.CurrentFrame, out idx, out is_enabled);

Report.Debug (DebugFlags.SSE,
"{0} hit temporary breakpoint {1} at {2} {3}",
this, arg, inferior.CurrentFrame, bpt);
if ((bpt == null) || !bpt.Breaks (thread.ID) || bpt.HideFromUser) {
"{0} hit temporary breakpoint {1} at {2}: {3} {4} {5}",
this, arg, inferior.CurrentFrame, handle, idx, is_enabled);

if ((handle == null) || !is_enabled || !handle.Breakpoint.Breaks (thread.ID) ||
handle.Breakpoint.HideFromUser) {
message = Inferior.ChildEventType.CHILD_STOPPED;
arg = 0;
cevent = new Inferior.ChildEvent (Inferior.ChildEventType.CHILD_STOPPED, 0, 0, 0);
} else {
cevent = new Inferior.ChildEvent (Inferior.ChildEventType.CHILD_HIT_BREAKPOINT, idx, 0, 0);
ProcessOperationEvent (cevent);
return;
}
Expand Down Expand Up @@ -491,7 +503,17 @@ protected void ProcessOperationEvent (Inferior.ChildEvent cevent)

Report.Debug (DebugFlags.EventLoop, "{0} process operation event: {1} {2}", this, current_operation, cevent);

Operation.EventResult status = current_operation.ProcessEvent (cevent, out result);
Operation.EventResult status;

try {
status = current_operation.ProcessEvent (cevent, out result);
} catch (TargetException ex) {
Report.Error ("{0} caught exception while processing event {1}: {2}", this, cevent, ex.Message);
killed = true;
inferior.Kill ();
OperationCompleted (null);
return;
}

Report.Debug (DebugFlags.EventLoop, "{0} processed operation event: {1} {2} {3} {4}", this,
current_operation, cevent, status, result);
Expand Down
2 changes: 1 addition & 1 deletion backend/mono/MonoLanguageBackend.cs
Expand Up @@ -1418,7 +1418,7 @@ internal string GetShadowCopyLocation (string path)

MonoSymbolFile symfile = (MonoSymbolFile) symfile_by_index [(int) arg];
if (symfile == null)
throw new InternalError ();
break;

engine.Process.Debugger.OnModuleUnLoaded (symfile.Module);
close_symfile (symfile);
Expand Down
3 changes: 3 additions & 0 deletions backend/os/LinuxOperatingSystem.cs
Expand Up @@ -201,6 +201,9 @@ internal override void UpdateSharedLibraries (Inferior inferior)
// This fails if it's a statically linked executable.
try {
read_dynamic_info (inferior);
} catch (TargetException ex) {
Report.Error ("Failed to read shared libraries: {0}", ex.Message);
return;
} catch (Exception ex) {
Report.Error ("Failed to read shared libraries: {0}", ex);
return;
Expand Down
5 changes: 5 additions & 0 deletions backend/server/breakpoints.c
Expand Up @@ -92,6 +92,11 @@ mono_debugger_breakpoint_manager_get_breakpoints (BreakpointManager *bpm)
void
mono_debugger_breakpoint_manager_remove (BreakpointManager *bpm, BreakpointInfo *breakpoint)
{
if (!mono_debugger_breakpoint_manager_lookup_by_id (bpm, breakpoint->id)) {
g_warning (G_STRLOC ": mono_debugger_breakpoint_manager_remove(): No such breakpoint %d", breakpoint->id);
return;
}

if (--breakpoint->refcount > 0)
return;

Expand Down

0 comments on commit 4d20e1f

Please sign in to comment.