summaryrefslogtreecommitdiffstats
path: root/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
blob: 86e05964485923d21ca26f207a6ae370f4c3362d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//===-- BreakpointResolverFileLine.cpp --------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "lldb/Breakpoint/BreakpointResolverFileLine.h"

// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/StreamString.h"
#include "lldb/lldb-private-log.h"

using namespace lldb;
using namespace lldb_private;

//----------------------------------------------------------------------
// BreakpointResolverFileLine:
//----------------------------------------------------------------------
BreakpointResolverFileLine::BreakpointResolverFileLine
(
    Breakpoint *bkpt,
    const FileSpec &file_spec,
    uint32_t line_no,
    bool check_inlines
) :
    BreakpointResolver (bkpt),
    m_file_spec (file_spec),
    m_line_number (line_no),
    m_inlines (check_inlines)
{
}

BreakpointResolverFileLine::~BreakpointResolverFileLine ()
{
}

Searcher::CallbackReturn
BreakpointResolverFileLine::SearchCallback
(
    SearchFilter &filter,
    SymbolContext &context,
    Address *addr,
    bool containing
)
{
    SymbolContextList sc_list;
    uint32_t sc_list_size;
    CompileUnit *cu = context.comp_unit;

    assert (m_breakpoint != NULL);
    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);

    sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, sc_list);
    for (int i = 0; i < sc_list_size; i++)
    {
        SymbolContext sc;
        if (sc_list.GetContextAtIndex(i, sc))
        {
            Address line_start = sc.line_entry.range.GetBaseAddress();
            if (line_start.IsValid())
            {
                BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
                if (log && bp_loc_sp && !m_breakpoint->IsInternal())
                {
                    StreamString s;
                    bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
                    log->Printf ("Added location: %s\n", s.GetData());
                }
            }
            else
            {
                if (log)
                    log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n",
                                 line_start.GetFileAddress(),
                                 m_file_spec.GetFilename().AsCString("<Unknown>"),
                                 m_line_number);
            }
        }
        else
        {
#if 0
            s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n";
            if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset))
                s.EOL();
            if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset))
                s.EOL();
            if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress))
                s.EOL();
            if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress))
                s.EOL();
#endif
        }
    }
    return Searcher::eCallbackReturnContinue;
}

Searcher::Depth
BreakpointResolverFileLine::GetDepth()
{
    return Searcher::eDepthCompUnit;
}

void
BreakpointResolverFileLine::GetDescription (Stream *s)
{
    s->Printf ("File and line breakpoint - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString(), m_line_number);
}

void
BreakpointResolverFileLine::Dump (Stream *s) const
{

}

OpenPOWER on IntegriCloud