public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: frysk@sourceware.org
Subject: [patch] Check for SYSCALL on x86_64 after "spurious" step/trap
Date: Fri, 06 Jul 2007 15:02:00 -0000	[thread overview]
Message-ID: <1183734114.3651.82.camel@dijkstra.wildebeest.org> (raw)

[-- 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);
   }
 
   /**

                 reply	other threads:[~2007-07-06 15:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1183734114.3651.82.camel@dijkstra.wildebeest.org \
    --to=mark@klomp.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).