Author: martin
Date: 2005-10-11 09:09:21 -0400 (Tue, 11 Oct 2005)
New Revision: 51564
Modified:
trunk/debugger/ChangeLog
trunk/debugger/arch/Architecture_I386.cs
trunk/debugger/arch/Architecture_PowerPC.cs
trunk/debugger/arch/Architecture_X86_64.cs
trunk/debugger/arch/Bfd.cs
trunk/debugger/classes/TargetBinaryAccess.cs
trunk/debugger/interfaces/IArchitecture.cs
Log:
2005-10-11 Martin Baulig <[EMAIL PROTECTED]>
* interfaces/IArchitecture.cs
(IArchitecture.TrySpecialUnwind): New method.
* arch/Architecture_X86_64.cs
(Architecture_X86_64.TrySpecialUnwind): Support sigreturn trampolines.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2005-10-11 12:45:38 UTC (rev 51563)
+++ trunk/debugger/ChangeLog 2005-10-11 13:09:21 UTC (rev 51564)
@@ -1,3 +1,11 @@
+2005-10-11 Martin Baulig <[EMAIL PROTECTED]>
+
+ * interfaces/IArchitecture.cs
+ (IArchitecture.TrySpecialUnwind): New method.
+
+ * arch/Architecture_X86_64.cs
+ (Architecture_X86_64.TrySpecialUnwind): Support sigreturn trampolines.
+
2005-10-10 Martin Baulig <[EMAIL PROTECTED]>
* backends/server/x86_64-arch.c
Modified: trunk/debugger/arch/Architecture_I386.cs
===================================================================
--- trunk/debugger/arch/Architecture_I386.cs 2005-10-11 12:45:38 UTC (rev
51563)
+++ trunk/debugger/arch/Architecture_I386.cs 2005-10-11 13:09:21 UTC (rev
51564)
@@ -615,5 +615,11 @@
return new SimpleStackFrame (eip, esp, ebp, regs, 0);
}
+
+ public SimpleStackFrame TrySpecialUnwind (ITargetMemoryAccess
memory,
+ SimpleStackFrame
frame)
+ {
+ return null;
+ }
}
}
Modified: trunk/debugger/arch/Architecture_PowerPC.cs
===================================================================
--- trunk/debugger/arch/Architecture_PowerPC.cs 2005-10-11 12:45:38 UTC (rev
51563)
+++ trunk/debugger/arch/Architecture_PowerPC.cs 2005-10-11 13:09:21 UTC (rev
51564)
@@ -219,5 +219,11 @@
{
throw new NotImplementedException ();
}
+
+ public SimpleStackFrame TrySpecialUnwind (ITargetMemoryAccess
memory,
+ SimpleStackFrame
frame)
+ {
+ return null;
+ }
}
}
Modified: trunk/debugger/arch/Architecture_X86_64.cs
===================================================================
--- trunk/debugger/arch/Architecture_X86_64.cs 2005-10-11 12:45:38 UTC (rev
51563)
+++ trunk/debugger/arch/Architecture_X86_64.cs 2005-10-11 13:09:21 UTC (rev
51564)
@@ -569,5 +569,72 @@
return new SimpleStackFrame (rip, rsp, rbp, regs, 0);
}
+
+ SimpleStackFrame try_unwind_sigreturn (ITargetMemoryAccess
memory,
+ SimpleStackFrame frame)
+ {
+ byte[] data = memory.ReadMemory (frame.Address,
9).Contents;
+
+ /*
+ * Check for signal return trampolines:
+ *
+ * mov __NR_rt_sigreturn, %eax
+ * syscall
+ */
+ if ((data [0] != 0x48) || (data [1] != 0xc7) ||
+ (data [2] != 0xc0) || (data [3] != 0x0f) ||
+ (data [4] != 0x00) || (data [5] != 0x00) ||
+ (data [6] != 0x00) || (data [7] != 0x0f) ||
+ (data [8] != 0x05))
+ return null;
+
+ TargetAddress stack = frame.StackPointer;
+ /* See `struct sigcontext' in <asm/sigcontext.h> */
+ int[] regoffsets = {
+ (int) X86_64_Register.R8, (int)
X86_64_Register.R9,
+ (int) X86_64_Register.R10, (int)
X86_64_Register.R11,
+ (int) X86_64_Register.R12, (int)
X86_64_Register.R13,
+ (int) X86_64_Register.R14, (int)
X86_64_Register.R15,
+ (int) X86_64_Register.RDI, (int)
X86_64_Register.RSI,
+ (int) X86_64_Register.RBP, (int)
X86_64_Register.RBX,
+ (int) X86_64_Register.RDX, (int)
X86_64_Register.RAX,
+ (int) X86_64_Register.RCX, (int)
X86_64_Register.RSP,
+ (int) X86_64_Register.RIP, (int)
X86_64_Register.EFLAGS
+ };
+
+ Registers regs = new Registers (this);
+
+ int offset = 0x28;
+ /* The stack contains the `struct ucontext' from
<asm/ucontext.h>; the
+ * `struct sigcontext' starts at offset 0x28 in it. */
+ foreach (int regoffset in regoffsets) {
+ TargetAddress new_value =
memory.ReadGlobalAddress (stack + offset);
+ regs [regoffset].SetValue (new_value);
+ offset += 8;
+ }
+
+ long err = memory.ReadLongInteger (stack + offset + 8);
+ long trapno = memory.ReadLongInteger (stack + offset +
16);
+
+ TargetAddress rip = new TargetAddress (
+ memory.GlobalAddressDomain, regs [(int)
X86_64_Register.RIP].GetValue ());
+ TargetAddress rsp = new TargetAddress (
+ memory.GlobalAddressDomain, regs [(int)
X86_64_Register.RSP].GetValue ());
+ TargetAddress rbp = new TargetAddress (
+ memory.GlobalAddressDomain, regs [(int)
X86_64_Register.RBP].GetValue ());
+
+ return new SimpleStackFrame (rip, rsp, rbp, regs,
frame.Level + 1);
+ }
+
+ public SimpleStackFrame TrySpecialUnwind (ITargetMemoryAccess
memory,
+ SimpleStackFrame
frame)
+ {
+ SimpleStackFrame new_frame;
+ new_frame = try_unwind_sigreturn (memory, frame);
+ if (new_frame != null)
+ return new_frame;
+
+ return null;
+ }
}
}
Modified: trunk/debugger/arch/Bfd.cs
===================================================================
--- trunk/debugger/arch/Bfd.cs 2005-10-11 12:45:38 UTC (rev 51563)
+++ trunk/debugger/arch/Bfd.cs 2005-10-11 13:09:21 UTC (rev 51564)
@@ -970,17 +970,23 @@
if ((frame.Address < StartAddress) || (frame.Address >
EndAddress))
return null;
+ SimpleStackFrame new_frame;
try {
+ new_frame = arch.TrySpecialUnwind (memory,
frame);
+ if (new_frame != null)
+ return new_frame;
+ } catch {
+ }
+
+ try {
if (frame_reader != null) {
- SimpleStackFrame new_frame =
frame_reader.UnwindStack (
- frame, memory, arch);
+ new_frame = frame_reader.UnwindStack
(frame, memory, arch);
if (new_frame != null)
return new_frame;
}
if (eh_frame_reader != null) {
- SimpleStackFrame new_frame =
eh_frame_reader.UnwindStack (
- frame, memory, arch);
+ new_frame = eh_frame_reader.UnwindStack
(frame, memory, arch);
if (new_frame != null)
return new_frame;
}
Modified: trunk/debugger/classes/TargetBinaryAccess.cs
===================================================================
--- trunk/debugger/classes/TargetBinaryAccess.cs 2005-10-11 12:45:38 UTC
(rev 51563)
+++ trunk/debugger/classes/TargetBinaryAccess.cs 2005-10-11 13:09:21 UTC
(rev 51564)
@@ -98,6 +98,9 @@
{
StringBuilder sb = new StringBuilder ();
+ if (data == null)
+ return "[]";
+
sb.Append ("\n" + TargetAddress.FormatAddress (0) + "
");
for (int i = 0; i < data.Length; i++) {
Modified: trunk/debugger/interfaces/IArchitecture.cs
===================================================================
--- trunk/debugger/interfaces/IArchitecture.cs 2005-10-11 12:45:38 UTC (rev
51563)
+++ trunk/debugger/interfaces/IArchitecture.cs 2005-10-11 13:09:21 UTC (rev
51564)
@@ -110,5 +110,7 @@
SimpleStackFrame UnwindStack (ITargetMemoryAccess memory,
TargetAddress stack,
TargetAddress frame_address);
+
+ SimpleStackFrame TrySpecialUnwind (ITargetMemoryAccess memory,
SimpleStackFrame frame);
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches