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