From johnny.chen at apple.com Mon Sep 12 14:12:06 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 12 Sep 2011 19:12:06 -0000
Subject: [Lldb-commits] [lldb] r139524 - in /lldb/trunk/source:
Commands/CommandObjectFrame.cpp Interpreter/OptionGroupWatchpoint.cpp
Message-ID: <20110912191206.DD8202A6C12C@llvm.org>
Author: johnny
Date: Mon Sep 12 14:12:06 2011
New Revision: 139524
URL: http://llvm.org/viewvc/llvm-project?rev=139524&view=rev
Log:
Fix a bug in OptionGroupWatchpoint.cpp where the '-w' option arg parsing result was not checked
to effect an early error return.
Plus add logic to 'frame variable' command object to check that when watchpoint option is on,
only one variable with exact name (no regex) is specified as the sole command arg.
Modified:
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=139524&r1=139523&r2=139524&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 12 14:12:06 2011
@@ -414,6 +414,22 @@
if (variable_list)
{
+ // If watching a variable, there are certain restrictions to be followed.
+ if (m_option_watchpoint.watch_variable)
+ {
+ if (command.GetArgumentCount() != 1) {
+ result.GetErrorStream().Printf("error: specify exactly one variable when using the '-w' option\n");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ } else if (m_option_variable.use_regex) {
+ result.GetErrorStream().Printf("error: specify your variable name exactly (no regex) when using the '-w' option\n");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ // Things have checked out ok...
+ // m_option_watchpoint.watch_mode specifies the mode for watching.
+ }
if (command.GetArgumentCount() > 0)
{
VariableList regex_var_list;
Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=139524&r1=139523&r2=139524&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Mon Sep 12 14:12:06 2011
@@ -55,9 +55,10 @@
switch (short_option)
{
case 'w': {
- watch_variable = false;
OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values;
watch_mode = (WatchMode) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable);
+ if (!watch_variable)
+ error.SetErrorStringWithFormat("Invalid option arg for '-w': '%s'.\n", option_arg);
break;
}
default:
From gclayton at apple.com Mon Sep 12 14:56:07 2011
From: gclayton at apple.com (Greg Clayton)
Date: Mon, 12 Sep 2011 19:56:07 -0000
Subject: [Lldb-commits] [lldb] r139529 - /lldb/trunk/www/lldb-gdb.html
Message-ID: <20110912195607.61A092A6C12C@llvm.org>
Author: gclayton
Date: Mon Sep 12 14:56:07 2011
New Revision: 139529
URL: http://llvm.org/viewvc/llvm-project?rev=139529&view=rev
Log:
Added GDB/LLDB commands for the "target stop-hook add" command.
Modified:
lldb/trunk/www/lldb-gdb.html
Modified: lldb/trunk/www/lldb-gdb.html
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/lldb-gdb.html?rev=139529&r1=139528&r2=139529&view=diff
==============================================================================
--- lldb/trunk/www/lldb-gdb.html (original)
+++ lldb/trunk/www/lldb-gdb.html Mon Sep 12 14:56:07 2011
@@ -190,6 +190,43 @@
+
+
+
+ (lldb) target stop-hook add --one-liner "frame variable argc argv"
+ |
+
+ (gdb) display argc
+ (gdb) display argv
+ |
+
+
+
+
+
+ (lldb) target stop-hook add --name main --one-liner "frame variable argc argv"
+ |
+
+
+
+
+
+ (lldb) target stop-hook add --classname MyClass --one-liner "frame variable *this"
+ |
+
+
+
+
+
+ (lldb) target stop-hook add"
+ Enter your stop hook command(s). Type 'DONE' to end.
+ > bt
+ > disassemble --pc
+ > DONE
+ Stop hook #1 added.
+ |
+
+
From johnny.chen at apple.com Mon Sep 12 15:25:57 2011
From: johnny.chen at apple.com (Johnny Chen)
Date: Mon, 12 Sep 2011 20:25:57 -0000
Subject: [Lldb-commits] [lldb] r139534 -
/lldb/trunk/source/Commands/CommandObjectFrame.cpp
Message-ID: <20110912202558.08F202A6C12C@llvm.org>
Author: johnny
Date: Mon Sep 12 15:25:57 2011
New Revision: 139534
URL: http://llvm.org/viewvc/llvm-project?rev=139534&view=rev
Log:
Fix indentations, add some comments.
Modified:
lldb/trunk/source/Commands/CommandObjectFrame.cpp
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=139534&r1=139533&r2=139534&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 12 15:25:57 2011
@@ -499,10 +499,10 @@
uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember;
lldb::VariableSP var_sp;
valobj_sp = frame_sp->GetValueForVariableExpressionPath (name_cstr,
- m_varobj_options.use_dynamic,
- expr_path_options,
- var_sp,
- error);
+ m_varobj_options.use_dynamic,
+ expr_path_options,
+ var_sp,
+ error);
if (valobj_sp)
{
if (m_option_variable.format != eFormatDefault)
@@ -530,7 +530,7 @@
}
}
}
- else
+ else // No command arg specified. Use variable_list, instead.
{
const uint32_t num_variables = variable_list->GetSize();
From gclayton at apple.com Mon Sep 12 18:21:58 2011
From: gclayton at apple.com (Greg Clayton)
Date: Mon, 12 Sep 2011 23:21:58 -0000
Subject: [Lldb-commits] [lldb] r139557 - in /lldb/trunk/source: Expression/
Plugins/SymbolFile/DWARF/
Message-ID: <20110912232158.D13212A6C12C@llvm.org>
Author: gclayton
Date: Mon Sep 12 18:21:58 2011
New Revision: 139557
URL: http://llvm.org/viewvc/llvm-project?rev=139557&view=rev
Log:
Huge memory and performance improvements in the DWARF parser.
Address ranges are now split up into two different tables:
- one in DWARFDebugInfo that is compile unit specific
- one in each DWARFCompileUnit that has exact function DIE offsets
This helps keep the size of the aranges down since the main table will get
uniqued and sorted and have consecutive ranges merged. We then only parse the
compile unit one on demand once we have determined that a compile unit contains
the address in question. We also now use the .debug_aranges section if there
is one instead of always indexing the DWARF manually.
NameToDIE now uses a UniqueCStringMap map instead of a std::map.
std::map is very bulky as each node has 3 pointers and the key and value types.
This gets our NameToDIE entry down to 12 bytes each instead of 48 which saves
us a lot of memory when we have very large DWARF.
DWARFDebugAranges now has a smaller footprint for each range it contains to
save on memory.
Modified:
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Sep 12 18:21:58 2011
@@ -79,6 +79,8 @@
void
ClangUserExpression::ScanContext(ExecutionContext &exe_ctx)
{
+ m_target = exe_ctx.target;
+
if (!exe_ctx.frame)
return;
@@ -87,8 +89,6 @@
if (!sym_ctx.function)
return;
- m_target = &exe_ctx.GetProcess()->GetTarget();
-
clang::DeclContext *decl_context;
if (sym_ctx.block && sym_ctx.block->GetInlinedFunctionInfo())
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Mon Sep 12 18:21:58 2011
@@ -30,16 +30,16 @@
extern int g_verbose;
DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF* dwarf2Data) :
- m_dwarf2Data ( dwarf2Data ),
- m_offset ( DW_INVALID_OFFSET ),
- m_length ( 0 ),
- m_version ( 0 ),
- m_abbrevs ( NULL ),
- m_addr_size ( DWARFCompileUnit::GetDefaultAddressSize() ),
- m_base_addr ( 0 ),
+ m_dwarf2Data (dwarf2Data),
+ m_abbrevs (NULL),
+ m_user_data (NULL),
m_die_array (),
- m_aranges_ap (),
- m_user_data ( NULL )
+ m_func_aranges_ap (),
+ m_base_addr (0),
+ m_offset (DW_INVALID_OFFSET),
+ m_length (0),
+ m_version (0),
+ m_addr_size (DWARFCompileUnit::GetDefaultAddressSize())
{
}
@@ -53,7 +53,7 @@
m_addr_size = DWARFCompileUnit::GetDefaultAddressSize();
m_base_addr = 0;
m_die_array.clear();
- m_aranges_ap.reset();
+ m_func_aranges_ap.reset();
m_user_data = NULL;
}
@@ -324,6 +324,50 @@
g_default_addr_size = addr_size;
}
+void
+DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
+ DWARFDebugAranges* debug_aranges,
+ bool clear_dies_if_already_not_parsed)
+{
+ // This function is usually called if there in no .debug_aranges section
+ // in order to produce a compile unit level set of address ranges that
+ // is accurate. If the DIEs weren't parsed, then we don't want all dies for
+ // all compile units to stay loaded when they weren't needed. So we can end
+ // up parsing the DWARF and then throwing them all away to keep memory usage
+ // down.
+ const bool clear_dies = ExtractDIEsIfNeeded (false) > 1;
+
+ DIE()->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
+
+ // Keep memory down by clearing DIEs if this generate function
+ // caused them to be parsed
+ if (clear_dies)
+ ClearDIEs (true);
+
+}
+
+
+const DWARFDebugAranges &
+DWARFCompileUnit::GetFunctionAranges ()
+{
+ if (m_func_aranges_ap.get() == NULL)
+ {
+ m_func_aranges_ap.reset (new DWARFDebugAranges());
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
+
+ if (log)
+ log->Printf ("DWARFCompileUnit::GetFunctionAranges() for \"%s/%s\" compile unit at 0x%8.8x",
+ m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(),
+ m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString(),
+ m_offset);
+ DIE()->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
+ const bool minimize = false;
+ const uint32_t fudge_size = 0;
+ m_func_aranges_ap->Sort(minimize, fudge_size);
+ }
+ return *m_func_aranges_ap.get();
+}
+
bool
DWARFCompileUnit::LookupAddress
(
@@ -336,16 +380,13 @@
if (function_die_handle != NULL && DIE())
{
- if (m_aranges_ap.get() == NULL)
- {
- m_aranges_ap.reset(new DWARFDebugAranges());
- m_die_array.front().BuildFunctionAddressRangeTable(m_dwarf2Data, this, m_aranges_ap.get());
- }
+
+ const DWARFDebugAranges &func_aranges = GetFunctionAranges ();
// Re-check the aranges auto pointer contents in case it was created above
- if (m_aranges_ap.get() != NULL)
+ if (!func_aranges.IsEmpty())
{
- *function_die_handle = GetDIEPtr(m_aranges_ap->FindAddress(address));
+ *function_die_handle = GetDIEPtr(func_aranges.FindAddress(address));
if (*function_die_handle != NULL)
{
success = true;
@@ -581,26 +622,20 @@
void
-DWARFCompileUnit::Index
-(
- const uint32_t cu_idx,
- NameToDIE& func_basenames,
- NameToDIE& func_fullnames,
- NameToDIE& func_methods,
- NameToDIE& func_selectors,
- NameToDIE& objc_class_selectors,
- NameToDIE& globals,
- NameToDIE& types,
- NameToDIE& namespaces,
- const DWARFDebugRanges *debug_ranges,
- DWARFDebugAranges *aranges
-)
+DWARFCompileUnit::Index (const uint32_t cu_idx,
+ NameToDIE& func_basenames,
+ NameToDIE& func_fullnames,
+ NameToDIE& func_methods,
+ NameToDIE& func_selectors,
+ NameToDIE& objc_class_selectors,
+ NameToDIE& globals,
+ NameToDIE& types,
+ NameToDIE& namespaces)
{
const DataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data();
const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize());
- NameToDIE::Info die_info = { cu_idx, 0 };
DWARFDebugInfoEntry::const_iterator pos;
DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin();
DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
@@ -640,9 +675,6 @@
bool has_address = false;
bool has_location = false;
bool is_global_or_static_variable = false;
- dw_addr_t lo_pc = DW_INVALID_ADDRESS;
- dw_addr_t hi_pc = DW_INVALID_ADDRESS;
- DWARFDebugRanges::RangeList ranges;
dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes);
@@ -677,33 +709,8 @@
break;
case DW_AT_low_pc:
- has_address = true;
- if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- {
- lo_pc = form_value.Unsigned();
- }
- break;
-
case DW_AT_high_pc:
- has_address = true;
- if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- {
- hi_pc = form_value.Unsigned();
- }
- break;
-
case DW_AT_ranges:
- if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
- {
- if (debug_ranges)
- {
- debug_ranges->FindRanges(form_value.Unsigned(), ranges);
- // All DW_AT_ranges are relative to the base address of the
- // compile unit. We add the compile unit base address to make
- // sure all the addresses are properly fixed up.
- ranges.AddOffset(GetBaseAddress());
- }
- }
has_address = true;
break;
@@ -765,26 +772,8 @@
break;
}
}
-
- if (tag == DW_TAG_subprogram)
- {
- if (lo_pc != DW_INVALID_ADDRESS && hi_pc != DW_INVALID_ADDRESS)
- {
- aranges->AppendRange (m_offset, lo_pc, hi_pc);
- }
- else
- {
- for (uint32_t i=0, num_ranges = ranges.Size(); iAppendRange (m_offset, range->begin_offset, range->end_offset);
- }
- }
- }
}
- die_info.die_idx = std::distance (begin, pos);
-
switch (tag)
{
case DW_TAG_subprogram:
@@ -804,14 +793,14 @@
&objc_method_name,
&objc_base_name))
{
- objc_class_selectors.Insert(objc_class_name, die_info);
+ objc_class_selectors.Insert(objc_class_name, die.GetOffset());
- func_selectors.Insert (objc_method_name, die_info);
+ func_selectors.Insert (objc_method_name, die.GetOffset());
if (!objc_base_name.IsEmpty())
{
- func_basenames.Insert (objc_base_name, die_info);
- func_fullnames.Insert (objc_base_name, die_info);
+ func_basenames.Insert (objc_base_name, die.GetOffset());
+ func_fullnames.Insert (objc_base_name, die.GetOffset());
}
}
}
@@ -849,9 +838,9 @@
if (is_method)
- func_methods.Insert (ConstString(name), die_info);
+ func_methods.Insert (ConstString(name), die.GetOffset());
else
- func_basenames.Insert (ConstString(name), die_info);
+ func_basenames.Insert (ConstString(name), die.GetOffset());
}
if (mangled_cstr)
{
@@ -862,9 +851,9 @@
if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
{
Mangled mangled (mangled_cstr, true);
- func_fullnames.Insert (mangled.GetMangledName(), die_info);
+ func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
if (mangled.GetDemangledName())
- func_fullnames.Insert (mangled.GetDemangledName(), die_info);
+ func_fullnames.Insert (mangled.GetDemangledName(), die.GetOffset());
}
}
}
@@ -874,7 +863,7 @@
if (has_address)
{
if (name)
- func_basenames.Insert (ConstString(name), die_info);
+ func_basenames.Insert (ConstString(name), die.GetOffset());
if (mangled_cstr)
{
// Make sure our mangled name isn't the same string table entry
@@ -884,9 +873,9 @@
if (name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
{
Mangled mangled (mangled_cstr, true);
- func_fullnames.Insert (mangled.GetMangledName(), die_info);
+ func_fullnames.Insert (mangled.GetMangledName(), die.GetOffset());
if (mangled.GetDemangledName())
- func_fullnames.Insert (mangled.GetDemangledName(), die_info);
+ func_fullnames.Insert (mangled.GetDemangledName(), die.GetOffset());
}
}
}
@@ -903,19 +892,19 @@
case DW_TAG_typedef:
if (name && is_declaration == false)
{
- types.Insert (ConstString(name), die_info);
+ types.Insert (ConstString(name), die.GetOffset());
}
break;
case DW_TAG_namespace:
if (name)
- namespaces.Insert (ConstString(name), die_info);
+ namespaces.Insert (ConstString(name), die.GetOffset());
break;
case DW_TAG_variable:
if (name && has_location && is_global_or_static_variable)
{
- globals.Insert (ConstString(name), die_info);
+ globals.Insert (ConstString(name), die.GetOffset());
// Be sure to include variables by their mangled and demangled
// names if they have any since a variable can have a basename
// "i", a mangled named "_ZN12_GLOBAL__N_11iE" and a demangled
@@ -928,9 +917,9 @@
if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
{
Mangled mangled (mangled_cstr, true);
- globals.Insert (mangled.GetMangledName(), die_info);
+ globals.Insert (mangled.GetMangledName(), die.GetOffset());
if (mangled.GetDemangledName())
- globals.Insert (mangled.GetDemangledName(), die_info);
+ globals.Insert (mangled.GetDemangledName(), die.GetOffset());
}
}
break;
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Mon Sep 12 18:21:58 2011
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DWARFCompileUnit_h_
+#ifndef SymbolFileDWARF_DWARFCompileUnit_h_
#define SymbolFileDWARF_DWARFCompileUnit_h_
-#include "SymbolFileDWARF.h"
#include "DWARFDebugInfoEntry.h"
+#include "SymbolFileDWARF.h"
class NameToDIE;
@@ -45,6 +45,9 @@
uint8_t GetAddressByteSize() const { return m_addr_size; }
dw_addr_t GetBaseAddress() const { return m_base_addr; }
void ClearDIEs(bool keep_compile_unit_die);
+ void BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
+ DWARFDebugAranges* debug_aranges,
+ bool clear_dies_if_already_not_parsed);
void
SetBaseAddress(dw_addr_t base_addr)
@@ -141,24 +144,22 @@
NameToDIE& objc_class_selectors,
NameToDIE& globals,
NameToDIE& types,
- NameToDIE& namespaces,
- const DWARFDebugRanges* debug_ranges,
- DWARFDebugAranges *aranges);
+ NameToDIE& namespaces);
+ const DWARFDebugAranges &
+ GetFunctionAranges ();
protected:
SymbolFileDWARF* m_dwarf2Data;
+ const DWARFAbbreviationDeclarationSet *m_abbrevs;
+ void * m_user_data;
+ DWARFDebugInfoEntry::collection m_die_array; // The compile unit debug information entry item
+ std::auto_ptr m_func_aranges_ap; // A table similar to the .debug_aranges table, but this one points to the exact DW_TAG_subprogram DIEs
+ dw_addr_t m_base_addr;
dw_offset_t m_offset;
uint32_t m_length;
uint16_t m_version;
- const DWARFAbbreviationDeclarationSet*
- m_abbrevs;
uint8_t m_addr_size;
- dw_addr_t m_base_addr;
- DWARFDebugInfoEntry::collection
- m_die_array; // The compile unit debug information entry item
- std::auto_ptr m_aranges_ap; // A table similar to the .debug_aranges table, but this one points to the exact DW_TAG_subprogram DIEs
- void * m_user_data;
private:
DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit);
};
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Mon Sep 12 18:21:58 2011
@@ -14,9 +14,11 @@
#include
+#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
+#include "LogChannelDWARF.h"
#include "SymbolFileDWARF.h"
#include "DWARFDebugInfo.h"
#include "DWARFCompileUnit.h"
@@ -73,7 +75,7 @@
for (uint32_t i=0; (arange_desc_ptr = set.GetDescriptor(i)) != NULL; ++i)
{
range.lo_pc = arange_desc_ptr->address;
- range.hi_pc = arange_desc_ptr->address + arange_desc_ptr->length;
+ range.length = arange_desc_ptr->length;
// Insert each item in increasing address order so binary searching
// can later be done!
@@ -90,7 +92,7 @@
static void PrintRange(const DWARFDebugAranges::Range& range)
{
// Cast the address values in case the address type is compiled as 32 bit
- printf("0x%8.8x: [0x%8.8llx - 0x%8.8llx)\n", range.offset, (long long)range.lo_pc, (long long)range.hi_pc);
+ printf("0x%8.8x: [0x%8.8llx - 0x%8.8llx)\n", range.offset, (long long)range.lo_pc, (long long)range.hi_pc());
}
//----------------------------------------------------------------------
@@ -139,13 +141,14 @@
DWARFDebugInfo* debug_info = dwarf2Data->DebugInfo();
if (debug_info)
{
+ const bool clear_dies_if_already_not_parsed = true;
uint32_t cu_idx = 0;
const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits();
for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
{
DWARFCompileUnit* cu = debug_info->GetCompileUnitAtIndex(cu_idx);
if (cu)
- cu->DIE()->BuildAddressRangeTable(dwarf2Data, cu, this);
+ cu->BuildAddressRangeTable(dwarf2Data, this, clear_dies_if_already_not_parsed);
}
}
return !IsEmpty();
@@ -153,17 +156,23 @@
void
-DWARFDebugAranges::Print() const
+DWARFDebugAranges::Dump (Log *log) const
{
- puts("\n\nDWARFDebugAranges address range list is:\n");
- for_each(m_aranges.begin(), m_aranges.end(), PrintRange);
+ if (log == NULL)
+ return;
+ const uint32_t num_ranges = NumRanges();
+ for (uint32_t i = 0; i < num_ranges; ++i)
+ {
+ const Range &range = m_aranges[i];
+ log->Printf ("0x%8.8x: [0x%8.8llx - 0x%8.8llx)", range.offset, (uint64_t)range.lo_pc, (uint64_t)range.hi_pc());
+ }
}
void
DWARFDebugAranges::Range::Dump(Stream *s) const
{
- s->Printf("{0x%8.8x}: [0x%8.8llx - 0x%8.8llx)\n", offset, lo_pc, hi_pc);
+ s->Printf("{0x%8.8x}: [0x%8.8llx - 0x%8.8llx)\n", offset, lo_pc, hi_pc());
}
//----------------------------------------------------------------------
@@ -232,57 +241,14 @@
// debug_ranges.AppendMax64(0, addr_size);
//
//}
-//
-//----------------------------------------------------------------------
-// ArangeSetContainsAddress
-//----------------------------------------------------------------------
-class ArangeSetContainsAddress
-{
-public:
- ArangeSetContainsAddress (dw_addr_t the_address) : address(the_address), offset(DW_INVALID_OFFSET) {}
- bool operator() (const DWARFDebugArangeSet& set)
- {
- offset = set.FindAddress(address);
- return (offset != DW_INVALID_OFFSET);
- }
- const dw_addr_t address;
- dw_offset_t offset;
-};
-
-
-//----------------------------------------------------------------------
-// InsertRange
-//----------------------------------------------------------------------
-void
-DWARFDebugAranges::InsertRange(dw_offset_t offset, dw_addr_t low_pc, dw_addr_t high_pc)
-{
- // Insert each item in increasing address order so binary searching
- // can later be done!
- DWARFDebugAranges::Range range(low_pc, high_pc, offset);
- InsertRange(range);
-}
-
-//----------------------------------------------------------------------
-// InsertRange
-//----------------------------------------------------------------------
-void
-DWARFDebugAranges::InsertRange(const DWARFDebugAranges::Range& range)
-{
- // Insert each item in increasing address order so binary searching
- // can later be done!
- RangeColl::iterator insert_pos = lower_bound(m_aranges.begin(), m_aranges.end(), range, RangeLessThan);
- m_aranges.insert(insert_pos, range);
-}
-
-
void
DWARFDebugAranges::AppendRange (dw_offset_t offset, dw_addr_t low_pc, dw_addr_t high_pc)
{
if (!m_aranges.empty())
{
- if (m_aranges.back().offset == offset && m_aranges.back().hi_pc == low_pc)
+ if (m_aranges.back().offset == offset && m_aranges.back().hi_pc() == low_pc)
{
- m_aranges.back().hi_pc = high_pc;
+ m_aranges.back().set_hi_pc(high_pc);
return;
}
}
@@ -290,49 +256,83 @@
}
void
-DWARFDebugAranges::Sort()
+DWARFDebugAranges::Sort (bool minimize, uint32_t n)
{
Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p",
__PRETTY_FUNCTION__, this);
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
+ const size_t orig_arange_size = m_aranges.size();
+ if (log)
+ {
+ log->Printf ("DWARFDebugAranges::Sort(minimize = %u, n = %u) with %zu entries", minimize, n, orig_arange_size);
+ Dump (log);
+ }
+
+ // Size of one? If so, no sorting is needed
+ if (orig_arange_size <= 1)
+ return;
// Sort our address range entries
std::stable_sort (m_aranges.begin(), m_aranges.end(), RangeLessThan);
- // Merge all neighbouring ranges into a single range and remember the
- // indices of all ranges merged.
- const size_t old_size = m_aranges.size();
- std::vector merged;
- for (size_t merge, cursor = 1; cursor < old_size; ++cursor)
- {
- merge = cursor - 1;
- Range &r1 = m_aranges[merge];
- Range &r2 = m_aranges[cursor];
-
- if (r1.hi_pc == r2.lo_pc && r1.offset == r2.offset)
- {
- r2.lo_pc = r1.lo_pc;
- merged.push_back(merge);
- }
- }
+
+ if (!minimize)
+ return;
- if (merged.empty())
+ // Most address ranges are contiguous from function to function
+ // so our new ranges will likely be smaller. We calculate the size
+ // of the new ranges since although std::vector objects can be resized,
+ // the will never reduce their allocated block size and free any excesss
+ // memory, so we might as well start a brand new collection so it is as
+ // small as possible.
+
+ // First calculate the size of the new minimal arange vector
+ // so we don't have to do a bunch of re-allocations as we
+ // copy the new minimal stuff over to the new collection
+ size_t minimal_size = 1;
+ size_t i;
+ for (i=1; iPrintf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)",
+ m_aranges.size(), delta, delta * sizeof(Range));
+ Dump (log);
+ }
}
//----------------------------------------------------------------------
@@ -348,7 +348,7 @@
DWARFDebugAranges::RangeCollIterator end = m_aranges.end();
DWARFDebugAranges::RangeCollIterator pos = lower_bound(begin, end, range, RangeLessThan);
- if ((pos != end) && (pos->lo_pc <= address && address < pos->hi_pc))
+ if ((pos != end) && (pos->lo_pc <= address && address < pos->hi_pc()))
{
// printf("FindAddress(1) found 0x%8.8x in compile unit: 0x%8.8x\n", address, pos->offset);
return pos->offset;
@@ -356,7 +356,7 @@
else if (pos != begin)
{
--pos;
- if ((pos->lo_pc <= address) && (address < pos->hi_pc))
+ if ((pos->lo_pc <= address) && (address < pos->hi_pc()))
{
// printf("FindAddress(2) found 0x%8.8x in compile unit: 0x%8.8x\n", address, pos->offset);
return (*pos).offset;
@@ -384,10 +384,10 @@
{
if ((pos != begin) && (pos->lo_pc != next_addr))
return false;
- next_addr = pos->hi_pc;
+ next_addr = pos->hi_pc();
}
lo_pc = m_aranges.front().lo_pc; // We checked for empty at the start of function so front() will be valid
- hi_pc = m_aranges.back().hi_pc; // We checked for empty at the start of function so back() will be valid
+ hi_pc = m_aranges.back().hi_pc(); // We checked for empty at the start of function so back() will be valid
return true;
}
@@ -398,7 +398,7 @@
return false;
lo_pc = m_aranges.front().lo_pc; // We checked for empty at the start of function so front() will be valid
- hi_pc = m_aranges.back().hi_pc; // We checked for empty at the start of function so back() will be valid
+ hi_pc = m_aranges.back().hi_pc(); // We checked for empty at the start of function so back() will be valid
return true;
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Mon Sep 12 18:21:58 2011
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DWARFDebugAranges_h_
+#ifndef SymbolFileDWARF_DWARFDebugAranges_h_
#define SymbolFileDWARF_DWARFDebugAranges_h_
#include "DWARFDebugArangeSet.h"
@@ -20,35 +20,60 @@
public:
struct Range
{
- Range(
- dw_addr_t _lo_pc = DW_INVALID_ADDRESS,
- dw_addr_t _hi_pc = DW_INVALID_ADDRESS,
- dw_offset_t _offset = DW_INVALID_OFFSET) :
- lo_pc(_lo_pc),
- hi_pc(_hi_pc),
- offset(_offset)
+ explicit
+ Range (dw_addr_t lo = DW_INVALID_ADDRESS,
+ dw_addr_t hi = DW_INVALID_ADDRESS,
+ dw_offset_t off = DW_INVALID_OFFSET) :
+ lo_pc (lo),
+ length (hi-lo),
+ offset (off)
{
}
void Clear()
{
- lo_pc = hi_pc = DW_INVALID_ADDRESS;
+ lo_pc = DW_INVALID_ADDRESS;
+ length = 0;
offset = DW_INVALID_OFFSET;
}
- bool ValidRange() const
+ void
+ set_hi_pc (dw_addr_t hi_pc)
{
- return hi_pc > lo_pc;
+ if (hi_pc == DW_INVALID_ADDRESS || hi_pc <= lo_pc)
+ length = 0;
+ else
+ length = hi_pc - lo_pc;
+ }
+ dw_addr_t
+ hi_pc() const
+ {
+ if (length)
+ return lo_pc + length;
+ return DW_INVALID_ADDRESS;
+ }
+ bool
+ ValidRange() const
+ {
+ return length > 0;
+ }
+
+ static bool
+ SortedOverlapCheck (const Range& curr_range, const Range& next_range, uint32_t n)
+ {
+ if (curr_range.offset != next_range.offset)
+ return false;
+ return curr_range.hi_pc() + n >= next_range.lo_pc;
}
bool Contains(const Range& range) const
{
- return lo_pc <= range.lo_pc && range.hi_pc <= hi_pc;
+ return lo_pc <= range.lo_pc && range.hi_pc() <= hi_pc();
}
void Dump(lldb_private::Stream *s) const;
dw_addr_t lo_pc; // Start of address range
- dw_addr_t hi_pc; // End of address range (not including this address)
+ uint32_t length; // End of address range (not including this address)
dw_offset_t offset; // Offset of the compile unit or die
};
@@ -59,12 +84,10 @@
bool GetMaxRange(dw_addr_t& lo_pc, dw_addr_t& hi_pc) const;
bool Extract(const lldb_private::DataExtractor &debug_aranges_data);
bool Generate(SymbolFileDWARF* dwarf2Data);
- void InsertRange (dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc);
- void InsertRange (const DWARFDebugAranges::Range& range);
// Use append range multiple times and then call sort
void AppendRange (dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc);
- void Sort();
+ void Sort (bool minimize, uint32_t n);
const Range* RangeAtIndex(uint32_t idx) const
{
@@ -72,7 +95,7 @@
return &m_aranges[idx];
return NULL;
}
- void Print() const;
+ void Dump (lldb_private::Log *log) const;
dw_offset_t FindAddress(dw_addr_t address) const;
bool IsEmpty() const { return m_aranges.empty(); }
// void Dump(lldb_private::Stream *s);
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Mon Sep 12 18:21:58 2011
@@ -14,12 +14,15 @@
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfoEntry.h"
#include "DWARFFormValue.h"
+#include "LogChannelDWARF.h"
using namespace lldb_private;
using namespace std;
@@ -29,7 +32,8 @@
//----------------------------------------------------------------------
DWARFDebugInfo::DWARFDebugInfo() :
m_dwarf2Data(NULL),
- m_compile_units()
+ m_compile_units(),
+ m_cu_aranges_ap ()
{
}
@@ -43,25 +47,60 @@
m_compile_units.clear();
}
-//----------------------------------------------------------------------
-// BuildDIEAddressRangeTable
-//----------------------------------------------------------------------
-bool
-DWARFDebugInfo::BuildFunctionAddressRangeTable(DWARFDebugAranges* debug_aranges)
+
+DWARFDebugAranges &
+DWARFDebugInfo::GetCompileUnitAranges ()
{
- const uint32_t num_compile_units = GetNumCompileUnits();
- uint32_t idx;
- for (idx = 0; idx < num_compile_units; ++idx)
+ if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data)
{
- DWARFCompileUnit* cu = GetCompileUnitAtIndex (idx);
- if (cu)
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
+
+ m_cu_aranges_ap.reset (new DWARFDebugAranges());
+ const DataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data();
+ if (debug_aranges_data.GetByteSize() > 0)
{
- cu->DIE()->BuildFunctionAddressRangeTable(m_dwarf2Data, cu, debug_aranges);
+ if (log)
+ log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s/%s\" from .debug_aranges",
+ m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(),
+ m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString());
+ m_cu_aranges_ap->Extract (debug_aranges_data);
+
+ }
+ else
+ {
+ if (log)
+ log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s/%s\" by parsing",
+ m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(),
+ m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString());
+ const uint32_t num_compile_units = GetNumCompileUnits();
+ uint32_t idx;
+ const bool clear_dies_if_already_not_parsed = true;
+ for (idx = 0; idx < num_compile_units; ++idx)
+ {
+ DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
+ if (cu)
+ cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed);
+ }
}
+
+ // Sort with a fudge factor of 16 to make sure if we have a lot
+ // of functions in the compile unit whose end address if followed
+ // a start address that is "fudge_size" bytes close, it will combine
+ // the arange entries. This currently happens a lot on x86_64. This
+ // will help reduce the size of the aranges since sort will sort all
+ // of them and combine aranges that are consecutive for ranges in the
+ // same compile unit and we really don't need it to be all that
+ // accurate since we will get exact accuracy when we search the
+ // actual compile unit aranges which point to the exact range and
+ // the exact DIE offset of the function.
+ const bool minimize = true;
+ const uint32_t fudge_factor = 16;
+ m_cu_aranges_ap->Sort (minimize, fudge_factor);
}
- return !debug_aranges->IsEmpty();
+ return *m_cu_aranges_ap.get();
}
+
//----------------------------------------------------------------------
// LookupAddress
//----------------------------------------------------------------------
@@ -80,28 +119,9 @@
cu_sp = GetCompileUnit(hint_die_offset);
else
{
- // Get a non const version of the address ranges
- DWARFDebugAranges* debug_aranges = ((SymbolFileDWARF*)m_dwarf2Data)->DebugAranges();
-
- if (debug_aranges != NULL)
- {
- // If we have an empty address ranges section, lets build a sorted
- // table ourselves by going through all of the debug information so we
- // can do quick subsequent searches.
-
- if (debug_aranges->IsEmpty())
- {
- const uint32_t num_compile_units = GetNumCompileUnits();
- uint32_t idx;
- for (idx = 0; idx < num_compile_units; ++idx)
- {
- DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
- if (cu)
- cu->DIE()->BuildAddressRangeTable(m_dwarf2Data, cu, debug_aranges);
- }
- }
- cu_sp = GetCompileUnit(debug_aranges->FindAddress(address));
- }
+ DWARFDebugAranges &cu_aranges = GetCompileUnitAranges ();
+ const dw_offset_t cu_offset = cu_aranges.FindAddress (address);
+ cu_sp = GetCompileUnit(cu_offset);
}
if (cu_sp.get())
@@ -613,7 +633,7 @@
range.lo_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS);
if (range.lo_pc != DW_INVALID_ADDRESS)
{
- range.hi_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS);
+ range.set_hi_pc (die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS));
if (s->GetVerbose())
{
s->Printf("\n CU ");
@@ -636,8 +656,8 @@
range.lo_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS);
if (range.lo_pc != DW_INVALID_ADDRESS)
{
- range.hi_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS);
- if (range.hi_pc != DW_INVALID_ADDRESS)
+ range.set_hi_pc (die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS));
+ if (range.hi_pc() != DW_INVALID_ADDRESS)
{
range.offset = die->GetOffset();
bool valid = range.ValidRange();
@@ -651,10 +671,6 @@
s->Printf(" ERROR: Invalid address range for function.");
}
}
-
- // Only add to our subroutine ranges if our compile unit has a valid address range
- // if (valid && verifyInfo->die_ranges.size() >= 2 && verifyInfo->die_ranges[1].range.ValidRange())
- // verifyInfo->subroutine_ranges.InsertRange(range);
}
}
break;
@@ -665,8 +681,8 @@
range.lo_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS);
if (range.lo_pc != DW_INVALID_ADDRESS)
{
- range.hi_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS);
- if (range.hi_pc != DW_INVALID_ADDRESS)
+ range.set_hi_pc (die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS));
+ if (range.hi_pc() != DW_INVALID_ADDRESS)
{
range.offset = die->GetOffset();
bool valid = range.ValidRange();
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Mon Sep 12 18:21:58 2011
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DWARFDebugInfo_h_
+#ifndef SymbolFileDWARF_DWARFDebugInfo_h_
#define SymbolFileDWARF_DWARFDebugInfo_h_
#include
@@ -36,7 +36,6 @@
DWARFDebugInfo();
void SetDwarfData(SymbolFileDWARF* dwarf2Data);
- bool BuildFunctionAddressRangeTable(DWARFDebugAranges* debug_aranges);
bool LookupAddress(
const dw_addr_t address,
@@ -70,12 +69,14 @@
eDumpFlag_ShowAncestors = (1<<2) // Show all parent DIEs when dumping single DIEs
};
+ DWARFDebugAranges &
+ GetCompileUnitAranges ();
protected:
SymbolFileDWARF* m_dwarf2Data;
typedef std::vector CompileUnitColl;
-
CompileUnitColl m_compile_units;
+ std::auto_ptr m_cu_aranges_ap; // A quick address to compile unit table
private:
// All parsing needs to be done partially any managed by this class as accessors are called.
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Mon Sep 12 18:21:58 2011
@@ -1843,7 +1843,7 @@
if (hi_pc != DW_INVALID_ADDRESS)
{
/// printf("BuildAddressRangeTable() 0x%8.8x: %30s: [0x%8.8x - 0x%8.8x)\n", m_offset, DW_TAG_value_to_name(tag), lo_pc, hi_pc);
- debug_aranges->InsertRange(cu->GetOffset(), lo_pc, hi_pc);
+ debug_aranges->AppendRange (cu->GetOffset(), lo_pc, hi_pc);
}
}
@@ -1885,7 +1885,7 @@
if (hi_pc != DW_INVALID_ADDRESS)
{
// printf("BuildAddressRangeTable() 0x%8.8x: [0x%16.16llx - 0x%16.16llx)\n", m_offset, lo_pc, hi_pc); // DEBUG ONLY
- debug_aranges->InsertRange(GetOffset(), lo_pc, hi_pc);
+ debug_aranges->AppendRange (GetOffset(), lo_pc, hi_pc);
}
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp Mon Sep 12 18:21:58 2011
@@ -23,335 +23,53 @@
using namespace lldb_private;
void
-NameToDIE::Insert (const ConstString& name, const Info &info)
+NameToDIE::Finalize()
{
- m_collection.insert (std::make_pair(name.AsCString(), info));
+ m_map.Sort ();
+ m_map.SizeToFit ();
}
-size_t
-NameToDIE::Find (const ConstString &name, std::vector &info_array) const
+void
+NameToDIE::Insert (const ConstString& name, uint32_t die_offset)
{
- const char *name_cstr = name.AsCString();
- const size_t initial_info_array_size = info_array.size();
- collection::const_iterator pos, end = m_collection.end();
- for (pos = m_collection.lower_bound (name_cstr); pos != end && pos->first == name_cstr; ++pos)
- {
- info_array.push_back (pos->second);
- }
- return info_array.size() - initial_info_array_size;
+ m_map.Append(name.GetCString(), die_offset);
}
size_t
-NameToDIE::Find (const RegularExpression& regex, std::vector &info_array) const
+NameToDIE::Find (const ConstString &name, DIEArray &info_array) const
{
- const size_t initial_info_array_size = info_array.size();
- collection::const_iterator pos, end = m_collection.end();
- for (pos = m_collection.begin(); pos != end; ++pos)
- {
- if (regex.Execute(pos->first))
- info_array.push_back (pos->second);
- }
- return info_array.size() - initial_info_array_size;
+ return m_map.GetValues (name.GetCString(), info_array);
}
size_t
-NameToDIE::FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx, std::vector &info_array) const
+NameToDIE::Find (const RegularExpression& regex, DIEArray &info_array) const
{
- const size_t initial_info_array_size = info_array.size();
- collection::const_iterator pos, end = m_collection.end();
- for (pos = m_collection.begin(); pos != end; ++pos)
- {
- if (cu_idx == pos->second.cu_idx)
- info_array.push_back (pos->second);
- }
- return info_array.size() - initial_info_array_size;
+ return m_map.GetValues (regex, info_array);
}
-void
-NameToDIE::Dump (Stream *s)
-{
- collection::const_iterator pos, end = m_collection.end();
- for (pos = m_collection.begin(); pos != end; ++pos)
- {
- s->Printf("%p: 0x%8.8x 0x%8.8x \"%s\"\n", pos->first, pos->second.cu_idx, pos->second.die_idx, pos->first);
+size_t
+NameToDIE::FindAllEntriesForCompileUnit (uint32_t cu_offset,
+ uint32_t cu_end_offset,
+ DIEArray &info_array) const
+{
+ const size_t initial_size = info_array.size();
+ const uint32_t size = m_map.GetSize();
+ for (uint32_t i=0; i die_array;
-};
-
-typedef std::vector DIEArray;
-typedef std::map NameToDIEArrayMap;
-
-struct HashBucketEntryCStr
+void
+NameToDIE::Dump (Stream *s)
{
- uint32_t
- GetByteSize () const
+ const uint32_t size = m_map.GetSize();
+ for (uint32_t i=0; isecond.size() + 1);
- }
- return byte_size;
+ const char *cstr = m_map.GetCStringAtIndex(i);
+ s->Printf("%p: {0x%8.8x} \"%s\"\n", cstr, m_map.GetValueAtIndexUnchecked(i), cstr);
}
-
- NameToDIEArrayMap name_to_die;
-};
-
-static uint32_t
-closest_power_2_less_than_n (uint32_t n)
-{
- if (n)
- return 0x80000000u >> __builtin_clz (n);
- return 0;
-}
-
-typedef struct HashEntry HashEntryType;
-
-void
-NameToDIE::Hash (Stream *s, SymbolFileDWARF *dwarf)
-{
-// if (m_collection.empty())
-// return;
-//
-// typedef std::vector hash_collection;
-// hash_collection hash_entries;
-// collection::const_iterator pos, end = m_collection.end();
-// for (pos = m_collection.begin(); pos != end; ++pos)
-// {
-// HashEntry entry = { dl_new_hash (pos->first), pos->second.cu_idx, pos->second.die_idx, pos->first };
-// hash_entries.push_back (entry);
-// }
-//
-//// const DataExtractor &debug_str_data = dwarf->get_debug_str_data();
-//
-//// uint32_t collisions = 0;
-//// for (i=1; iPrintf("count = %u, collisions = %u\n", hash_entries_size, collisions);
-//
-//// for (i=0; iPrintf("0x%8.8x: cu = %8u, die = %8u, name = '%s'\n",
-//// hash_entries[i].hash,
-//// hash_entries[i].cu_idx,
-//// hash_entries[i].die_idx,
-//// hash_entries[i].name);
-// DWARFDebugInfo *debug_info = dwarf->DebugInfo();
-//
-// uint32_t num_buckets;
-// if (hash_entries_size > 1024)
-// num_buckets = closest_power_2_less_than_n (hash_entries_size/16);
-// else if (hash_entries_size > 128)
-// num_buckets = closest_power_2_less_than_n (hash_entries_size/8);
-// else
-// num_buckets = closest_power_2_less_than_n (hash_entries_size/4);
-// if (num_buckets == 0)
-// num_buckets = 1;
-//
-// //for (uint32_t power_2 = 0x10; power_2 <= hash_entries_size; power_2 <<= 1)
-// {
-//// if (num_buckets > 0x10 && num_buckets > hash_entries_size)
-//// break;
-//
-// typedef std::vector uint32_array;
-// typedef std::map HashBucketEntryMap;
-// std::vector hash_buckets;
-// hash_buckets.resize(num_buckets);
-//
-// uint32_t bucket_entry_empties = 0;
-// uint32_t bucket_entry_single = 0;
-// uint32_t bucket_entry_collisions = 0;
-// uint32_t names_entry_single = 0;
-// uint32_t names_entry_collisions = 0;
-// //StreamString hash_file_data(Stream::eBinary, dwarf->GetObjectFile()->GetAddressByteSize(), dwarf->GetObjectFile()->GetByteSize());
-//
-// // Write hash table header
-//// hash_file_data.PutHex32 (1); // Version
-//// hash_file_data.PutHex32 (4); // Sizeof bucket data
-//// hash_file_data.PutHex32 (num_buckets);
-//// hash_file_data.PutHex32 (0); // Flags
-//
-// s->Printf("HashHeader = { version = %u, bucket_info_size = %u, bucket_count = %u, flags = 0x%8.8x }\n", 1, (uint32_t)sizeof(HashBucketInfo), num_buckets, 0);
-//
-// for (i=0; iGetCompileUnitAtIndex (hash_entries[i].cu_idx);
-// cu->ExtractDIEsIfNeeded(false);
-// DWARFDebugInfoEntry *die = cu->GetDIEAtIndexUnchecked(hash_entries[i].die_idx);
-// hash_buckets[bucket_idx][hash].name_to_die[hash_entries[i].name].push_back(die->GetOffset());
-// }
-// uint32_t byte_size = sizeof(HashHeader); // Header
-// uint32_t data_offset = 0;
-// uint32_t num_bucket_entries;
-// uint32_t bucket_data_size;
-// // Now for each bucket we write the offset to the data for each bucket
-// // The offset is currently a zero based offset from the end of this table
-// // which is header.num_buckets * sizeof(uint32_t) long.
-// for (i=0; ifirst) + pos->second.GetByteSize();
-// }
-// if (bucket_data_size > 0)
-// {
-// // Offset to bucket data
-//// hash_file_data.PutHex32 (data_offset);
-// s->Printf("bucket[%u] {0x%8.8x}\n", i, data_offset);
-// data_offset += bucket_data_size;
-// }
-// else
-// {
-// // Invalid offset that indicates an empty bucket
-//// hash_file_data.PutHex32 (UINT32_MAX);
-// s->Printf("bucket[%u] {0xFFFFFFFF}\n", i);
-// ++bucket_entry_empties;
-// }
-// }
-//
-// // Now we write the bucket data for each bucket that corresponds to each bucket
-// // offset from above.
-// data_offset = 0;
-// uint32_t total_num_name_entries = 0;
-// uint32_t total_num_bucket_entries = 0;
-// uint32_t total_non_empty_buckets = 0;
-// for (i=0; iPrintf("0x%8.8x: BucketEntry:\n", data_offset, num_bucket_entries);
-// bucket_data_size = 0;
-// uint32_t num_bucket_entries = 0;
-// HashBucketEntryMap::const_iterator pos, end = bucket_entry.end();
-// for (pos = bucket_entry.begin(); pos != end; ++pos)
-// {
-// ++num_bucket_entries;
-// uint32_t hash_data_len = pos->second.GetByteSize();
-// s->Printf(" hash = 0x%8.8x, length = 0x%8.8x:\n", pos->first, hash_data_len);
-//// hash_file_data.PutHex32 (pos->first); // Write the hash
-//// hash_file_data.PutHex32 (hash_data_len); // The length of the data for this hash not including the length itself
-//
-// const HashBucketEntryCStr &hash_entry = pos->second;
-// uint32_t num_name_entries = 0;
-// NameToDIEArrayMap::const_iterator name_pos, name_end = hash_entry.name_to_die.end();
-// for (name_pos = hash_entry.name_to_die.begin(); name_pos != name_end; ++name_pos)
-// {
-// ++num_name_entries;
-// ++total_num_name_entries;
-// s->Printf(" name = %p '%s'\n", name_pos->first, name_pos->first);
-//// hash_file_data.PutHex32 (pos->first); // Write the hash
-//// hash_file_data.PutHex32 (hash_data_len); // The length of the data for this hash not including the length itself
-//
-//
-// const uint32_t num_dies = name_pos->second.size();
-// s->Printf(" dies[%u] = { ", num_dies);
-// for (uint32_t j=0; j < num_dies; ++j)
-// s->Printf("0x%8.8x ", name_pos->second[j]);
-// s->PutCString("}\n");
-// }
-// if (num_name_entries == 1)
-// ++names_entry_single;
-// else if (num_name_entries > 1)
-// ++names_entry_collisions;
-// bucket_data_size += sizeof(pos->first) + hash_data_len;
-// }
-// data_offset += bucket_data_size;
-// byte_size += bucket_data_size;
-// total_num_bucket_entries += num_bucket_entries;
-// if (num_bucket_entries == 1)
-// ++bucket_entry_single;
-// else if (num_bucket_entries > 1)
-// ++bucket_entry_collisions;
-// }
-//
-// s->Printf ("Trying size of %u buckets, %u items:\n", num_buckets, hash_entries_size);
-// s->Printf ("buckets: empty = %u (%%%f)\n", bucket_entry_empties, ((float)bucket_entry_empties/(float)num_buckets) * 100.0f);
-// s->Printf ("buckets: single = %u\n", bucket_entry_single);
-// s->Printf ("buckets: multiple = %u (avg = %f entries/bucket, avg = %f entries/non-empty bucket)\n",
-// bucket_entry_collisions,
-// (float)total_num_bucket_entries / (float)num_buckets,
-// (float)total_num_bucket_entries / (float)total_non_empty_buckets);
-// s->Printf ("names : single = %u of %u\n", names_entry_single, total_num_name_entries);
-// s->Printf ("names : multiple = %u of %u\n", names_entry_collisions, total_num_name_entries);
-// s->Printf ("total byte size = %u\n", byte_size);
-// s->PutCString ("\n----------------------------------------------------------------------\n\n");
-// }
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h?rev=139557&r1=139556&r2=139557&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Mon Sep 12 18:21:58 2011
@@ -10,24 +10,18 @@
#ifndef SymbolFileDWARF_NameToDIE_h_
#define SymbolFileDWARF_NameToDIE_h_
-#include