public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Check memory address alignment before setting watchpoint. Date: Tue, 13 May 2008 14:38:00 -0000 [thread overview] Message-ID: <20080513143849.23155.qmail@sourceware.org> (raw) The branch, master has been updated via e62c4482adaf39915db4f42983327a7b715d316a (commit) from d5bc17c1a45b723f2dcf3b87e5f0695de83524c3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit e62c4482adaf39915db4f42983327a7b715d316a Author: Phil Muldoon <pmuldoon@redhat.com> Date: Tue May 13 15:37:46 2008 +0100 Check memory address alignment before setting watchpoint. 2008-05-13 Phil Muldoon <pmuldoon@redhat.com> * TestTaskObserverWatchpoint.java (testAddFailed): Add alignment test. 2008-05-13 Phil Muldoon <pmuldoon@redhat.com> * IA32WatchpointFunctions.java (setWatchpoint): Add alignment check. * X8664WatchpointFunctions.java (setWatchpoint): Ditto. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/isa/watchpoints/ChangeLog | 5 ++++ .../isa/watchpoints/IA32WatchpointFunctions.java | 4 +++ .../isa/watchpoints/X8664WatchpointFunctions.java | 6 ++++- frysk-core/frysk/proc/ChangeLog | 4 +++ .../frysk/proc/TestTaskObserverWatchpoint.java | 26 +++++++++---------- 5 files changed, 30 insertions(+), 15 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/isa/watchpoints/ChangeLog b/frysk-core/frysk/isa/watchpoints/ChangeLog index 961ea10..8c86788 100644 --- a/frysk-core/frysk/isa/watchpoints/ChangeLog +++ b/frysk-core/frysk/isa/watchpoints/ChangeLog @@ -1,3 +1,8 @@ +2008-05-13 Phil Muldoon <pmuldoon@redhat.com> + + * IA32WatchpointFunctions.java (setWatchpoint): Add alignment check. + * X8664WatchpointFunctions.java (setWatchpoint): Ditto. + 2008-05-07 Teresa Thomas <tthomas@redhat.com> * IA32WatchpointFunctions.java (setWatchpoint): Fix diff --git a/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java b/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java index ce962aa..8d170df 100644 --- a/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java +++ b/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java @@ -71,6 +71,10 @@ class IA32WatchpointFunctions extends WatchpointFunctions { // turn bit on ( b= bit no): l |= (1L << b); if ((range == 1) || (range == 2) || (range == 4)) { + if ((addr &~ (range -1)) != addr) + throw new RuntimeException("Address 0x"+Long.toHexString(addr) + + " is not aligned on a " + range + " byte boundary. Cannot set watchpoint."); + // Set the Debug register with the linear address. task.setRegister(IA32Registers.DEBUG_REGS_GROUP.getRegisters()[index], addr); diff --git a/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java b/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java index 11f5030..7104854 100644 --- a/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java +++ b/frysk-core/frysk/isa/watchpoints/X8664WatchpointFunctions.java @@ -65,11 +65,15 @@ class X8664WatchpointFunctions extends WatchpointFunctions { public void setWatchpoint(Task task, int index, long addr, int range, boolean writeOnly) { - + // turn bit off (b = bit no): l &= ~(1L << b) // turn bit on ( b= bit no): l |= (1L << b); if ((range == 1) || (range == 2) || (range == 4) || (range == 8)) { + if ((addr &~ (range -1)) != addr) + throw new RuntimeException("Address 0x"+Long.toHexString(addr) + + " is not aligned on a " + range + " byte boundary. Cannot set watchpoint."); + // Set the Debug register with the linear address. task.setRegister(X8664Registers.DEBUG_REGS_GROUP.getRegisters()[index], addr); diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index ab70cc1..d5b5a7f 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,3 +1,7 @@ +2008-05-13 Phil Muldoon <pmuldoon@redhat.com> + + * TestTaskObserverWatchpoint.java (testAddFailed): Add alignment test. + 2008-05-12 Phil Muldoon <pmuldoon@redhat.com> * TestTaskObserverWatchpoint.java (testAddFailed): New. diff --git a/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java b/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java index a100008..94fdfde 100644 --- a/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java +++ b/frysk-core/frysk/proc/TestTaskObserverWatchpoint.java @@ -177,12 +177,8 @@ extends TestLib } - // This test case tests whether watchpoints are caught when a task is in a straight - // "running" condition. This really tests the basic and advertised functionality of watchpoints: - // to be caught by hardware, not software. In this test: set up the watchpoint, set up - // a terminated observer to guard the watchpoint was caught, and simply set the task to run. - // If the watchpoint observer is called, and the test is blocked then the test passes. If the - // process terminates and the watchpoint is not caught, then this signified an error condition. + // This test case tests whether watchpoints addFailed is called on + // a variety of error conditions. public void testAddFailed () { if (unresolvedOnPPC(5991)) return; @@ -209,21 +205,23 @@ extends TestLib // Find Variable source for watch long address = getGlobalSymbolAddress(task,"source"); - // Add watch observer - AddFailWatchObserver watch = new AddFailWatchObserver(); - task.requestAddWatchObserver(watch, address, 72, true); - task.requestUnblock(co); + // Add bad length watch observer + AddFailWatchObserver badLength = new AddFailWatchObserver(); + task.requestAddWatchObserver(badLength, address, 72, true); + + AddFailWatchObserver badAlignment = new AddFailWatchObserver(); + task.requestAddWatchObserver(badAlignment, address-1, 4, true); + task.requestUnblock(co); assertRunUntilStop("Run and test watchpoint "); - // Make sure it triggered. - assertTrue("addedFailed", watch.addFailed); + assertTrue("addedFailed on length", badLength.addFailed); + assertTrue("addedFailed on bad alignment", badAlignment.addFailed); + // Delete both observers. task.requestDeleteCodeObserver(co, mainAddress); runPending(); - - } // This test case tests whether 'read or write' watchpoints are caught when a task is in a straight hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-05-13 14:38 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=20080513143849.23155.qmail@sourceware.org \ --to=pmuldoon@sourceware.org \ --cc=frysk-cvs@sourceware.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: linkBe 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).