public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* [patch] Check for SYSCALL on x86_64 after "spurious" step/trap
@ 2007-07-06 15:02 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2007-07-06 15:02 UTC (permalink / raw)
  To: frysk

[-- Attachment #1: Type: text/plain, Size: 920 bytes --]

Hi,

On some x86_64 kernels you will get a trapped event after a step out of
a syscall, but the stepping flag isn't set in that case. This is at
least the case at least on 2.6.18-8.1.6.el5, but not on any of the
Fedora kernels I ever tested with, currently 2.6.20-1.2962.fc6.

Luckily the Isa has a way to signal such an event and this patch updates
the X86_64 Isa as follows to handle this:

2007-07-06  Mark Wielaard  <mwielaard@redhat.com>

    * IsaX8664.java hasExecutedSpuriousTrap): Check for SYSCALL
    instruction.

This makes the following testcases PASS on such kernels and doesn't
change the results on any other system I tested on:

testSteppingtestHitAndRun(frysk.proc.TestBreakpoints) ...PASS
testSteppingtestInsertRemove(frysk.proc.TestBreakpoints) ...PASS
testSteppingAddLots(frysk.proc.TestBreakpoints) ...PASS
testStepSigReturn(frysk.proc.TestTaskObserverInstructionSigReturn) ...PASS

Cheers,

Mark

[-- Attachment #2: Type: text/x-patch, Size: 1031 bytes --]

Index: frysk-core/frysk/proc/IsaX8664.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/proc/IsaX8664.java,v
retrieving revision 1.18
diff -u -r1.18 IsaX8664.java
--- frysk-core/frysk/proc/IsaX8664.java	5 Jul 2007 12:40:28 -0000	1.18
+++ frysk-core/frysk/proc/IsaX8664.java	6 Jul 2007 14:49:25 -0000
@@ -336,12 +336,15 @@
    * attributed to entering a signal handler or a normal step
    * instruction notification.
    * 
-   * x86_64 doesn't generate spurious trap events and this method
-   * always returns false on this architecture.
+   * On some kernels x86_64 doesn't generate spurious trap events (or
+   * rather doesn't set the stepping flag) after returning from a
+   * SYSCALL instruction.
    */
   public boolean hasExecutedSpuriousTrap(Task task)
   {
-    return false;
+    long address = pc(task);
+    return (task.getMemory().getByte(address - 1) == (byte) 0x05
+            && task.getMemory().getByte(address - 2) == (byte) 0x0f);
   }
 
   /**

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-06 15:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-06 15:02 [patch] Check for SYSCALL on x86_64 after "spurious" step/trap Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).