From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26781 invoked by alias); 3 Apr 2008 13:00:19 -0000 Received: (qmail 26657 invoked by uid 9514); 3 Apr 2008 13:00:03 -0000 Date: Thu, 03 Apr 2008 13:00:00 -0000 Message-ID: <20080403130002.26637.qmail@sourceware.org> From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Create Watchpoint data class. Return Watchpoint class instead of long. Do not allow user to set global/local flags. Add new test,testing new getAllWatchPoints() funtion. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 21953327b97883d2adb9423c3dad56fc319f2f12 X-Git-Newrev: 72db660d1ea985caa145e3cf93880c6e705d8b51 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q2/txt/msg00027.txt.bz2 The branch, master has been updated via 72db660d1ea985caa145e3cf93880c6e705d8b51 (commit) from 21953327b97883d2adb9423c3dad56fc319f2f12 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 72db660d1ea985caa145e3cf93880c6e705d8b51 Author: Phil Muldoon Date: Thu Apr 3 13:58:27 2008 +0100 Create Watchpoint data class. Return Watchpoint class instead of long. Do not allow user to set global/local flags. Add new test,testing new getAllWatchPoints() funtion. 2008-04-03 Phil Muldoon * TestWatchpoint.java (Symbol.Symbol): New temporary class to resolve Elf symbols. (getGlobalSymbolAddress): New function. (testWatchFourBytesBitPattern): Adjust to use funit-watchpoints.S. GetAddress from Watchpoint.java (testWatchTwoBytesBitPattern): Ditto. (testWatchOneByteBitPattern): Ditto. (testGetAllWatchpoints): New. * IA32WatchpointFunctions.java (setWatchpoint): Delete localOnly flag. Remove local/global breakpoint bit logic. (readWatchpoint): Rewrite. Return Watchpoint. * X8664WatchpointFunctions.java (setWatchpoint): Delete localOnly flag. Remove local/global breakpoint bit logic. (readWatchpoint): Rewrite. Return Watchpoint. * WatchpointFunctions.java (getAllWatchpoints): New. Implement. (setWatchpoint): Remove localOnly flag. (readWatchpoint): return a Watchpoint class over a long. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/isa/watchpoints/ChangeLog | 20 +++ .../isa/watchpoints/IA32WatchpointFunctions.java | 67 +++++++--- .../frysk/isa/watchpoints/TestWatchpoint.java | 135 +++++++++++++++++--- .../watchpoints/Watchpoint.java} | 98 +++++++-------- .../frysk/isa/watchpoints/WatchpointFunctions.java | 25 +++- .../isa/watchpoints/X8664WatchpointFunctions.java | 65 +++++++--- 6 files changed, 299 insertions(+), 111 deletions(-) copy frysk-core/frysk/{symtab/Symbol.java => isa/watchpoints/Watchpoint.java} (53%) First 500 lines of diff: diff --git a/frysk-core/frysk/isa/watchpoints/ChangeLog b/frysk-core/frysk/isa/watchpoints/ChangeLog index e3f419a..93952e1 100644 --- a/frysk-core/frysk/isa/watchpoints/ChangeLog +++ b/frysk-core/frysk/isa/watchpoints/ChangeLog @@ -1,3 +1,23 @@ +2008-04-03 Phil Muldoon + + * TestWatchpoint.java (Symbol.Symbol): New temporary class to resolve + Elf symbols. + (getGlobalSymbolAddress): New function. + (testWatchFourBytesBitPattern): Adjust to use funit-watchpoints.S. + GetAddress from Watchpoint.java + (testWatchTwoBytesBitPattern): Ditto. + (testWatchOneByteBitPattern): Ditto. + (testGetAllWatchpoints): New. + * IA32WatchpointFunctions.java (setWatchpoint): Delete localOnly flag. + Remove local/global breakpoint bit logic. + (readWatchpoint): Rewrite. Return Watchpoint. + * X8664WatchpointFunctions.java (setWatchpoint): Delete localOnly flag. + Remove local/global breakpoint bit logic. + (readWatchpoint): Rewrite. Return Watchpoint. + * WatchpointFunctions.java (getAllWatchpoints): New. Implement. + (setWatchpoint): Remove localOnly flag. + (readWatchpoint): return a Watchpoint class over a long. + 2008-04-02 Phil Muldoon * Watchpoint.java: Refactor to WatchpointFunctions.java diff --git a/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java b/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java index 15117c5..e2883c7 100644 --- a/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java +++ b/frysk-core/frysk/isa/watchpoints/IA32WatchpointFunctions.java @@ -65,8 +65,7 @@ class IA32WatchpointFunctions extends WatchpointFunctions { */ public void setWatchpoint(Task task, int index, long addr, int range, - boolean writeOnly, - boolean localOnly) { + boolean writeOnly) { // turn bit off (b = bit no): l &= ~(1L << b) @@ -86,17 +85,10 @@ class IA32WatchpointFunctions extends WatchpointFunctions { // Calculate "Global Exact Breakpoint #index Enabled" bit to set int bitToSet = index * 2; - if (localOnly) { - // Set "Local Exact Breakpoint #index Enabled" to 0 - debugControl |= (1L << bitToSet); - // Set Global Exact Breakpoint to 1 - debugControl &= ~(1L << bitToSet+1); - } else { - // Set "Local Exact Breakpoint #index Enabled" to 0 - debugControl &= ~(1L << bitToSet); - // Set Global Exact Breakpoint to 1 - debugControl |= (1L << bitToSet+1); - } + // Set "Local Exact Breakpoint #index Enabled" to 0 + debugControl &= ~(1L << bitToSet); + // Set Global Exact Breakpoint to 1 + debugControl |= (1L << bitToSet+1); // Dending on the WP register to set, the next // 4 bits are offset 4 * WP Count. On x8664 @@ -148,18 +140,53 @@ class IA32WatchpointFunctions extends WatchpointFunctions { "range. Has to be 1, 2, 4 or 8"); } + /** * Reads a watchpoint. Takes a task, and an index. * * @param task - task to read a watchpoint from. * @param index - watchpoint number to read. - * - * @return long - value of register for watchpoint. + + * @return Watchpoint - value of Watchpoint at + * register. */ - public long readWatchpoint(Task task, int index) { - return task.getRegister(IA32Registers.DEBUG_REGS_GROUP.getRegisters()[index]); - } + public Watchpoint readWatchpoint(Task task, int index) { + // Get Address from watchpoint register + long address = task.getRegister( + IA32Registers.DEBUG_REGS_GROUP.getRegisters()[index]); + + // Get debug status register for all other values + long debugStatus = task.getRegister(IA32Registers.DEBUG_CONTROL); + boolean writeOnly = false; + + // To find write/read, or read only the bit setting is 0 + no of + // register to check * 4 bits (each register has four bits assigned + // for r/w and global/local bits. + int typeOfWpTrap = 16 + (index *4); + + // if 1 and 0 set, must be writeOnly. + if ( (testBit(debugStatus,typeOfWpTrap)) && (!testBit(debugStatus,typeOfWpTrap+1))) + writeOnly = true; + + // Move over +2 bits for length + int lengthOfWP = typeOfWpTrap + 2; + int length = 0; + + // Test length on combination of bits. 00 = 1, 01 = 2 + // 11 = 4. + if (!testBit(debugStatus,lengthOfWP)) + if (!testBit(debugStatus,lengthOfWP+1)) + length = 1; + else + length = 2; + else + if (testBit(debugStatus, lengthOfWP)) + length = 4; + return Watchpoint.create(address, length, index, writeOnly); + } + + /** * Deletes a watchpoint. Takes a task, and an index. * @@ -219,6 +246,10 @@ class IA32WatchpointFunctions extends WatchpointFunctions { public long readControlRegister(Task task) { return task.getRegister(IA32Registers.DEBUG_CONTROL); } + + private boolean testBit(long register, int bitToTest) { + return (register & (1L << bitToTest)) != 0; + } } diff --git a/frysk-core/frysk/isa/watchpoints/TestWatchpoint.java b/frysk-core/frysk/isa/watchpoints/TestWatchpoint.java index 49e5ceb..db52a10 100644 --- a/frysk-core/frysk/isa/watchpoints/TestWatchpoint.java +++ b/frysk-core/frysk/isa/watchpoints/TestWatchpoint.java @@ -40,6 +40,17 @@ package frysk.isa.watchpoints; +import java.util.ArrayList; +import java.util.Iterator; + +import lib.dwfl.Dwfl; +import lib.dwfl.DwflModule; +import lib.dwfl.ElfSymbolBinding; +import lib.dwfl.ElfSymbolType; +import lib.dwfl.ElfSymbolVisibility; +import lib.dwfl.SymbolBuilder; +import frysk.config.Config; +import frysk.dwfl.DwflCache; import frysk.proc.Proc; import frysk.proc.Task; import frysk.testbed.DaemonBlockedAtEntry; @@ -56,17 +67,17 @@ public class TestWatchpoint extends TestLib { return; Proc proc = giveMeABlockedProc(); Task task = proc.getMainTask(); - long address = 0x1000; + long address = getGlobalSymbolAddress(task,"source"); long debugControlRegister; WatchpointFunctions wp = WatchpointFunctionFactory.getWatchpoint(task.getISA()); long savedDebugControlRegister = wp.readControlRegister(task); for (int i=0; i<4; i++) { - wp.setWatchpoint(task, i, address, 4, false, false); + wp.setWatchpoint(task, i, address, 4, false); // simple first test. Does register contain address? assertEquals("Saved watchpoint and address are similar", - address, wp.readWatchpoint(task, i)); + address, wp.readWatchpoint(task, i).getAddress()); debugControlRegister = wp.readControlRegister(task); @@ -92,7 +103,7 @@ public class TestWatchpoint extends TestLib { for (int j=0; j < 4; j++) { wp.deleteWatchpoint(task,j); assertEquals("Deleted Watchpoint is 0", - wp.readWatchpoint(task, j),0); + wp.readWatchpoint(task, j).getAddress(),0); } assertEquals("Debug control register is left as we originally found it", @@ -109,17 +120,17 @@ public class TestWatchpoint extends TestLib { return; Proc proc = giveMeABlockedProc(); Task task = proc.getMainTask(); - long address = 0x1000; + long address = getGlobalSymbolAddress(task,"source"); long debugControlRegister; WatchpointFunctions wp = WatchpointFunctionFactory.getWatchpoint(task.getISA()); long savedDebugControlRegister = wp.readControlRegister(task); for (int i=0; i<4; i++) { - wp.setWatchpoint(task, i, address, 1, true, false); + wp.setWatchpoint(task, i, address, 1, true); // simple first test. Does register contain address? assertEquals("Saved watchpoint and address are similar", - address, wp.readWatchpoint(task, i)); + address, wp.readWatchpoint(task, i).getAddress()); debugControlRegister = wp.readControlRegister(task); @@ -145,7 +156,7 @@ public class TestWatchpoint extends TestLib { for (int j=0; j < 4; j++) { wp.deleteWatchpoint(task,j); assertEquals("Deleted Watchpoint is 0", - wp.readWatchpoint(task, j),0); + wp.readWatchpoint(task, j).getAddress(),0); } assertEquals("Debug control register is left as we originally found it", @@ -164,25 +175,25 @@ public class TestWatchpoint extends TestLib { return; Proc proc = giveMeABlockedProc(); Task task = proc.getMainTask(); - long address = 0x0; + long address = getGlobalSymbolAddress(task,"source"); long debugControlRegister; WatchpointFunctions wp = WatchpointFunctionFactory.getWatchpoint(task.getISA()); long savedDebugControlRegister = wp.readControlRegister(task); for (int i=0; i<4; i++) { - wp.setWatchpoint(task, i, address, 1, false, true); + wp.setWatchpoint(task, i, address, 1, false); // simple first test. Does register contain address? assertEquals("Saved watchpoint and address are similar", - address, wp.readWatchpoint(task, i)); + address, wp.readWatchpoint(task, i).getAddress()); debugControlRegister = wp.readControlRegister(task); - // Test Debug Control Register Bit Pattern. Local Exact. - assertEquals(i + " wp local exact bit", true, + // Test Debug Control Register Bit Pattern. Global Exact. + assertEquals(i + " wp local exact bit", false, testBit(debugControlRegister, 0 + (i*2))); - assertEquals(i + " wp global exact bit", false, + assertEquals(i + " wp global exact bit", true, testBit(debugControlRegister, 1 + (i*2))); // Test Debug Control Register. Fire on Read and Write @@ -201,7 +212,7 @@ public class TestWatchpoint extends TestLib { for (int j=0; j < 4; j++) { wp.deleteWatchpoint(task,j); assertEquals("Deleted Watchpoint is 0", - wp.readWatchpoint(task, j),0); + wp.readWatchpoint(task, j).getAddress(),0); } assertEquals("Debug control register is left as we originally found it", @@ -209,17 +220,103 @@ public class TestWatchpoint extends TestLib { } + public void testGetAllWatchpoints () { + // Set maximum number of watchpoints, then test them + // via getAll. + if (unresolvedOnPPC(5991)) + return; + int lengthSet[] = {1,1,2,4}; + int count = 0; + Proc proc = giveMeABlockedProc(); + Task task = proc.getMainTask(); + long address = getGlobalSymbolAddress(task,"source"); + WatchpointFunctions wp = WatchpointFunctionFactory.getWatchpoint(task.getISA()); + for (int i=0; i