summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins')
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp12
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h1
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp80
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp68
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h2
6 files changed, 99 insertions, 66 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index 334c21e60ca..fc33c755cad 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -226,6 +226,7 @@ ProcessMacOSX::ProcessMacOSX(Target& target, Listener &listener) :
m_task (this),
m_flags (eFlagsNone),
m_stdio_thread (LLDB_INVALID_HOST_THREAD),
+ m_monitor_thread (LLDB_INVALID_HOST_THREAD),
m_stdio_mutex (Mutex::eMutexTypeRecursive),
m_stdout_data (),
m_exception_messages (),
@@ -244,6 +245,7 @@ ProcessMacOSX::~ProcessMacOSX()
{
// m_mach_process.UnregisterNotificationCallbacks (this);
Clear();
+
}
//----------------------------------------------------------------------
@@ -450,7 +452,7 @@ ProcessMacOSX::DidLaunchOrAttach ()
// Install a signal handler so we can catch when our child process
// dies and set the exit status correctly.
- Host::StartMonitoringChildProcess (Process::SetProcessExitStatus, NULL, GetID(), false);
+ m_monitor_thread = Host::StartMonitoringChildProcess (Process::SetProcessExitStatus, NULL, GetID(), false);
if (m_arch_spec == ArchSpec("arm"))
{
@@ -1156,6 +1158,14 @@ ProcessMacOSX::Clear()
m_exception_messages.clear();
}
+ if (m_monitor_thread != LLDB_INVALID_HOST_THREAD)
+ {
+ Host::ThreadCancel (m_monitor_thread, NULL);
+ thread_result_t thread_result;
+ Host::ThreadJoin (m_monitor_thread, &thread_result, NULL);
+ m_monitor_thread = LLDB_INVALID_HOST_THREAD;
+ }
+
}
bool
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
index 20628622a8a..a3585dbebbd 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
@@ -239,6 +239,7 @@ protected:
MachTask m_task; // The mach task for this process
lldb_private::Flags m_flags; // Process specific flags (see eFlags enums)
lldb::thread_t m_stdio_thread; // Thread ID for the thread that watches for child process stdio
+ lldb::thread_t m_monitor_thread; // Thread ID for the thread that watches for child process stdio
lldb_private::Mutex m_stdio_mutex; // Multithreaded protection for stdio
std::string m_stdout_data;
MachException::Message::collection m_exception_messages; // A collection of exception messages caught when listening to the exception port
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 1c6b164ca61..2a07ee97617 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -110,7 +110,7 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
m_byte_order (eByteOrderHost),
m_gdb_comm(),
m_debugserver_pid (LLDB_INVALID_PROCESS_ID),
- m_debugserver_monitor (0),
+ m_debugserver_thread (LLDB_INVALID_HOST_THREAD),
m_last_stop_packet (),
m_register_info (),
m_async_broadcaster ("lldb.process.gdb-remote.async-broadcaster"),
@@ -134,6 +134,13 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
//----------------------------------------------------------------------
ProcessGDBRemote::~ProcessGDBRemote()
{
+ if (m_debugserver_thread != LLDB_INVALID_HOST_THREAD)
+ {
+ Host::ThreadCancel (m_debugserver_thread, NULL);
+ thread_result_t thread_result;
+ Host::ThreadJoin (m_debugserver_thread, &thread_result, NULL);
+ m_debugserver_thread = LLDB_INVALID_HOST_THREAD;
+ }
// m_mach_process.UnregisterNotificationCallbacks (this);
Clear();
}
@@ -535,11 +542,11 @@ ProcessGDBRemote::ConnectToDebugserver (const char *host_port)
m_gdb_comm.SendAck('+');
if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
- m_debugserver_monitor = Host::StartMonitoringChildProcess (MonitorDebugserverProcess,
- (void*)(intptr_t)GetID(), // Pass the inferior pid in the thread argument (which is a void *)
- m_debugserver_pid,
- false);
-
+ m_debugserver_thread = Host::StartMonitoringChildProcess (MonitorDebugserverProcess,
+ this,
+ m_debugserver_pid,
+ false);
+
StringExtractorGDBRemote response;
if (m_gdb_comm.SendPacketAndWaitForResponse("QStartNoAckMode", response, 1, false))
{
@@ -1907,47 +1914,42 @@ ProcessGDBRemote::MonitorDebugserverProcess
// "debugserver_pid" argument passed in is the process ID for
// debugserver that we are tracking...
- lldb::pid_t gdb_remote_pid = (lldb::pid_t)(intptr_t)callback_baton;
- TargetSP target_sp(Debugger::FindTargetWithProcessID (gdb_remote_pid));
- if (target_sp)
+ ProcessGDBRemote *process = (ProcessGDBRemote *)callback_baton;
+
+ if (process)
{
- ProcessSP process_sp (target_sp->GetProcessSP());
- if (process_sp)
+ // Sleep for a half a second to make sure our inferior process has
+ // time to set its exit status before we set it incorrectly when
+ // both the debugserver and the inferior process shut down.
+ usleep (500000);
+ // If our process hasn't yet exited, debugserver might have died.
+ // If the process did exit, the we are reaping it.
+ if (process->GetState() != eStateExited)
{
- // Sleep for a half a second to make sure our inferior process has
- // time to set its exit status before we set it incorrectly when
- // both the debugserver and the inferior process shut down.
- usleep (500000);
- // If our process hasn't yet exited, debugserver might have died.
- // If the process did exit, the we are reaping it.
- if (process_sp->GetState() != eStateExited)
+ char error_str[1024];
+ if (signo)
{
- char error_str[1024];
- if (signo)
- {
- const char *signal_cstr = process_sp->GetUnixSignals().GetSignalAsCString (signo);
- if (signal_cstr)
- ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %s", signal_cstr);
- else
- ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %i", signo);
- }
+ const char *signal_cstr = process->GetUnixSignals().GetSignalAsCString (signo);
+ if (signal_cstr)
+ ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %s", signal_cstr);
else
- {
- ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with an exit status of 0x%8.8x", exit_status);
- }
-
- process_sp->SetExitStatus (-1, error_str);
+ ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %i", signo);
}
else
{
- ProcessGDBRemote *gdb_process = (ProcessGDBRemote *)process_sp.get();
- // Debugserver has exited we need to let our ProcessGDBRemote
- // know that it no longer has a debugserver instance
- gdb_process->m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
- // We are returning true to this function below, so we can
- // forget about the monitor handle.
- gdb_process->m_debugserver_monitor = 0;
+ ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with an exit status of 0x%8.8x", exit_status);
}
+
+ process->SetExitStatus (-1, error_str);
+ }
+ else
+ {
+ // Debugserver has exited we need to let our ProcessGDBRemote
+ // know that it no longer has a debugserver instance
+ process->m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
+ // We are returning true to this function below, so we can
+ // forget about the monitor handle.
+ process->m_debugserver_thread = LLDB_INVALID_HOST_THREAD;
}
}
return true;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index d1fb7bf9155..88c495a652a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -324,7 +324,7 @@ protected:
lldb::ByteOrder m_byte_order;
GDBRemoteCommunication m_gdb_comm;
lldb::pid_t m_debugserver_pid;
- uint32_t m_debugserver_monitor;
+ lldb::thread_t m_debugserver_thread;
StringExtractor m_last_stop_packet;
GDBRemoteDynamicRegisterInfo m_register_info;
lldb_private::Broadcaster m_async_broadcaster;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 96aec7827d7..c64bb4ac674 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -785,8 +785,7 @@ SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx)
static void
AddRangesToBlock
(
- BlockList& blocks,
- lldb::user_id_t blockID,
+ Block& block,
DWARFDebugRanges::RangeList& ranges,
addr_t block_base_addr
)
@@ -796,7 +795,7 @@ AddRangesToBlock
const DWARFDebugRanges::Range *debug_range;
for (range_idx = 0; (debug_range = ranges.RangeAtIndex(range_idx)) != NULL; range_idx++)
{
- blocks.AddRange(blockID, debug_range->begin_offset, debug_range->end_offset);
+ block.AddRange(debug_range->begin_offset, debug_range->end_offset);
}
}
@@ -1129,7 +1128,7 @@ size_t
SymbolFileDWARF::ParseFunctionBlocks
(
const SymbolContext& sc,
- lldb::user_id_t parentBlockID,
+ Block *parent_block,
const DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
addr_t subprogram_low_pc,
@@ -1151,18 +1150,31 @@ SymbolFileDWARF::ParseFunctionBlocks
DWARFDebugRanges::RangeList ranges;
const char *name = NULL;
const char *mangled_name = NULL;
- BlockList& blocks = sc.function->GetBlocks(false);
+ Block *block = NULL;
+ if (tag != DW_TAG_subprogram)
+ {
+ BlockSP block_sp(new Block (die->GetOffset()));
+ parent_block->AddChild(block_sp);
+ block = block_sp.get();
+ }
+ else
+ {
+ block = parent_block;
+ }
- lldb::user_id_t blockID = blocks.AddChild(parentBlockID, die->GetOffset());
int decl_file = 0;
int decl_line = 0;
int decl_column = 0;
int call_file = 0;
int call_line = 0;
int call_column = 0;
- if (die->GetDIENamesAndRanges(this, dwarf_cu, name, mangled_name, ranges,
- decl_file, decl_line, decl_column,
- call_file, call_line, call_column))
+ if (die->GetDIENamesAndRanges (this,
+ dwarf_cu,
+ name,
+ mangled_name,
+ ranges,
+ decl_file, decl_line, decl_column,
+ call_file, call_line, call_column))
{
if (tag == DW_TAG_subprogram)
{
@@ -1185,7 +1197,7 @@ SymbolFileDWARF::ParseFunctionBlocks
}
}
- AddRangesToBlock (blocks, blockID, ranges, subprogram_low_pc);
+ AddRangesToBlock (*block, ranges, subprogram_low_pc);
if (tag != DW_TAG_subprogram && (name != NULL || mangled_name != NULL))
{
@@ -1199,15 +1211,20 @@ SymbolFileDWARF::ParseFunctionBlocks
call_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(call_file),
call_line, call_column));
- blocks.SetInlinedFunctionInfo(blockID, name, mangled_name, decl_ap.get(), call_ap.get());
+ block->SetInlinedFunctionInfo (name, mangled_name, decl_ap.get(), call_ap.get());
}
++blocks_added;
if (parse_children && die->HasChildren())
{
- blocks_added += ParseFunctionBlocks(sc, blockID, dwarf_cu, die->GetFirstChild(),
- subprogram_low_pc, true, true);
+ blocks_added += ParseFunctionBlocks (sc,
+ block,
+ dwarf_cu,
+ die->GetFirstChild(),
+ subprogram_low_pc,
+ true,
+ true);
}
}
}
@@ -1582,12 +1599,12 @@ SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_
if (resolve_scope & eSymbolContextBlock)
{
- BlockList& blocks = sc.function->GetBlocks(true);
+ Block& block = sc.function->GetBlock (true);
if (block_die != NULL)
- sc.block = blocks.GetBlockByID(block_die->GetOffset());
+ sc.block = block.FindBlockByID (block_die->GetOffset());
else
- sc.block = blocks.GetBlockByID(function_die->GetOffset());
+ sc.block = block.FindBlockByID (function_die->GetOffset());
if (sc.block)
resolved |= eSymbolContextBlock;
}
@@ -1674,12 +1691,12 @@ SymbolFileDWARF::ResolveSymbolContext(const FileSpec& file_spec, uint32_t line,
if (sc.function != NULL)
{
- BlockList& blocks = sc.function->GetBlocks(true);
+ Block& block = sc.function->GetBlock (true);
if (block_die != NULL)
- sc.block = blocks.GetBlockByID(block_die->GetOffset());
+ sc.block = block.FindBlockByID (block_die->GetOffset());
else
- sc.block = blocks.GetBlockByID(function_die->GetOffset());
+ sc.block = block.FindBlockByID (function_die->GetOffset());
}
}
}
@@ -3126,7 +3143,7 @@ SymbolFileDWARF::ParseType(const SymbolContext& sc, const DWARFCompileUnit* dwar
}
else if (sc.function != NULL)
{
- symbol_context_scope = sc.function->GetBlocks(true).GetBlockByID(sc_parent_die->GetOffset());
+ symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset());
if (symbol_context_scope == NULL)
symbol_context_scope = sc.function;
}
@@ -3235,7 +3252,7 @@ SymbolFileDWARF::ParseFunctionBlocks (const SymbolContext &sc)
const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(function_die_offset);
if (function_die)
{
- ParseFunctionBlocks(sc, Block::RootID, dwarf_cu, function_die, LLDB_INVALID_ADDRESS, false, true);
+ ParseFunctionBlocks(sc, &sc.function->GetBlock (false), dwarf_cu, function_die, LLDB_INVALID_ADDRESS, false, true);
}
}
@@ -3430,7 +3447,7 @@ SymbolFileDWARF::ParseVariableDIE
}
else if (sc.function != NULL)
{
- symbol_context_scope = sc.function->GetBlocks(true).GetBlockByID(sc_parent_die->GetOffset());
+ symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset());
if (symbol_context_scope == NULL)
symbol_context_scope = sc.function;
}
@@ -3495,11 +3512,14 @@ SymbolFileDWARF::ParseVariables
if (sc.function != NULL)
{
// Check to see if we already have parsed the variables for the given scope
- variables = sc.function->GetBlocks(true).GetVariableList(sc_parent_die->GetOffset(), false, false);
+
+ Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset());
+ assert (block != NULL);
+ variables = block->GetVariableList(false, true);
if (variables.get() == NULL)
{
variables.reset(new VariableList());
- sc.function->GetBlocks(true).SetVariableList(sc_parent_die->GetOffset(), variables);
+ block->SetVariableList(variables);
}
}
else
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index b6fb7736321..fc4325a5447 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -222,7 +222,7 @@ protected:
bool GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc);
lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die);
size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc,
- lldb::user_id_t parentBlockID,
+ lldb_private::Block *parent_block,
const DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
lldb::addr_t subprogram_low_pc,
OpenPOWER on IntegriCloud