[Lldb-commits] [lldb] r154182 - in /lldb/trunk: include/lldb/Core/ModuleList.h source/API/SBTarget.cpp source/Commands/CommandObjectMemory.cpp source/Core/ModuleList.cpp source/Expression/ClangASTSource.cpp source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Greg Clayton
gclayton at apple.com
Fri Apr 6 10:41:13 PDT 2012
Author: gclayton
Date: Fri Apr 6 12:41:13 2012
New Revision: 154182
URL: http://llvm.org/viewvc/llvm-project?rev=154182&view=rev
Log:
In a prior commit, I changed the parameters around on a ModuleList::FindTypes where the old parameters that existing clients were using would have been compatible, so I renamed ModuleList::FindTypes to ModuleList::FindTypes2. Then I made fixes and verified I updated and fixed all client code, but I forgot to rename the function back to ModuleList::FindTypes(). I am doing that now and also cleaning up the C++ dynamic type code a bit.
Modified:
lldb/trunk/include/lldb/Core/ModuleList.h
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Expression/ClangASTSource.cpp
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=154182&r1=154181&r2=154182&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Fri Apr 6 12:41:13 2012
@@ -340,7 +340,7 @@
/// The number of matches added to \a type_list.
//------------------------------------------------------------------
uint32_t
- FindTypes2 (const SymbolContext& sc,
+ FindTypes (const SymbolContext& sc,
const ConstString &name,
bool name_is_fully_qualified,
uint32_t max_matches,
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=154182&r1=154181&r2=154182&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Fri Apr 6 12:41:13 2012
@@ -1958,7 +1958,7 @@
SymbolContext sc;
TypeList type_list;
- uint32_t num_matches = images.FindTypes2 (sc,
+ uint32_t num_matches = images.FindTypes (sc,
name_const,
exact_match,
UINT32_MAX,
Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=154182&r1=154181&r2=154182&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Apr 6 12:41:13 2012
@@ -465,7 +465,7 @@
}
if (type_list.GetSize() == 0)
{
- target->GetImages().FindTypes2 (sc,
+ target->GetImages().FindTypes (sc,
lookup_type_name,
exact_match,
1,
Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=154182&r1=154181&r2=154182&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Fri Apr 6 12:41:13 2012
@@ -352,7 +352,7 @@
uint32_t
-ModuleList::FindTypes2 (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, uint32_t max_matches, TypeList& types)
+ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, uint32_t max_matches, TypeList& types)
{
Mutex::Locker locker(m_modules_mutex);
Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=154182&r1=154181&r2=154182&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Fri Apr 6 12:41:13 2012
@@ -245,7 +245,7 @@
ModuleList &module_list = m_target->GetImages();
bool exact_match = false;
- module_list.FindTypes2 (null_sc, name, exact_match, UINT32_MAX, types);
+ module_list.FindTypes (null_sc, name, exact_match, UINT32_MAX, types);
for (uint32_t ti = 0, te = types.GetSize();
ti != te && !found;
@@ -598,7 +598,7 @@
if (module_sp && namespace_decl)
module_sp->FindTypesInNamespace(null_sc, name, &namespace_decl, 1, types);
else
- m_target->GetImages().FindTypes2(null_sc, name, exact_match, 1, types);
+ m_target->GetImages().FindTypes(null_sc, name, exact_match, 1, types);
if (types.GetSize())
{
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=154182&r1=154181&r2=154182&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Fri Apr 6 12:41:13 2012
@@ -116,11 +116,14 @@
class_type_or_name.SetName (class_name);
const bool exact_match = true;
TypeList class_types;
- uint32_t num_matches = target->GetImages().FindTypes2 (sc,
- ConstString(class_name),
- exact_match,
- UINT32_MAX,
- class_types);
+
+ uint32_t num_matches = target->GetImages().FindTypes (sc,
+ ConstString(class_name),
+ exact_match,
+ UINT32_MAX,
+ class_types);
+
+ lldb::TypeSP type_sp;
if (num_matches == 0)
{
if (log)
@@ -129,7 +132,7 @@
}
if (num_matches == 1)
{
- lldb::TypeSP type_sp(class_types.GetTypeAtIndex(0));
+ type_sp = class_types.GetTypeAtIndex(0);
if (log)
log->Printf ("0x%16.16llx: static-type = '%s' has dynamic type: uid={0x%llx}, type-name='%s'\n",
original_ptr,
@@ -141,73 +144,105 @@
}
else if (num_matches > 1)
{
- for (size_t i = 0; i < num_matches; i++)
+ size_t i;
+ if (log)
+ {
+ for (i = 0; i < num_matches; i++)
+ {
+ type_sp = class_types.GetTypeAtIndex(i);
+ if (type_sp)
+ {
+ if (log)
+ log->Printf ("0x%16.16llx: static-type = '%s' has multiple matching dynamic types: uid={0x%llx}, type-name='%s'\n",
+ original_ptr,
+ in_value.GetTypeName().AsCString(),
+ type_sp->GetID(),
+ type_sp->GetName().GetCString());
+ }
+ }
+ }
+
+ for (i = 0; i < num_matches; i++)
{
- lldb::TypeSP type_sp(class_types.GetTypeAtIndex(i));
+ type_sp = class_types.GetTypeAtIndex(i);
if (type_sp)
{
- if (log)
- log->Printf ("0x%16.16llx: static-type = '%s' has multiple matching dynamic types: uid={0x%llx}, type-name='%s'\n",
- original_ptr,
- in_value.GetTypeName().AsCString(),
- type_sp->GetID(),
- type_sp->GetName().GetCString());
-
-// if (ClangASTContext::IsCXXClassType(type_sp->GetClangFullType()))
-// {
-// // There can only be one type with a given name,
-// // so we've just found duplicate definitions, and this
-// // one will do as well as any other.
-// // We don't consider something to have a dynamic type if
-// // it is the same as the static type. So compare against
-// // the value we were handed:
-//
-// clang::ASTContext *in_ast_ctx = in_value.GetClangAST ();
-// clang::ASTContext *this_ast_ctx = type_sp->GetClangAST ();
-// if (in_ast_ctx != this_ast_ctx
-// || !ClangASTContext::AreTypesSame (in_ast_ctx,
-// in_value.GetClangType(),
-// type_sp->GetClangFullType()))
-// {
-// class_type_or_name.SetTypeSP (this_type);
-// return true;
-// }
-// return false;
-// }
+ if (ClangASTContext::IsCXXClassType(type_sp->GetClangFullType()))
+ {
+ if (log)
+ log->Printf ("0x%16.16llx: static-type = '%s' has multiple matching dynamic types, picking this one: uid={0x%llx}, type-name='%s'\n",
+ original_ptr,
+ in_value.GetTypeName().AsCString(),
+ type_sp->GetID(),
+ type_sp->GetName().GetCString());
+ class_type_or_name.SetTypeSP(type_sp);
+ break;
+ }
}
}
- return false;
- }
- // The offset_to_top is two pointers above the address.
- Address offset_to_top_address = address_point_address;
- int64_t slide = -2 * ((int64_t) target->GetArchitecture().GetAddressByteSize());
- offset_to_top_address.Slide (slide);
-
- Error error;
- lldb::addr_t offset_to_top_location = offset_to_top_address.GetLoadAddress(target);
-
- size_t bytes_read = process->ReadMemory (offset_to_top_location,
- memory_buffer,
- address_byte_size,
- error);
-
- if (!error.Success() || (bytes_read != address_byte_size))
- {
- return false;
+ if (i == num_matches)
+ {
+ if (log)
+ log->Printf ("0x%16.16llx: static-type = '%s' has multiple matching dynamic types, didn't find a C++ match\n",
+ original_ptr,
+ in_value.GetTypeName().AsCString());
+ return false;
+ }
}
-
- offset_ptr = 0;
- int64_t offset_to_top = data.GetMaxS64(&offset_ptr, process->GetAddressByteSize());
-
- // So the dynamic type is a value that starts at offset_to_top
- // above the original address.
- lldb::addr_t dynamic_addr = original_ptr + offset_to_top;
- if (!target->GetSectionLoadList().ResolveLoadAddress (dynamic_addr, dynamic_address))
+
+ // There can only be one type with a given name,
+ // so we've just found duplicate definitions, and this
+ // one will do as well as any other.
+ // We don't consider something to have a dynamic type if
+ // it is the same as the static type. So compare against
+ // the value we were handed.
+ if (type_sp)
{
- dynamic_address.SetRawAddress(dynamic_addr);
+ clang::ASTContext *in_ast_ctx = in_value.GetClangAST ();
+ clang::ASTContext *this_ast_ctx = type_sp->GetClangAST ();
+ if (in_ast_ctx == this_ast_ctx)
+ {
+ if (ClangASTContext::AreTypesSame (in_ast_ctx,
+ in_value.GetClangType(),
+ type_sp->GetClangFullType()))
+ {
+ // The dynamic type we found was the same type,
+ // so we don't have a dynamic type here...
+ return false;
+ }
+ }
+
+ // The offset_to_top is two pointers above the address.
+ Address offset_to_top_address = address_point_address;
+ int64_t slide = -2 * ((int64_t) target->GetArchitecture().GetAddressByteSize());
+ offset_to_top_address.Slide (slide);
+
+ Error error;
+ lldb::addr_t offset_to_top_location = offset_to_top_address.GetLoadAddress(target);
+
+ size_t bytes_read = process->ReadMemory (offset_to_top_location,
+ memory_buffer,
+ address_byte_size,
+ error);
+
+ if (!error.Success() || (bytes_read != address_byte_size))
+ {
+ return false;
+ }
+
+ offset_ptr = 0;
+ int64_t offset_to_top = data.GetMaxS64(&offset_ptr, process->GetAddressByteSize());
+
+ // So the dynamic type is a value that starts at offset_to_top
+ // above the original address.
+ lldb::addr_t dynamic_addr = original_ptr + offset_to_top;
+ if (!target->GetSectionLoadList().ResolveLoadAddress (dynamic_addr, dynamic_address))
+ {
+ dynamic_address.SetRawAddress(dynamic_addr);
+ }
+ return true;
}
- return true;
}
}
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=154182&r1=154181&r2=154182&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Fri Apr 6 12:41:13 2012
@@ -350,7 +350,7 @@
TypeList class_types;
SymbolContext sc;
const bool exact_match = true;
- uint32_t num_matches = target.GetImages().FindTypes2 (sc,
+ uint32_t num_matches = target.GetImages().FindTypes (sc,
class_type_or_name.GetName(),
exact_match,
UINT32_MAX,
More information about the lldb-commits
mailing list