1ac7ddfbfSEd Maste //===-- BreakpointResolverAddress.cpp ---------------------------*- C++ -*-===// 2ac7ddfbfSEd Maste // 3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure 4ac7ddfbfSEd Maste // 5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source 6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details. 7ac7ddfbfSEd Maste // 8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===// 9ac7ddfbfSEd Maste 10ac7ddfbfSEd Maste #include "lldb/Breakpoint/BreakpointResolverAddress.h" 11ac7ddfbfSEd Maste 12ac7ddfbfSEd Maste // C Includes 13ac7ddfbfSEd Maste // C++ Includes 14ac7ddfbfSEd Maste // Other libraries and framework includes 15ac7ddfbfSEd Maste // Project includes 16ac7ddfbfSEd Maste #include "lldb/lldb-private-log.h" 17ac7ddfbfSEd Maste 18ac7ddfbfSEd Maste #include "lldb/Breakpoint/BreakpointLocation.h" 19ac7ddfbfSEd Maste #include "lldb/Core/Log.h" 20ac7ddfbfSEd Maste #include "lldb/Core/StreamString.h" 21ac7ddfbfSEd Maste #include "lldb/Target/Target.h" 22ac7ddfbfSEd Maste 23ac7ddfbfSEd Maste using namespace lldb; 24ac7ddfbfSEd Maste using namespace lldb_private; 25ac7ddfbfSEd Maste 26ac7ddfbfSEd Maste //---------------------------------------------------------------------- 27ac7ddfbfSEd Maste // BreakpointResolverAddress: 28ac7ddfbfSEd Maste //---------------------------------------------------------------------- 29ac7ddfbfSEd Maste BreakpointResolverAddress::BreakpointResolverAddress 30ac7ddfbfSEd Maste ( 31ac7ddfbfSEd Maste Breakpoint *bkpt, 32ac7ddfbfSEd Maste const Address &addr 33ac7ddfbfSEd Maste ) : 34ac7ddfbfSEd Maste BreakpointResolver (bkpt, BreakpointResolver::AddressResolver), 35ac7ddfbfSEd Maste m_addr (addr) 36ac7ddfbfSEd Maste { 37ac7ddfbfSEd Maste } 38ac7ddfbfSEd Maste 39ac7ddfbfSEd Maste BreakpointResolverAddress::~BreakpointResolverAddress () 40ac7ddfbfSEd Maste { 41ac7ddfbfSEd Maste 42ac7ddfbfSEd Maste } 43ac7ddfbfSEd Maste 44ac7ddfbfSEd Maste void 45ac7ddfbfSEd Maste BreakpointResolverAddress::ResolveBreakpoint (SearchFilter &filter) 46ac7ddfbfSEd Maste { 47ac7ddfbfSEd Maste // The address breakpoint only takes once, so if we've already set it we're done. 48ac7ddfbfSEd Maste if (m_breakpoint->GetNumLocations() > 0) 49ac7ddfbfSEd Maste return; 50ac7ddfbfSEd Maste else 51ac7ddfbfSEd Maste BreakpointResolver::ResolveBreakpoint(filter); 52ac7ddfbfSEd Maste } 53ac7ddfbfSEd Maste 54ac7ddfbfSEd Maste void 55ac7ddfbfSEd Maste BreakpointResolverAddress::ResolveBreakpointInModules 56ac7ddfbfSEd Maste ( 57ac7ddfbfSEd Maste SearchFilter &filter, 58ac7ddfbfSEd Maste ModuleList &modules 59ac7ddfbfSEd Maste ) 60ac7ddfbfSEd Maste { 61ac7ddfbfSEd Maste // The address breakpoint only takes once, so if we've already set it we're done. 62ac7ddfbfSEd Maste if (m_breakpoint->GetNumLocations() > 0) 63ac7ddfbfSEd Maste return; 64ac7ddfbfSEd Maste else 65ac7ddfbfSEd Maste BreakpointResolver::ResolveBreakpointInModules (filter, modules); 66ac7ddfbfSEd Maste } 67ac7ddfbfSEd Maste 68ac7ddfbfSEd Maste Searcher::CallbackReturn 69ac7ddfbfSEd Maste BreakpointResolverAddress::SearchCallback 70ac7ddfbfSEd Maste ( 71ac7ddfbfSEd Maste SearchFilter &filter, 72ac7ddfbfSEd Maste SymbolContext &context, 73ac7ddfbfSEd Maste Address *addr, 74ac7ddfbfSEd Maste bool containing 75ac7ddfbfSEd Maste ) 76ac7ddfbfSEd Maste { 77ac7ddfbfSEd Maste assert (m_breakpoint != NULL); 78ac7ddfbfSEd Maste 79ac7ddfbfSEd Maste if (filter.AddressPasses (m_addr)) 80ac7ddfbfSEd Maste { 81ac7ddfbfSEd Maste BreakpointLocationSP bp_loc_sp(m_breakpoint->AddLocation(m_addr)); 82ac7ddfbfSEd Maste if (bp_loc_sp && !m_breakpoint->IsInternal()) 83ac7ddfbfSEd Maste { 84ac7ddfbfSEd Maste StreamString s; 85ac7ddfbfSEd Maste bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); 86ac7ddfbfSEd Maste Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); 87ac7ddfbfSEd Maste if (log) 88ac7ddfbfSEd Maste log->Printf ("Added location: %s\n", s.GetData()); 89ac7ddfbfSEd Maste } 90ac7ddfbfSEd Maste } 91ac7ddfbfSEd Maste return Searcher::eCallbackReturnStop; 92ac7ddfbfSEd Maste } 93ac7ddfbfSEd Maste 94ac7ddfbfSEd Maste Searcher::Depth 95ac7ddfbfSEd Maste BreakpointResolverAddress::GetDepth() 96ac7ddfbfSEd Maste { 97ac7ddfbfSEd Maste return Searcher::eDepthTarget; 98ac7ddfbfSEd Maste } 99ac7ddfbfSEd Maste 100ac7ddfbfSEd Maste void 101ac7ddfbfSEd Maste BreakpointResolverAddress::GetDescription (Stream *s) 102ac7ddfbfSEd Maste { 103ac7ddfbfSEd Maste s->PutCString ("address = "); 104ac7ddfbfSEd Maste m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(), Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); 105ac7ddfbfSEd Maste } 106ac7ddfbfSEd Maste 107ac7ddfbfSEd Maste void 108ac7ddfbfSEd Maste BreakpointResolverAddress::Dump (Stream *s) const 109ac7ddfbfSEd Maste { 110ac7ddfbfSEd Maste 111ac7ddfbfSEd Maste } 112