[Lldb-commits] [lldb] r182066 - <rdar://problem/13893094>
Greg Clayton
gclayton at apple.com
Thu May 16 17:55:29 PDT 2013
Author: gclayton
Date: Thu May 16 19:55:28 2013
New Revision: 182066
URL: http://llvm.org/viewvc/llvm-project?rev=182066&view=rev
Log:
<rdar://problem/13893094>
Show variables that were in the debug info but optimized out. Also display a good error message when one of these variables get used in an expression.
Modified:
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Expression/DWARFExpression.cpp
lldb/trunk/source/Expression/Materializer.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=182066&r1=182065&r2=182066&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu May 16 19:55:28 2013
@@ -1493,13 +1493,7 @@ ClangExpressionDeclMap::GetVariableValue
return NULL;
}
}
- else if (!var_location_expr.Evaluate(&m_parser_vars->m_exe_ctx, ast, NULL, NULL, NULL, loclist_base_load_addr, NULL, *var_location.get(), &err))
- {
- if (log)
- log->Printf("Error evaluating location: %s", err.AsCString());
- return NULL;
- }
-
+
void *type_to_use = NULL;
if (parser_ast_context)
Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=182066&r1=182065&r2=182066&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Thu May 16 19:55:28 2013
@@ -1303,6 +1303,13 @@ DWARFExpression::Evaluate
Error *error_ptr
)
{
+
+ if (opcodes_length == 0)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString ("no location, value may have been optimized out");
+ return false;
+ }
std::vector<Value> stack;
Process *process = NULL;
@@ -1328,7 +1335,7 @@ DWARFExpression::Evaluate
if (!opcodes.ValidOffsetForDataOfSize(opcodes_offset, opcodes_length))
{
if (error_ptr)
- error_ptr->SetErrorString ("Invalid offset and/or length for opcodes buffer.");
+ error_ptr->SetErrorString ("invalid offset and/or length for opcodes buffer.");
return false;
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
Modified: lldb/trunk/source/Expression/Materializer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=182066&r1=182065&r2=182066&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Thu May 16 19:55:28 2013
@@ -89,8 +89,7 @@ public:
if (!allocate_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't allocate a memory area to store %s: %s", m_persistent_variable_sp->GetName().GetCString(), allocate_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't allocate a memory area to store %s: %s", m_persistent_variable_sp->GetName().GetCString(), allocate_error.AsCString());
return;
}
@@ -123,8 +122,7 @@ public:
if (!write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", m_persistent_variable_sp->GetName().AsCString(),
+ err.SetErrorStringWithFormat ("couldn't write %s to the target: %s", m_persistent_variable_sp->GetName().AsCString(),
write_error.AsCString());
return;
}
@@ -140,8 +138,7 @@ public:
if (!deallocate_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat ("Couldn't deallocate memory for %s: %s", m_persistent_variable_sp->GetName().GetCString(), deallocate_error.AsCString());
+ err.SetErrorStringWithFormat ("couldn't deallocate memory for %s: %s", m_persistent_variable_sp->GetName().GetCString(), deallocate_error.AsCString());
}
}
@@ -178,14 +175,12 @@ public:
if (!write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the location of %s to memory: %s", m_persistent_variable_sp->GetName().AsCString(), write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write the location of %s to memory: %s", m_persistent_variable_sp->GetName().AsCString(), write_error.AsCString());
}
}
else
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("No materialization happened for persistent variable %s", m_persistent_variable_sp->GetName().AsCString());
+ err.SetErrorStringWithFormat("no materialization happened for persistent variable %s", m_persistent_variable_sp->GetName().AsCString());
return;
}
}
@@ -219,8 +214,7 @@ public:
if (!read_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't read the address of program-allocated variable %s: %s", m_persistent_variable_sp->GetName().GetCString(), read_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't read the address of program-allocated variable %s: %s", m_persistent_variable_sp->GetName().GetCString(), read_error.AsCString());
return;
}
@@ -251,15 +245,13 @@ public:
if (!m_persistent_variable_sp->m_live_sp)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't find the memory area used to store %s", m_persistent_variable_sp->GetName().GetCString());
+ err.SetErrorStringWithFormat("couldn't find the memory area used to store %s", m_persistent_variable_sp->GetName().GetCString());
return;
}
if (m_persistent_variable_sp->m_live_sp->GetValue().GetValueAddressType() != eAddressTypeLoad)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("The address of the memory area for %s is in an incorrect format", m_persistent_variable_sp->GetName().GetCString());
+ err.SetErrorStringWithFormat("the address of the memory area for %s is in an incorrect format", m_persistent_variable_sp->GetName().GetCString());
return;
}
@@ -282,8 +274,7 @@ public:
if (!read_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat ("Couldn't read the contents of %s from memory: %s", m_persistent_variable_sp->GetName().GetCString(), read_error.AsCString());
+ err.SetErrorStringWithFormat ("couldn't read the contents of %s from memory: %s", m_persistent_variable_sp->GetName().GetCString(), read_error.AsCString());
return;
}
@@ -292,8 +283,7 @@ public:
}
else
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("No dematerialization happened for persistent variable %s", m_persistent_variable_sp->GetName().AsCString());
+ err.SetErrorStringWithFormat("no dematerialization happened for persistent variable %s", m_persistent_variable_sp->GetName().AsCString());
return;
}
@@ -435,8 +425,7 @@ public:
if (!valobj_sp)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't get a value object for variable %s", m_variable_sp->GetName().AsCString());
+ err.SetErrorStringWithFormat("couldn't get a value object for variable %s", m_variable_sp->GetName().AsCString());
return;
}
@@ -452,8 +441,7 @@ public:
if (!write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the contents of reference variable %s to memory: %s", m_variable_sp->GetName().AsCString(), write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write the contents of reference variable %s to memory: %s", m_variable_sp->GetName().AsCString(), write_error.AsCString());
return;
}
}
@@ -473,8 +461,7 @@ public:
if (!write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the address of variable %s to memory: %s", m_variable_sp->GetName().AsCString(), write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write the address of variable %s to memory: %s", m_variable_sp->GetName().AsCString(), write_error.AsCString());
return;
}
}
@@ -485,15 +472,20 @@ public:
if (m_temporary_allocation != LLDB_INVALID_ADDRESS)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Trying to create a temporary region for %s but one exists", m_variable_sp->GetName().AsCString());
+ err.SetErrorStringWithFormat("trying to create a temporary region for %s but one exists", m_variable_sp->GetName().AsCString());
return;
}
if (data.GetByteSize() != m_variable_sp->GetType()->GetByteSize())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Size of variable %s disagrees with the ValueObject's size", m_variable_sp->GetName().AsCString());
+ if (data.GetByteSize() == 0 && m_variable_sp->LocationExpression().IsValid() == false)
+ {
+ err.SetErrorStringWithFormat("the variable '%s' has no location, it may have been optimized out", m_variable_sp->GetName().AsCString());
+ }
+ else
+ {
+ err.SetErrorStringWithFormat("size of variable %s disagrees with the ValueObject's size", m_variable_sp->GetName().AsCString());
+ }
return;
}
@@ -507,8 +499,7 @@ public:
if (!alloc_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't allocate a temporary region for %s: %s", m_variable_sp->GetName().AsCString(), alloc_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't allocate a temporary region for %s: %s", m_variable_sp->GetName().AsCString(), alloc_error.AsCString());
return;
}
@@ -518,8 +509,7 @@ public:
if (!write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write to the temporary region for %s: %s", m_variable_sp->GetName().AsCString(), write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write to the temporary region for %s: %s", m_variable_sp->GetName().AsCString(), write_error.AsCString());
return;
}
@@ -529,8 +519,7 @@ public:
if (!pointer_write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the address of the temporary region for %s: %s", m_variable_sp->GetName().AsCString(), pointer_write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write the address of the temporary region for %s: %s", m_variable_sp->GetName().AsCString(), pointer_write_error.AsCString());
}
}
}
@@ -559,8 +548,7 @@ public:
if (!valobj_sp)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't get a value object for variable %s", m_variable_sp->GetName().AsCString());
+ err.SetErrorStringWithFormat("couldn't get a value object for variable %s", m_variable_sp->GetName().AsCString());
return;
}
@@ -572,8 +560,7 @@ public:
if (!extract_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't get the data for variable %s", m_variable_sp->GetName().AsCString());
+ err.SetErrorStringWithFormat("couldn't get the data for variable %s", m_variable_sp->GetName().AsCString());
return;
}
@@ -583,8 +570,7 @@ public:
if (!set_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the new contents of %s back into the variable", m_variable_sp->GetName().AsCString());
+ err.SetErrorStringWithFormat("couldn't write the new contents of %s back into the variable", m_variable_sp->GetName().AsCString());
return;
}
@@ -594,8 +580,7 @@ public:
if (!free_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't free the temporary region for %s: %s", m_variable_sp->GetName().AsCString(), free_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't free the temporary region for %s: %s", m_variable_sp->GetName().AsCString(), free_error.AsCString());
return;
}
@@ -727,7 +712,6 @@ public:
{
if (m_temporary_allocation != LLDB_INVALID_ADDRESS)
{
- err.SetErrorToGenericError();
err.SetErrorString("Trying to create a temporary region for the result but one exists");
return;
}
@@ -743,8 +727,7 @@ public:
if (!alloc_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't allocate a temporary region for the result: %s", alloc_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't allocate a temporary region for the result: %s", alloc_error.AsCString());
return;
}
@@ -754,8 +737,7 @@ public:
if (!pointer_write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the address of the temporary region for the result: %s", pointer_write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write the address of the temporary region for the result: %s", pointer_write_error.AsCString());
}
}
}
@@ -763,7 +745,6 @@ public:
void Dematerialize (lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address,
lldb::addr_t frame_top, lldb::addr_t frame_bottom, Error &err)
{
- err.SetErrorToGenericError();
err.SetErrorString("Tried to detmaterialize a result variable with the normal Dematerialize method");
}
@@ -777,7 +758,6 @@ public:
if (!exe_scope)
{
- err.SetErrorToGenericError();
err.SetErrorString("Couldn't dematerialize a result variable: invalid execution context scope");
return;
}
@@ -789,7 +769,6 @@ public:
if (!read_error.Success())
{
- err.SetErrorToGenericError();
err.SetErrorString("Couldn't dematerialize a result variable: couldn't read its address");
return;
}
@@ -798,7 +777,6 @@ public:
if (!target_sp)
{
- err.SetErrorToGenericError();
err.SetErrorString("Couldn't dematerialize a result variable: no target");
return;
}
@@ -815,8 +793,7 @@ public:
if (!ret)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't dematerialize a result variable: failed to make persistent variable %s", name.AsCString());
+ err.SetErrorStringWithFormat("couldn't dematerialize a result variable: failed to make persistent variable %s", name.AsCString());
return;
}
@@ -844,7 +821,6 @@ public:
if (!read_error.Success())
{
- err.SetErrorToGenericError();
err.SetErrorString("Couldn't dematerialize a result variable: couldn't read its memory");
return;
}
@@ -1007,8 +983,7 @@ public:
if (!target_sp)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't resolve symbol %s because there is no target", m_symbol.GetName().AsCString());
+ err.SetErrorStringWithFormat("couldn't resolve symbol %s because there is no target", m_symbol.GetName().AsCString());
return;
}
@@ -1023,8 +998,7 @@ public:
if (!pointer_write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the address of symbol %s: %s", m_symbol.GetName().AsCString(), pointer_write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write the address of symbol %s: %s", m_symbol.GetName().AsCString(), pointer_write_error.AsCString());
return;
}
}
@@ -1120,8 +1094,7 @@ public:
if (!frame_sp.get())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't materialize register %s without a stack frame", m_register_info.name);
+ err.SetErrorStringWithFormat("couldn't materialize register %s without a stack frame", m_register_info.name);
return;
}
@@ -1129,8 +1102,7 @@ public:
if (!reg_context_sp->ReadRegister(&m_register_info, reg_value))
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't read the value of register %s", m_register_info.name);
+ err.SetErrorStringWithFormat("couldn't read the value of register %s", m_register_info.name);
return;
}
@@ -1138,15 +1110,13 @@ public:
if (!reg_value.GetData(register_data))
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't get the data for register %s", m_register_info.name);
+ err.SetErrorStringWithFormat("couldn't get the data for register %s", m_register_info.name);
return;
}
if (register_data.GetByteSize() != m_register_info.byte_size)
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Data for register %s had size %llu but we expected %llu", m_register_info.name, (unsigned long long)register_data.GetByteSize(), (unsigned long long)m_register_info.byte_size);
+ err.SetErrorStringWithFormat("data for register %s had size %llu but we expected %llu", m_register_info.name, (unsigned long long)register_data.GetByteSize(), (unsigned long long)m_register_info.byte_size);
return;
}
@@ -1156,8 +1126,7 @@ public:
if (!write_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the contents of register %s: %s", m_register_info.name, write_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't write the contents of register %s: %s", m_register_info.name, write_error.AsCString());
return;
}
}
@@ -1180,8 +1149,7 @@ public:
if (!frame_sp.get())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't dematerialize register %s without a stack frame", m_register_info.name);
+ err.SetErrorStringWithFormat("couldn't dematerialize register %s without a stack frame", m_register_info.name);
return;
}
@@ -1191,8 +1159,7 @@ public:
if (!extract_error.Success())
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't get the data for register %s: %s", m_register_info.name, extract_error.AsCString());
+ err.SetErrorStringWithFormat("couldn't get the data for register %s: %s", m_register_info.name, extract_error.AsCString());
return;
}
@@ -1200,8 +1167,7 @@ public:
if (!reg_context_sp->WriteRegister(&m_register_info, register_value))
{
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't write the value of register %s", m_register_info.name);
+ err.SetErrorStringWithFormat("couldn't write the value of register %s", m_register_info.name);
return;
}
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=182066&r1=182065&r2=182066&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu May 16 19:55:28 2013
@@ -7175,174 +7175,171 @@ SymbolFileDWARF::ParseVariableDIE
}
}
- if (location.IsValid())
- {
- ValueType scope = eValueTypeInvalid;
+ ValueType scope = eValueTypeInvalid;
- const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die);
- dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0;
- SymbolContextScope * symbol_context_scope = NULL;
-
- // DWARF doesn't specify if a DW_TAG_variable is a local, global
- // or static variable, so we have to do a little digging by
- // looking at the location of a varaible to see if it contains
- // a DW_OP_addr opcode _somewhere_ in the definition. I say
- // somewhere because clang likes to combine small global variables
- // into the same symbol and have locations like:
- // DW_OP_addr(0x1000), DW_OP_constu(2), DW_OP_plus
- // So if we don't have a DW_TAG_formal_parameter, we can look at
- // the location to see if it contains a DW_OP_addr opcode, and
- // then we can correctly classify our variables.
- if (tag == DW_TAG_formal_parameter)
- scope = eValueTypeVariableArgument;
- else
+ const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die);
+ dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0;
+ SymbolContextScope * symbol_context_scope = NULL;
+
+ // DWARF doesn't specify if a DW_TAG_variable is a local, global
+ // or static variable, so we have to do a little digging by
+ // looking at the location of a varaible to see if it contains
+ // a DW_OP_addr opcode _somewhere_ in the definition. I say
+ // somewhere because clang likes to combine small global variables
+ // into the same symbol and have locations like:
+ // DW_OP_addr(0x1000), DW_OP_constu(2), DW_OP_plus
+ // So if we don't have a DW_TAG_formal_parameter, we can look at
+ // the location to see if it contains a DW_OP_addr opcode, and
+ // then we can correctly classify our variables.
+ if (tag == DW_TAG_formal_parameter)
+ scope = eValueTypeVariableArgument;
+ else
+ {
+ bool op_error = false;
+ // Check if the location has a DW_OP_addr with any address value...
+ lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS;
+ if (!location_is_const_value_data)
{
- bool op_error = false;
- // Check if the location has a DW_OP_addr with any address value...
- lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS;
- if (!location_is_const_value_data)
+ location_DW_OP_addr = location.GetLocation_DW_OP_addr (0, op_error);
+ if (op_error)
{
- location_DW_OP_addr = location.GetLocation_DW_OP_addr (0, op_error);
- if (op_error)
- {
- StreamString strm;
- location.DumpLocationForAddress (&strm, eDescriptionLevelFull, 0, 0, NULL);
- GetObjectFile()->GetModule()->ReportError ("0x%8.8x: %s has an invalid location: %s", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), strm.GetString().c_str());
- }
+ StreamString strm;
+ location.DumpLocationForAddress (&strm, eDescriptionLevelFull, 0, 0, NULL);
+ GetObjectFile()->GetModule()->ReportError ("0x%8.8x: %s has an invalid location: %s", die->GetOffset(), DW_TAG_value_to_name(die->Tag()), strm.GetString().c_str());
}
+ }
- if (location_DW_OP_addr != LLDB_INVALID_ADDRESS)
+ if (location_DW_OP_addr != LLDB_INVALID_ADDRESS)
+ {
+ if (is_external)
+ scope = eValueTypeVariableGlobal;
+ else
+ scope = eValueTypeVariableStatic;
+
+
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile ();
+
+ if (debug_map_symfile)
{
- if (is_external)
- scope = eValueTypeVariableGlobal;
- else
- scope = eValueTypeVariableStatic;
-
-
- SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile ();
-
- if (debug_map_symfile)
+ // When leaving the DWARF in the .o files on darwin,
+ // when we have a global variable that wasn't initialized,
+ // the .o file might not have allocated a virtual
+ // address for the global variable. In this case it will
+ // have created a symbol for the global variable
+ // that is undefined/data and external and the value will
+ // be the byte size of the variable. When we do the
+ // address map in SymbolFileDWARFDebugMap we rely on
+ // having an address, we need to do some magic here
+ // so we can get the correct address for our global
+ // variable. The address for all of these entries
+ // will be zero, and there will be an undefined symbol
+ // in this object file, and the executable will have
+ // a matching symbol with a good address. So here we
+ // dig up the correct address and replace it in the
+ // location for the variable, and set the variable's
+ // symbol context scope to be that of the main executable
+ // so the file address will resolve correctly.
+ bool linked_oso_file_addr = false;
+ if (is_external && location_DW_OP_addr == 0)
{
- // When leaving the DWARF in the .o files on darwin,
- // when we have a global variable that wasn't initialized,
- // the .o file might not have allocated a virtual
- // address for the global variable. In this case it will
- // have created a symbol for the global variable
- // that is undefined/data and external and the value will
- // be the byte size of the variable. When we do the
- // address map in SymbolFileDWARFDebugMap we rely on
- // having an address, we need to do some magic here
- // so we can get the correct address for our global
- // variable. The address for all of these entries
- // will be zero, and there will be an undefined symbol
- // in this object file, and the executable will have
- // a matching symbol with a good address. So here we
- // dig up the correct address and replace it in the
- // location for the variable, and set the variable's
- // symbol context scope to be that of the main executable
- // so the file address will resolve correctly.
- bool linked_oso_file_addr = false;
- if (is_external && location_DW_OP_addr == 0)
+
+ // we have a possible uninitialized extern global
+ ConstString const_name(mangled ? mangled : name);
+ ObjectFile *debug_map_objfile = debug_map_symfile->GetObjectFile();
+ if (debug_map_objfile)
{
-
- // we have a possible uninitialized extern global
- ConstString const_name(mangled ? mangled : name);
- ObjectFile *debug_map_objfile = debug_map_symfile->GetObjectFile();
- if (debug_map_objfile)
+ Symtab *debug_map_symtab = debug_map_objfile->GetSymtab();
+ if (debug_map_symtab)
{
- Symtab *debug_map_symtab = debug_map_objfile->GetSymtab();
- if (debug_map_symtab)
+ Symbol *exe_symbol = debug_map_symtab->FindFirstSymbolWithNameAndType (const_name,
+ eSymbolTypeData,
+ Symtab::eDebugYes,
+ Symtab::eVisibilityExtern);
+ if (exe_symbol)
{
- Symbol *exe_symbol = debug_map_symtab->FindFirstSymbolWithNameAndType (const_name,
- eSymbolTypeData,
- Symtab::eDebugYes,
- Symtab::eVisibilityExtern);
- if (exe_symbol)
+ if (exe_symbol->ValueIsAddress())
{
- if (exe_symbol->ValueIsAddress())
+ const addr_t exe_file_addr = exe_symbol->GetAddress().GetFileAddress();
+ if (exe_file_addr != LLDB_INVALID_ADDRESS)
{
- const addr_t exe_file_addr = exe_symbol->GetAddress().GetFileAddress();
- if (exe_file_addr != LLDB_INVALID_ADDRESS)
+ if (location.Update_DW_OP_addr (exe_file_addr))
{
- if (location.Update_DW_OP_addr (exe_file_addr))
- {
- linked_oso_file_addr = true;
- symbol_context_scope = exe_symbol;
- }
+ linked_oso_file_addr = true;
+ symbol_context_scope = exe_symbol;
}
}
}
}
}
}
+ }
- if (!linked_oso_file_addr)
+ if (!linked_oso_file_addr)
+ {
+ // The DW_OP_addr is not zero, but it contains a .o file address which
+ // needs to be linked up correctly.
+ const lldb::addr_t exe_file_addr = debug_map_symfile->LinkOSOFileAddress(this, location_DW_OP_addr);
+ if (exe_file_addr != LLDB_INVALID_ADDRESS)
{
- // The DW_OP_addr is not zero, but it contains a .o file address which
- // needs to be linked up correctly.
- const lldb::addr_t exe_file_addr = debug_map_symfile->LinkOSOFileAddress(this, location_DW_OP_addr);
- if (exe_file_addr != LLDB_INVALID_ADDRESS)
- {
- // Update the file address for this variable
- location.Update_DW_OP_addr (exe_file_addr);
- }
- else
- {
- // Variable didn't make it into the final executable
- return var_sp;
- }
+ // Update the file address for this variable
+ location.Update_DW_OP_addr (exe_file_addr);
+ }
+ else
+ {
+ // Variable didn't make it into the final executable
+ return var_sp;
}
}
}
- else
- {
- scope = eValueTypeVariableLocal;
- }
}
+ else
+ {
+ scope = eValueTypeVariableLocal;
+ }
+ }
- if (symbol_context_scope == NULL)
+ if (symbol_context_scope == NULL)
+ {
+ switch (parent_tag)
{
- switch (parent_tag)
+ case DW_TAG_subprogram:
+ case DW_TAG_inlined_subroutine:
+ case DW_TAG_lexical_block:
+ if (sc.function)
{
- case DW_TAG_subprogram:
- case DW_TAG_inlined_subroutine:
- case DW_TAG_lexical_block:
- if (sc.function)
- {
- symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset()));
- if (symbol_context_scope == NULL)
- symbol_context_scope = sc.function;
- }
- break;
-
- default:
- symbol_context_scope = sc.comp_unit;
- break;
+ symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset()));
+ if (symbol_context_scope == NULL)
+ symbol_context_scope = sc.function;
}
+ break;
+
+ default:
+ symbol_context_scope = sc.comp_unit;
+ break;
}
+ }
- if (symbol_context_scope)
- {
- var_sp.reset (new Variable (MakeUserID(die->GetOffset()),
- name,
- mangled,
- SymbolFileTypeSP (new SymbolFileType(*this, type_uid)),
- scope,
- symbol_context_scope,
- &decl,
- location,
- is_external,
- is_artificial));
-
- var_sp->SetLocationIsConstantValueData (location_is_const_value_data);
- }
- else
- {
- // Not ready to parse this variable yet. It might be a global
- // or static variable that is in a function scope and the function
- // in the symbol context wasn't filled in yet
- return var_sp;
- }
+ if (symbol_context_scope)
+ {
+ var_sp.reset (new Variable (MakeUserID(die->GetOffset()),
+ name,
+ mangled,
+ SymbolFileTypeSP (new SymbolFileType(*this, type_uid)),
+ scope,
+ symbol_context_scope,
+ &decl,
+ location,
+ is_external,
+ is_artificial));
+
+ var_sp->SetLocationIsConstantValueData (location_is_const_value_data);
+ }
+ else
+ {
+ // Not ready to parse this variable yet. It might be a global
+ // or static variable that is in a function scope and the function
+ // in the symbol context wasn't filled in yet
+ return var_sp;
}
}
// Cache var_sp even if NULL (the variable was just a specification or
More information about the lldb-commits
mailing list