From 4d441a9746616b2e45397097e6a7600a67aa973c Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Sat, 7 Aug 2010 05:35:29 -0800 Subject: watchpoint facility for ptx debugging [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 7160] --- src/cuda-sim/memory.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/cuda-sim/memory.cc') diff --git a/src/cuda-sim/memory.cc b/src/cuda-sim/memory.cc index 09c9e81..b825f12 100644 --- a/src/cuda-sim/memory.cc +++ b/src/cuda-sim/memory.cc @@ -63,6 +63,7 @@ #include "memory.h" #include +#include "../debug.h" template memory_space_impl::memory_space_impl( std::string name, unsigned hash_size ) { @@ -79,13 +80,21 @@ template memory_space_impl::memory_space_impl( std::strin assert( m_log2_block_size != (unsigned)-1 ); } -template void memory_space_impl::write( mem_addr_t addr, size_t length, const void *data ) +template void memory_space_impl::write( mem_addr_t addr, size_t length, const void *data, class ptx_thread_info *thd, const ptx_instruction *pI) { mem_addr_t index = addr >> m_log2_block_size; unsigned offset = addr & (BSIZE-1); unsigned nbytes = length; assert( (addr+length) <= (index+1)*BSIZE ); m_data[index].write(offset,nbytes,(const unsigned char*)data); + if( !m_watchpoints.empty() ) { + std::map::iterator i; + for( i=m_watchpoints.begin(); i!=m_watchpoints.end(); i++ ) { + mem_addr_t wa = i->second; + if( ((addr<=wa) && ((addr+length)>wa)) || ((addr>wa) && (addr < (wa+4))) ) + hit_watchpoint(i->first,thd,pI); + } + } } template void memory_space_impl::read( mem_addr_t addr, size_t length, void *data ) const @@ -119,6 +128,11 @@ template void memory_space_impl::print( const char *forma } } +template void memory_space_impl::set_watch( addr_t addr, unsigned watchpoint ) +{ + m_watchpoints[watchpoint]=addr; +} + template class memory_space_impl<32>; template class memory_space_impl<64>; template class memory_space_impl<8192>; @@ -137,7 +151,7 @@ int main(int argc, char *argv[] ) memory_space *mem = new memory_space_impl<32>("test",4); // write address to [address] for( mem_addr_t addr=0; addr < 16*1024; addr+=4) - mem->write(addr,4,&addr); + mem->write(addr,4,&addr,NULL,NULL); for( mem_addr_t addr=0; addr < 16*1024; addr+=4) { unsigned tmp=0; @@ -150,7 +164,7 @@ int main(int argc, char *argv[] ) for( mem_addr_t addr=0; addr < 16*1024; addr+=1) { unsigned char val = (addr + 128) % 256; - mem->write(addr,1,&val); + mem->write(addr,1,&val,NULL,NULL); } for( mem_addr_t addr=0; addr < 16*1024; addr+=1) { -- cgit v1.3