diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-06-28 12:15:31 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-06-28 12:15:31 +0000 |
| commit | 8e7fdbc150ad2f17837d87c3e700e66cdb84b3ea (patch) | |
| tree | a883de5a12f28cc44fc76b04e34d43db37d63d84 /Source/Core/Common | |
| parent | 7c92dada85f70a11db784bf4b7491f963d740b0b (diff) | |
cleanup: extract breakpoint code into Common. only have one shared PPCDebugInterface.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3567 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Common.vcproj | 8 | ||||
| -rw-r--r-- | Source/Core/Common/Src/BreakPoints.cpp | 154 | ||||
| -rw-r--r-- | Source/Core/Common/Src/BreakPoints.h | 100 | ||||
| -rw-r--r-- | Source/Core/Common/Src/DebugInterface.h | 1 | ||||
| -rw-r--r-- | Source/Core/Common/Src/SConscript | 1 |
5 files changed, 264 insertions, 0 deletions
diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index bfd4fbfe2c..ccb0a04cd3 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -557,6 +557,14 @@ >
</File>
<File
+ RelativePath=".\Src\BreakPoints.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Src\BreakPoints.h"
+ >
+ </File>
+ <File
RelativePath=".\Src\CDUtils.cpp"
>
</File>
diff --git a/Source/Core/Common/Src/BreakPoints.cpp b/Source/Core/Common/Src/BreakPoints.cpp new file mode 100644 index 0000000000..446852028c --- /dev/null +++ b/Source/Core/Common/Src/BreakPoints.cpp @@ -0,0 +1,154 @@ +// Copyright (C) 2003-2009 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "Common.h" + +#include "DebugInterface.h" +#include "BreakPoints.h" + +void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bool write, int size, u32 pc) +{ + if ((write && OnWrite) || (!write && OnRead)) + { + if (Log) + { + DEBUG_LOG(MEMMAP, "CHK %08x %s%i at %08x (%s)", + iValue, write ? "Write" : "Read", // read or write + size*8, addr, // address + debug_interface->GetDescription(addr).c_str() // symbol map description + ); + } + if (Break) + debug_interface->breakNow(); + } +} + +bool BreakPoints::IsAddressBreakPoint(u32 _iAddress) +{ + std::vector<TBreakPoint>::iterator iter; + for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter) + if ((*iter).iAddress == _iAddress) + return true; + return false; +} + +bool BreakPoints::IsTempBreakPoint(u32 _iAddress) +{ + std::vector<TBreakPoint>::iterator iter; + + for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter) + if ((*iter).iAddress == _iAddress && (*iter).bTemporary) + return true; + + return false; +} + +bool BreakPoints::Add(u32 em_address, bool temp) +{ + if (!IsAddressBreakPoint(em_address)) // only add new addresses + { + TBreakPoint pt; // breakpoint settings + pt.bOn = true; + pt.bTemporary = temp; + pt.iAddress = em_address; + + m_BreakPoints.push_back(pt); + return true; + } else { + return false; + } +} + +bool BreakPoints::Remove(u32 _iAddress) +{ + std::vector<TBreakPoint>::iterator iter; + for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter) + { + if ((*iter).iAddress == _iAddress) + { + m_BreakPoints.erase(iter); + return true; + } + } + return false; +} + +void BreakPoints::Clear() +{ + m_BreakPoints.clear(); +} + +void BreakPoints::DeleteByAddress(u32 _Address) +{ + // first check breakpoints + { + std::vector<TBreakPoint>::iterator iter; + for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter) + { + if ((*iter).iAddress == _Address) + { + m_BreakPoints.erase(iter); + return; + } + } + } +} + +void MemChecks::Add(const TMemCheck& _rMemoryCheck) +{ + m_MemChecks.push_back(_rMemoryCheck); +} + + +TMemCheck *MemChecks::GetMemCheck(u32 address) +{ + std::vector<TMemCheck>::iterator iter; + for (iter = m_MemChecks.begin(); iter != m_MemChecks.end(); ++iter) + { + if ((*iter).bRange) + { + if (address >= (*iter).StartAddress && address <= (*iter).EndAddress) + return &(*iter); + } + else + { + if ((*iter).StartAddress == address) + return &(*iter); + } + } + + //none found + return 0; +} + +void MemChecks::Clear() +{ + m_MemChecks.clear(); +} + +void MemChecks::DeleteByAddress(u32 _Address) +{ + std::vector<TMemCheck>::iterator iter; + for (iter = m_MemChecks.begin(); iter != m_MemChecks.end(); ++iter) + { + if ((*iter).StartAddress == _Address) + { + m_MemChecks.erase(iter); + return; + } + } +} diff --git a/Source/Core/Common/Src/BreakPoints.h b/Source/Core/Common/Src/BreakPoints.h new file mode 100644 index 0000000000..ef40da7419 --- /dev/null +++ b/Source/Core/Common/Src/BreakPoints.h @@ -0,0 +1,100 @@ +// Copyright (C) 2003-2009 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _DEBUGGER_BREAKPOINTS_H +#define _DEBUGGER_BREAKPOINTS_H + +#include <vector> +#include <string> + +#include "Common.h" + +class DebugInterface; + +struct TBreakPoint +{ + u32 iAddress; + bool bOn; + bool bTemporary; +}; + +struct TMemCheck +{ + TMemCheck() { + numHits = 0; + } + u32 StartAddress; + u32 EndAddress; + + bool bRange; + + bool OnRead; + bool OnWrite; + + bool Log; + bool Break; + + u32 numHits; + + void Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr, bool write, int size, u32 pc); +}; + +// Code breakpoints. +class BreakPoints +{ +public: + typedef std::vector<TBreakPoint> TBreakPoints; + + const TBreakPoints& GetBreakPoints() { return m_BreakPoints; } + + // is address breakpoint + bool IsAddressBreakPoint(u32 _iAddress); + bool IsTempBreakPoint(u32 _iAddress); + + // AddBreakPoint + bool Add(u32 em_address, bool temp=false); + + // Remove Breakpoint + bool Remove(u32 _iAddress); + void Clear(); + + void DeleteByAddress(u32 _Address); + +private: + TBreakPoints m_BreakPoints; + u32 m_iBreakOnCount; +}; + + +// Memory breakpoints +class MemChecks +{ +public: + typedef std::vector<TMemCheck> TMemChecks; + TMemChecks m_MemChecks; + const TMemChecks& GetMemChecks() { return m_MemChecks; } + void Add(const TMemCheck& _rMemoryCheck); + + //memory breakpoint + TMemCheck *GetMemCheck(u32 address); + void DeleteByAddress(u32 _Address); + + void Clear(); +}; + +#endif + diff --git a/Source/Core/Common/Src/DebugInterface.h b/Source/Core/Common/Src/DebugInterface.h index 804125b8dd..3e8a93e8b9 100644 --- a/Source/Core/Common/Src/DebugInterface.h +++ b/Source/Core/Common/Src/DebugInterface.h @@ -27,6 +27,7 @@ public: virtual void setPC(unsigned int /*address*/) {} virtual void step() {} virtual void runToBreakpoint() {} + virtual void breakNow() {} virtual void insertBLR(unsigned int /*address*/, unsigned int) {} virtual int getColor(unsigned int /*address*/){return 0xFFFFFFFF;} virtual std::string getDescription(unsigned int /*address*/) = 0; diff --git a/Source/Core/Common/Src/SConscript b/Source/Core/Common/Src/SConscript index 6ceba317a2..07e6ff313f 100644 --- a/Source/Core/Common/Src/SConscript +++ b/Source/Core/Common/Src/SConscript @@ -5,6 +5,7 @@ import sys files = [ "ABI.cpp", + "BreakPoints.cpp", "CDUtils.cpp", "ChunkFile.cpp", "ColorUtil.cpp", |
