[Lldb-commits] [lldb] r114876 - in /lldb/trunk/source/Plugins: Process/gdb-remote/ProcessGDBRemote.cpp SymbolFile/DWARF/DWARFDebugInfoEntry.h SymbolFile/DWARF/SymbolFileDWARF.cpp SymbolFile/DWARF/SymbolFileDWARF.h
Greg Clayton
gclayton at apple.com
Mon Sep 27 14:07:38 PDT 2010
Author: gclayton
Date: Mon Sep 27 16:07:38 2010
New Revision: 114876
URL: http://llvm.org/viewvc/llvm-project?rev=114876&view=rev
Log:
Hooked up detach for ProcessGDBRemote.
Remove the GetUserData()/SetUserData() from the DWARFDebugInfoEntry
class. We now track everything with dense maps.
Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=114876&r1=114875&r2=114876&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Sep 27 16:07:38 2010
@@ -1133,14 +1133,58 @@
ProcessGDBRemote::WillDetach ()
{
Error error;
- const StateType state = m_private_state.GetValue();
-
- if (IsRunning(state))
- error.SetErrorString("Process must be stopped in order to detach.");
+ if (m_gdb_comm.IsRunning())
+ {
+ bool timed_out = false;
+ Mutex::Locker locker;
+ if (!m_gdb_comm.SendInterrupt (locker, 2, &timed_out))
+ {
+ if (timed_out)
+ error.SetErrorString("timed out sending interrupt packet");
+ else
+ error.SetErrorString("unknown error sending interrupt packet");
+ }
+ }
return error;
}
+Error
+ProcessGDBRemote::DoDetach()
+{
+ Error error;
+ Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS);
+ if (log)
+ log->Printf ("ProcessGDBRemote::DoDetach()");
+
+ DisableAllBreakpointSites ();
+
+ StringExtractorGDBRemote response;
+ size_t response_size = m_gdb_comm.SendPacketAndWaitForResponse("D", response, 2, false);
+ if (response_size)
+ {
+ if (response.IsOKPacket())
+ {
+ if (log)
+ log->Printf ("ProcessGDBRemote::DoDetach() detach was successful");
+
+ }
+ else if (log)
+ {
+ log->Printf ("ProcessGDBRemote::DoDestroy() detach failed: %s", response.GetStringRef().c_str());
+ }
+ }
+ else if (log)
+ {
+ log->PutCString ("ProcessGDBRemote::DoDestroy() detach failed for unknown reasons");
+ }
+ StopAsyncThread ();
+ m_gdb_comm.StopReadThread();
+ KillDebugserverProcess ();
+ m_gdb_comm.Disconnect(); // Disconnect from the debug server.
+ SetPublicState (eStateDetached);
+ return error;
+}
Error
ProcessGDBRemote::DoDestroy ()
@@ -1575,57 +1619,6 @@
return error;
}
-
-Error
-ProcessGDBRemote::DoDetach()
-{
- Error error;
- Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS);
- if (log)
- log->Printf ("ProcessGDBRemote::DoDetach()");
-
- // if (DoSIGSTOP (true))
- // {
- // CloseChildFileDescriptors ();
- //
- // // Scope for "locker" so we can reply to all of our exceptions (the SIGSTOP
- // // exception).
- // {
- // Mutex::Locker locker(m_exception_messages_mutex);
- // ReplyToAllExceptions();
- // }
- //
- // // Shut down the exception thread and cleanup our exception remappings
- // Task().ShutDownExceptionThread();
- //
- // pid_t pid = GetID();
- //
- // // Detach from our process while we are stopped.
- // errno = 0;
- //
- // // Detach from our process
- // ::ptrace (PT_DETACH, pid, (caddr_t)1, 0);
- //
- // error.SetErrorToErrno();
- //
- // if (log || error.Fail())
- // error.PutToLog(log, "::ptrace (PT_DETACH, %u, (caddr_t)1, 0)", pid);
- //
- // // Resume our task
- // Task().Resume();
- //
- // // NULL our task out as we have already retored all exception ports
- // Task().Clear();
- //
- // // Clear out any notion of the process we once were
- // Clear();
- //
- // SetPrivateState (eStateDetached);
- // return true;
- // }
- return error;
-}
-
void
ProcessGDBRemote::STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len)
{
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=114876&r1=114875&r2=114876&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Mon Sep 27 16:07:38 2010
@@ -105,8 +105,7 @@
m_offset (DW_INVALID_OFFSET),
m_parent_idx (0),
m_sibling_idx (0),
- m_abbrevDecl (NULL),
- m_user_data (NULL)
+ m_abbrevDecl (NULL)
{
}
@@ -319,14 +318,11 @@
}
const DWARFAbbreviationDeclaration* GetAbbreviationDeclarationPtr() const { return m_abbrevDecl; }
- void * GetUserData() const { return m_user_data; }
- void SetUserData(void *d) const { m_user_data = d; }
protected:
dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry
uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent
uint32_t m_sibling_idx; // How many to add to "this" to get the sibling.
const DWARFAbbreviationDeclaration* m_abbrevDecl;
- mutable void * m_user_data; // Flags for use by the parsers
};
#endif // liblldb_DWARFDebugInfoEntry_h_
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=114876&r1=114875&r2=114876&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Sep 27 16:07:38 2010
@@ -52,7 +52,7 @@
#include <map>
-#define DIE_IS_BEING_PARSED ((void*)1)
+#define DIE_IS_BEING_PARSED ((lldb_private::Type*)1)
using namespace lldb;
using namespace lldb_private;
@@ -609,10 +609,7 @@
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column));
- Type *func_type = NULL;
-
- if (die->GetUserData() != DIE_IS_BEING_PARSED)
- func_type = (Type*)die->GetUserData();
+ Type *func_type = m_die_to_type.lookup (die);
assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
@@ -1215,17 +1212,7 @@
DWARFCompileUnitSP cu_sp;
const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp);
if (type_die != NULL)
- {
- void *type = type_die->GetUserData();
- if (type == NULL)
- {
- TypeSP owning_type_sp;
- GetTypeForDIE(cu_sp.get(), type_die, owning_type_sp, 0, 0);
- type = type_die->GetUserData();
- }
- if (type != DIE_IS_BEING_PARSED)
- return (Type *)type;
- }
+ return ResolveType (cu_sp.get(), type_die);
}
return NULL;
}
@@ -1235,15 +1222,14 @@
{
if (type_die != NULL)
{
- void *type = type_die->GetUserData();
+ Type *type = m_die_to_type.lookup (type_die);
if (type == NULL)
{
TypeSP owning_type_sp;
- TypeSP type_sp(GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0));
- type = type_die->GetUserData();
+ type = GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0).get();
}
- if (type != DIE_IS_BEING_PARSED)
- return (Type *)type;
+ assert (type != DIE_IS_BEING_PARSED);
+ return type;
}
return NULL;
}
@@ -2238,38 +2224,26 @@
}
}
-Type*
-SymbolFileDWARF::GetUniquedTypeForDIEOffset(dw_offset_t type_die_offset, TypeSP& owning_type_sp, int32_t child_type, uint32_t idx, bool safe)
-{
- if (type_die_offset != DW_INVALID_OFFSET)
- {
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* type_die = DebugInfo()->GetDIEPtr(type_die_offset, &cu_sp);
- assert(type_die != NULL);
- GetTypeForDIE(cu_sp.get(), type_die, owning_type_sp, child_type, idx);
- // Return the uniqued type if there is one
- Type* type = (Type*)type_die->GetUserData();
- if (type == DIE_IS_BEING_PARSED && safe)
- return NULL;
- return type;
- }
- return NULL;
-}
-
TypeSP
-SymbolFileDWARF::GetTypeForDIE(DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die, TypeSP& owning_type_sp, int32_t child_type, uint32_t idx)
+SymbolFileDWARF::GetTypeForDIE
+(
+ DWARFCompileUnit *cu,
+ const DWARFDebugInfoEntry* die,
+ TypeSP& owning_type_sp,
+ int32_t child_type,
+ uint32_t idx
+)
{
TypeSP type_sp;
if (die != NULL)
{
assert(cu != NULL);
- Type *type_ptr = (Type *)die->GetUserData();
+ Type *type_ptr = m_die_to_type.lookup (die);
if (type_ptr == NULL)
{
SymbolContext sc(GetCompUnitForDWARFCompUnit(cu));
bool type_is_new = false;
type_sp = ParseType(sc, cu, die, type_is_new);
- type_ptr = (Type *)die->GetUserData();
if (owning_type_sp.get() == NULL)
owning_type_sp = type_sp;
}
@@ -2349,11 +2323,13 @@
AccessType accessibility = eAccessNone;
if (die != NULL)
{
- const dw_tag_t tag = die->Tag();
- if (die->GetUserData() == NULL)
+ Type *type_ptr = m_die_to_type.lookup (die);
+ if (type_ptr == NULL)
{
type_is_new = true;
+ const dw_tag_t tag = die->Tag();
+
bool is_forward_declaration = false;
DWARFDebugInfoEntry::Attributes attributes;
const char *type_name_cstr = NULL;
@@ -2376,7 +2352,7 @@
{
//printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(DIE_IS_BEING_PARSED);
+ m_die_to_type[die] = DIE_IS_BEING_PARSED;
const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
Declaration decl;
@@ -2480,8 +2456,7 @@
type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, encoding_uid_type, &decl, clang_type));
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(type_sp.get());
-
+ m_die_to_type[die] = type_sp.get();
// Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false);
// if (encoding_type != NULL)
@@ -2500,7 +2475,7 @@
{
//printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(DIE_IS_BEING_PARSED);
+ m_die_to_type[die] = DIE_IS_BEING_PARSED;
size_t byte_size = 0;
LanguageType class_language = eLanguageTypeUnknown;
@@ -2589,7 +2564,7 @@
m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type));
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(type_sp.get());
+ m_die_to_type[die] = type_sp.get();
// assert(type_sp.get());
// if (accessibility)
@@ -2655,7 +2630,7 @@
{
//printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(DIE_IS_BEING_PARSED);
+ m_die_to_type[die] = DIE_IS_BEING_PARSED;
size_t byte_size = 0;
lldb::user_id_t encoding_uid = DW_INVALID_OFFSET;
@@ -2707,7 +2682,7 @@
m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type));
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(type_sp.get());
+ m_die_to_type[die] = type_sp.get();
if (die->HasChildren())
{
@@ -2725,7 +2700,7 @@
{
//printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(DIE_IS_BEING_PARSED);
+ m_die_to_type[die] = DIE_IS_BEING_PARSED;
const char *mangled = NULL;
dw_offset_t type_die_offset = DW_INVALID_OFFSET;
@@ -2820,6 +2795,10 @@
// Parse the function children for the parameters
bool skip_artificial = true;
+ if (die->GetOffset() == 1340212) // REMOVE THIS BEFORE CHECKIN
+ { // REMOVE THIS BEFORE CHECKIN
+ printf("this one!\n"); // REMOVE THIS BEFORE CHECKIN
+ } // REMOVE THIS BEFORE CHECKIN
ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls);
// clang_type will get the function prototype clang type after this call
@@ -2908,7 +2887,7 @@
}
type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, 0, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type));
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(type_sp.get());
+ m_die_to_type[die] = type_sp.get();
assert(type_sp.get());
}
}
@@ -2918,7 +2897,7 @@
{
//printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(DIE_IS_BEING_PARSED);
+ m_die_to_type[die] = DIE_IS_BEING_PARSED;
size_t byte_size = 0;
lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
@@ -2993,7 +2972,7 @@
}
ConstString empty_name;
type_sp.reset( new Type(die->GetOffset(), this, empty_name, array_element_bit_stride / 8, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type));
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(type_sp.get());
+ m_die_to_type[die] = type_sp.get();
}
}
}
@@ -3035,7 +3014,7 @@
size_t byte_size = ClangASTType::GetClangTypeBitWidth (type_list->GetClangASTContext().getASTContext(), clang_type) / 8;
type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, NULL, clang_type));
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(type_sp.get());
+ m_die_to_type[die] = type_sp.get();
}
break;
@@ -3078,43 +3057,14 @@
{
// We are ready to put this type into the uniqued list up at the module level
TypeSP uniqued_type_sp(m_obj_file->GetModule()->GetTypeList()->InsertUnique(type_sp));
-
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(uniqued_type_sp.get());
-
type_sp = uniqued_type_sp;
+ m_die_to_type[die] = type_sp.get();
}
}
}
- else
+ else if (type_ptr != DIE_IS_BEING_PARSED)
{
- switch (tag)
- {
- case DW_TAG_base_type:
- case DW_TAG_pointer_type:
- case DW_TAG_reference_type:
- case DW_TAG_typedef:
- case DW_TAG_const_type:
- case DW_TAG_restrict_type:
- case DW_TAG_volatile_type:
- case DW_TAG_structure_type:
- case DW_TAG_union_type:
- case DW_TAG_class_type:
- case DW_TAG_enumeration_type:
- case DW_TAG_subprogram:
- case DW_TAG_subroutine_type:
- case DW_TAG_array_type:
- {
- Type *existing_type = (Type*)die->GetUserData();
- if (existing_type != DIE_IS_BEING_PARSED)
- {
- type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(existing_type->GetID());
- }
- }
- break;
- default:
- //assert(!"invalid type tag...");
- break;
- }
+ type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID());
}
}
return type_sp;
@@ -3280,7 +3230,6 @@
const char *mangled = NULL;
Declaration decl;
uint32_t i;
- TypeSP type_sp;
Type *var_type = NULL;
DWARFExpression location;
bool is_external = false;
@@ -3300,7 +3249,7 @@
case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break;
case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break;
- case DW_AT_type: var_type = GetUniquedTypeForDIEOffset(form_value.Reference(dwarf_cu), type_sp, 0, 0, false); break;
+ case DW_AT_type: var_type = ResolveTypeUID(form_value.Reference(dwarf_cu)); break;
case DW_AT_external: is_external = form_value.Unsigned() != 0; break;
case DW_AT_location:
{
@@ -3396,7 +3345,8 @@
location,
is_external,
is_artificial));
- const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(var_sp.get());
+
+ m_die_to_variable_sp[die] = var_sp;
}
}
return var_sp;
@@ -3477,7 +3427,7 @@
dw_tag_t tag = die->Tag();
// Check to see if we have already parsed this variable or constant?
- if (die->GetUserData() == NULL)
+ if (m_die_to_variable_sp[die].get() == NULL)
{
// We haven't already parsed it, lets do that now.
if ((tag == DW_TAG_variable) ||
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=114876&r1=114875&r2=114876&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Sep 27 16:07:38 2010
@@ -280,8 +280,12 @@
const NameToDIE &name_to_die,
lldb_private::SymbolContextList& sc_list);
- lldb_private::Type* GetUniquedTypeForDIEOffset(dw_offset_t type_die_offset, lldb::TypeSP& owning_type_sp, int32_t child_type, uint32_t idx, bool safe);
- lldb::TypeSP GetTypeForDIE(DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die, lldb::TypeSP& owning_type_sp, int32_t child_type, uint32_t idx);
+ lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu,
+ const DWARFDebugInfoEntry* die,
+ lldb::TypeSP& owning_type_sp,
+ int32_t child_type,
+ uint32_t idx);
+
uint32_t FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, lldb_private::TypeList& types);
void Index();
@@ -313,7 +317,11 @@
std::auto_ptr<DWARFDebugRanges> m_ranges;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;
DIEToDeclContextMap m_die_to_decl_ctx;
+ DIEToTypePtr m_die_to_type;
+ DIEToVariableSP m_die_to_variable_sp;
};
More information about the lldb-commits
mailing list