Files
clang-p2996/lldb/tools/debugserver/source/MacOSX/MachThreadList.h
Greg Clayton 3af9ea56d3 Fixed Process::Halt() as it was broken for "process halt" after recent changes
to the DoHalt down in ProcessGDBRemote. I also moved the functionality that
was in ProcessGDBRemote::DoHalt up into Process::Halt so not every class has
to implement a tricky halt/resume on the internal state thread. The 
functionality is the same as it was before with two changes:
- when we eat the event we now just reuse the event we consume when the private
  state thread is paused and set the interrupted bool on the event if needed
- we also properly update the Process::m_public_state with the state of the
  event we consume.
  
Prior to this, if you issued a "process halt" it would eat the event, not 
update the process state, and then produce a new event with the interrupted
bit set and send it. Anyone listening to the event would get the stopped event
with a process that whose state was set to "running".

Fixed debugserver to not have to be spawned with the architecture of the
inferior process. This worked fine for launching processes, but when attaching
to processes by name or pid without a file in lldb, it would fail.

Now debugserver can support multiple architectures for a native debug session
on the current host. This currently means i386 and x86_64 are supported in
the same binary and a x86_64 debugserver can attach to a i386 executable.
This change involved a lot of changes to make sure we dynamically detect the
correct registers for the inferior process.

llvm-svn: 119680
2010-11-18 05:57:03 +00:00

75 lines
3.3 KiB
C++

//===-- MachThreadList.h ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Created by Greg Clayton on 6/19/07.
//
//===----------------------------------------------------------------------===//
#ifndef __MachThreadList_h__
#define __MachThreadList_h__
#include "MachThread.h"
class DNBThreadResumeActions;
class MachThreadList
{
public:
MachThreadList ();
~MachThreadList ();
void Clear ();
void Dump () const;
void GetRegisterState (int flavor, bool force);
void SetRegisterState (int flavor);
bool GetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, DNBRegisterValue *reg_value) const;
bool SetRegisterValue (nub_thread_t tid, uint32_t reg_set_idx, uint32_t reg_idx, const DNBRegisterValue *reg_value) const;
nub_size_t GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len);
nub_size_t SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len);
const char * GetThreadInfo (nub_thread_t tid) const;
void ProcessWillResume (MachProcess *process, const DNBThreadResumeActions &thread_actions);
uint32_t ProcessDidStop (MachProcess *process);
bool NotifyException (MachException::Data& exc);
bool ShouldStop (bool &step_more);
const char * GetName (thread_t tid);
nub_state_t GetState (thread_t tid);
nub_thread_t SetCurrentThread (thread_t tid);
bool GetThreadStoppedReason (nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const;
void DumpThreadStoppedReason (nub_thread_t tid) const;
bool GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info);
nub_size_t NumThreads () const;
nub_thread_t ThreadIDAtIndex (nub_size_t idx) const;
nub_thread_t CurrentThreadID ();
uint32_t GetThreadIndexByID (thread_t tid) const;
void CurrentThread (MachThreadSP& threadSP);
void NotifyBreakpointChanged (const DNBBreakpoint *bp);
uint32_t EnableHardwareBreakpoint (const DNBBreakpoint *bp) const;
bool DisableHardwareBreakpoint (const DNBBreakpoint *bp) const;
uint32_t EnableHardwareWatchpoint (const DNBBreakpoint *wp) const;
bool DisableHardwareWatchpoint (const DNBBreakpoint *wp) const;
uint32_t GetThreadIndexForThreadStoppedWithSignal (const int signo) const;
MachThread * GetThreadByID (nub_thread_t tid) const;
protected:
typedef std::vector<MachThreadSP> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
uint32_t UpdateThreadList (MachProcess *process, bool update);
// const_iterator FindThreadByID (thread_t tid) const;
collection m_threads;
PThreadMutex m_threads_mutex;
MachThreadSP m_current_thread;
};
#endif // #ifndef __MachThreadList_h__