2010-06-09 00:52:24 +08:00
|
|
|
//===-- LineEntry.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/Symbol/LineEntry.h"
|
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
2010-09-15 07:36:40 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
LineEntry::LineEntry() :
|
|
|
|
range(),
|
|
|
|
file(),
|
2013-09-27 09:15:46 +08:00
|
|
|
line(LLDB_INVALID_LINE_NUMBER),
|
2010-06-09 00:52:24 +08:00
|
|
|
column(0),
|
|
|
|
is_start_of_statement(0),
|
|
|
|
is_start_of_basic_block(0),
|
|
|
|
is_prologue_end(0),
|
2010-07-06 03:13:23 +08:00
|
|
|
is_epilogue_begin(0),
|
|
|
|
is_terminal_entry(0)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LineEntry::LineEntry
|
|
|
|
(
|
2012-02-24 09:59:29 +08:00
|
|
|
const lldb::SectionSP §ion_sp,
|
2010-06-09 00:52:24 +08:00
|
|
|
lldb::addr_t section_offset,
|
|
|
|
lldb::addr_t byte_size,
|
|
|
|
const FileSpec &_file,
|
|
|
|
uint32_t _line,
|
|
|
|
uint16_t _column,
|
|
|
|
bool _is_start_of_statement,
|
|
|
|
bool _is_start_of_basic_block,
|
|
|
|
bool _is_prologue_end,
|
|
|
|
bool _is_epilogue_begin,
|
|
|
|
bool _is_terminal_entry
|
|
|
|
) :
|
2012-02-24 09:59:29 +08:00
|
|
|
range(section_sp, section_offset, byte_size),
|
2010-06-09 00:52:24 +08:00
|
|
|
file(_file),
|
2016-05-12 06:46:53 +08:00
|
|
|
original_file(_file),
|
2010-06-09 00:52:24 +08:00
|
|
|
line(_line),
|
|
|
|
column(_column),
|
|
|
|
is_start_of_statement(_is_start_of_statement),
|
|
|
|
is_start_of_basic_block(_is_start_of_basic_block),
|
|
|
|
is_prologue_end(_is_prologue_end),
|
|
|
|
is_epilogue_begin(_is_epilogue_begin),
|
|
|
|
is_terminal_entry(_is_terminal_entry)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LineEntry::Clear()
|
|
|
|
{
|
|
|
|
range.Clear();
|
|
|
|
file.Clear();
|
2016-05-12 06:46:53 +08:00
|
|
|
original_file.Clear();
|
2013-09-27 09:15:46 +08:00
|
|
|
line = LLDB_INVALID_LINE_NUMBER;
|
2010-06-09 00:52:24 +08:00
|
|
|
column = 0;
|
|
|
|
is_start_of_statement = 0;
|
|
|
|
is_start_of_basic_block = 0;
|
|
|
|
is_prologue_end = 0;
|
|
|
|
is_epilogue_begin = 0;
|
|
|
|
is_terminal_entry = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
LineEntry::IsValid() const
|
|
|
|
{
|
2013-09-27 09:15:46 +08:00
|
|
|
return range.GetBaseAddress().IsValid() && line != LLDB_INVALID_LINE_NUMBER;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-03 05:44:10 +08:00
|
|
|
LineEntry::DumpStopContext(Stream *s, bool show_fullpaths) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
if (file)
|
|
|
|
{
|
2010-09-03 05:44:10 +08:00
|
|
|
if (show_fullpaths)
|
|
|
|
file.Dump (s);
|
|
|
|
else
|
|
|
|
file.GetFilename().Dump (s);
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (line)
|
|
|
|
s->PutChar(':');
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
if (line)
|
|
|
|
s->Printf ("%u", line);
|
|
|
|
else
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
LineEntry::Dump
|
|
|
|
(
|
|
|
|
Stream *s,
|
2010-09-15 07:36:40 +08:00
|
|
|
Target *target,
|
2010-06-09 00:52:24 +08:00
|
|
|
bool show_file,
|
|
|
|
Address::DumpStyle style,
|
|
|
|
Address::DumpStyle fallback_style,
|
|
|
|
bool show_range
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
if (show_range)
|
|
|
|
{
|
|
|
|
// Show address range
|
2010-09-15 07:36:40 +08:00
|
|
|
if (!range.Dump(s, target, style, fallback_style))
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Show address only
|
|
|
|
if (!range.GetBaseAddress().Dump(s,
|
2010-09-15 07:36:40 +08:00
|
|
|
target,
|
2010-06-09 00:52:24 +08:00
|
|
|
style,
|
|
|
|
fallback_style))
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-29 05:30:43 +08:00
|
|
|
if (show_file)
|
|
|
|
*s << ", file = " << file;
|
2010-06-09 00:52:24 +08:00
|
|
|
if (line)
|
|
|
|
s->Printf(", line = %u", line);
|
|
|
|
if (column)
|
|
|
|
s->Printf(", column = %u", column);
|
|
|
|
if (is_start_of_statement)
|
|
|
|
*s << ", is_start_of_statement = TRUE";
|
|
|
|
|
|
|
|
if (is_start_of_basic_block)
|
|
|
|
*s << ", is_start_of_basic_block = TRUE";
|
|
|
|
|
|
|
|
if (is_prologue_end)
|
|
|
|
*s << ", is_prologue_end = TRUE";
|
|
|
|
|
|
|
|
if (is_epilogue_begin)
|
|
|
|
*s << ", is_epilogue_begin = TRUE";
|
|
|
|
|
|
|
|
if (is_terminal_entry)
|
|
|
|
*s << ", is_terminal_entry = TRUE";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-15 07:36:40 +08:00
|
|
|
LineEntry::GetDescription (Stream *s, lldb::DescriptionLevel level, CompileUnit* cu, Target *target, bool show_address_only) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
if (level == lldb::eDescriptionLevelBrief || level == lldb::eDescriptionLevelFull)
|
|
|
|
{
|
2010-06-29 05:30:43 +08:00
|
|
|
if (show_address_only)
|
|
|
|
{
|
2010-09-15 07:36:40 +08:00
|
|
|
range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
|
2010-06-29 05:30:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-15 07:36:40 +08:00
|
|
|
range.Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
|
2010-06-29 05:30:43 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-10 09:30:46 +08:00
|
|
|
*s << ": " << file;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (line)
|
|
|
|
{
|
|
|
|
s->Printf(":%u", line);
|
|
|
|
if (column)
|
|
|
|
s->Printf(":%u", column);
|
|
|
|
}
|
|
|
|
|
2010-09-10 09:30:46 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (level == lldb::eDescriptionLevelFull)
|
|
|
|
{
|
|
|
|
if (is_start_of_statement)
|
|
|
|
*s << ", is_start_of_statement = TRUE";
|
|
|
|
|
|
|
|
if (is_start_of_basic_block)
|
|
|
|
*s << ", is_start_of_basic_block = TRUE";
|
|
|
|
|
|
|
|
if (is_prologue_end)
|
|
|
|
*s << ", is_prologue_end = TRUE";
|
|
|
|
|
|
|
|
if (is_epilogue_begin)
|
|
|
|
*s << ", is_epilogue_begin = TRUE";
|
|
|
|
|
|
|
|
if (is_terminal_entry)
|
|
|
|
*s << ", is_terminal_entry = TRUE";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (is_terminal_entry)
|
|
|
|
s->EOL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-15 07:36:40 +08:00
|
|
|
return Dump (s, target, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
lldb_private::operator< (const LineEntry& a, const LineEntry& b)
|
|
|
|
{
|
|
|
|
return LineEntry::Compare (a, b) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
LineEntry::Compare (const LineEntry& a, const LineEntry& b)
|
|
|
|
{
|
|
|
|
int result = Address::CompareFileAddress (a.range.GetBaseAddress(), b.range.GetBaseAddress());
|
|
|
|
if (result != 0)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
const lldb::addr_t a_byte_size = a.range.GetByteSize();
|
|
|
|
const lldb::addr_t b_byte_size = b.range.GetByteSize();
|
|
|
|
|
|
|
|
if (a_byte_size < b_byte_size)
|
|
|
|
return -1;
|
|
|
|
if (a_byte_size > b_byte_size)
|
|
|
|
return +1;
|
|
|
|
|
|
|
|
// Check for an end sequence entry mismatch after we have determined
|
|
|
|
// that the address values are equal. If one of the items is an end
|
|
|
|
// sequence, we don't care about the line, file, or column info.
|
|
|
|
if (a.is_terminal_entry > b.is_terminal_entry)
|
|
|
|
return -1;
|
|
|
|
if (a.is_terminal_entry < b.is_terminal_entry)
|
|
|
|
return +1;
|
|
|
|
|
|
|
|
if (a.line < b.line)
|
|
|
|
return -1;
|
|
|
|
if (a.line > b.line)
|
|
|
|
return +1;
|
|
|
|
|
|
|
|
if (a.column < b.column)
|
|
|
|
return -1;
|
|
|
|
if (a.column > b.column)
|
|
|
|
return +1;
|
|
|
|
|
|
|
|
return FileSpec::Compare (a.file, b.file, true);
|
|
|
|
}
|
|
|
|
|
2015-12-15 08:40:30 +08:00
|
|
|
AddressRange
|
|
|
|
LineEntry::GetSameLineContiguousAddressRange () const
|
|
|
|
{
|
|
|
|
// Add each LineEntry's range to complete_line_range until we find
|
|
|
|
// a different file / line number.
|
|
|
|
AddressRange complete_line_range = range;
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
SymbolContext next_line_sc;
|
|
|
|
Address range_end (complete_line_range.GetBaseAddress());
|
|
|
|
range_end.Slide (complete_line_range.GetByteSize());
|
|
|
|
range_end.CalculateSymbolContext (&next_line_sc, lldb::eSymbolContextLineEntry);
|
|
|
|
|
|
|
|
if (next_line_sc.line_entry.IsValid()
|
|
|
|
&& next_line_sc.line_entry.range.GetByteSize() > 0
|
2016-05-12 06:46:53 +08:00
|
|
|
&& original_file == next_line_sc.line_entry.original_file)
|
2015-12-15 08:40:30 +08:00
|
|
|
{
|
|
|
|
// Include any line 0 entries - they indicate that this is compiler-generated code
|
|
|
|
// that does not correspond to user source code.
|
|
|
|
if (next_line_sc.line_entry.line == 0)
|
|
|
|
{
|
|
|
|
complete_line_range.SetByteSize (complete_line_range.GetByteSize() + next_line_sc.line_entry.range.GetByteSize());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line == next_line_sc.line_entry.line)
|
|
|
|
{
|
|
|
|
// next_line_sc is the same file & line as this LineEntry, so extend our
|
|
|
|
// AddressRange by its size and continue to see if there are more LineEntries
|
|
|
|
// that we can combine.
|
|
|
|
complete_line_range.SetByteSize (complete_line_range.GetByteSize() + next_line_sc.line_entry.range.GetByteSize());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return complete_line_range;
|
|
|
|
}
|
2016-05-12 06:46:53 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
LineEntry::ApplyFileMappings(lldb::TargetSP target_sp)
|
|
|
|
{
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
// Apply any file remappings to our file
|
|
|
|
FileSpec new_file_spec;
|
|
|
|
if (target_sp->GetSourcePathMap().FindFile(original_file, new_file_spec))
|
|
|
|
file = new_file_spec;
|
|
|
|
}
|
|
|
|
}
|