blob: da015dc81912a8e4e9ba0a6d7cdec781cea0dcbd [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) :
34 BreakpointResolver (bkpt),
35 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);
59 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
60
61 sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, sc_list);
62 for (int i = 0; i < sc_list_size; i++)
63 {
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 {
70 BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
71 if (log && bp_loc_sp && !m_breakpoint->IsInternal())
72 {
73 StreamString s;
74 bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
75 log->Printf ("Added location: %s\n", s.GetData());
76 }
77 }
78 else
79 {
80 if (log)
81 log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n",
82 line_start.GetFileAddress(),
83 m_file_spec.GetFilename().AsCString("<Unknown>"),
84 m_line_number);
85 }
86 }
87 else
88 {
89#if 0
90 s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n";
91 if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset))
92 s.EOL();
93 if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset))
94 s.EOL();
95 if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress))
96 s.EOL();
97 if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress))
98 s.EOL();
99#endif
100 }
101 }
102 return Searcher::eCallbackReturnContinue;
103}
104
105Searcher::Depth
106BreakpointResolverFileLine::GetDepth()
107{
108 return Searcher::eDepthCompUnit;
109}
110
111void
112BreakpointResolverFileLine::GetDescription (Stream *s)
113{
Greg Clayton12bec712010-06-28 21:30:43 +0000114 s->Printf ("file ='%s', line = %u", m_file_spec.GetFilename().AsCString(), m_line_number);
Chris Lattner24943d22010-06-08 16:52:24 +0000115}
116
117void
118BreakpointResolverFileLine::Dump (Stream *s) const
119{
120
121}
122