blob: 224dd158f672193cc3bad77e1aa3763b22c460a3 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- BreakpointResolverFileLine.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/BreakpointResolverFileLine.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16#include "lldb/Breakpoint/BreakpointLocation.h"
17#include "lldb/Core/Log.h"
18#include "lldb/Core/StreamString.h"
19#include "lldb/lldb-private-log.h"
20
21using namespace lldb;
22using namespace lldb_private;
23
24//----------------------------------------------------------------------
25// BreakpointResolverFileLine:
26//----------------------------------------------------------------------
27BreakpointResolverFileLine::BreakpointResolverFileLine
28(
29 Breakpoint *bkpt,
30 const FileSpec &file_spec,
31 uint32_t line_no,
32 bool check_inlines
33) :
Johnny Chena62ad7c2010-10-28 17:27:46 +000034 BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver),
Chris Lattner24943d22010-06-08 16:52:24 +000035 m_file_spec (file_spec),
36 m_line_number (line_no),
37 m_inlines (check_inlines)
38{
39}
40
41BreakpointResolverFileLine::~BreakpointResolverFileLine ()
42{
43}
44
45Searcher::CallbackReturn
46BreakpointResolverFileLine::SearchCallback
47(
48 SearchFilter &filter,
49 SymbolContext &context,
50 Address *addr,
51 bool containing
52)
53{
54 SymbolContextList sc_list;
55 uint32_t sc_list_size;
56 CompileUnit *cu = context.comp_unit;
57
58 assert (m_breakpoint != NULL);
Greg Claytone005f2c2010-11-06 01:53:30 +000059 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +000060
61 sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, sc_list);
Greg Clayton54e7afa2010-07-09 20:39:50 +000062 for (uint32_t i = 0; i < sc_list_size; i++)
Chris Lattner24943d22010-06-08 16:52:24 +000063 {
64 SymbolContext sc;
65 if (sc_list.GetContextAtIndex(i, sc))
66 {
67 Address line_start = sc.line_entry.range.GetBaseAddress();
68 if (line_start.IsValid())
69 {
Jim Ingham03c8ee52011-09-21 01:17:13 +000070 if (filter.AddressPasses(line_start))
Chris Lattner24943d22010-06-08 16:52:24 +000071 {
Jim Ingham03c8ee52011-09-21 01:17:13 +000072 BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
73 if (log && bp_loc_sp && !m_breakpoint->IsInternal())
74 {
75 StreamString s;
76 bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
77 log->Printf ("Added location: %s\n", s.GetData());
78 }
79 }
80 else if (log)
81 {
82 log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass the filter.\n",
83 line_start.GetFileAddress(),
84 m_file_spec.GetFilename().AsCString("<Unknown>"),
85 m_line_number);
Chris Lattner24943d22010-06-08 16:52:24 +000086 }
87 }
88 else
89 {
90 if (log)
91 log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n",
92 line_start.GetFileAddress(),
93 m_file_spec.GetFilename().AsCString("<Unknown>"),
94 m_line_number);
95 }
96 }
97 else
98 {
99#if 0
100 s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n";
101 if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset))
102 s.EOL();
103 if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset))
104 s.EOL();
105 if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress))
106 s.EOL();
107 if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress))
108 s.EOL();
109#endif
110 }
111 }
112 return Searcher::eCallbackReturnContinue;
113}
114
115Searcher::Depth
116BreakpointResolverFileLine::GetDepth()
117{
118 return Searcher::eDepthCompUnit;
119}
120
121void
122BreakpointResolverFileLine::GetDescription (Stream *s)
123{
Greg Clayton12bec712010-06-28 21:30:43 +0000124 s->Printf ("file ='%s', line = %u", m_file_spec.GetFilename().AsCString(), m_line_number);
Chris Lattner24943d22010-06-08 16:52:24 +0000125}
126
127void
128BreakpointResolverFileLine::Dump (Stream *s) const
129{
130
131}
132