Jason Molenda 1c73911d42 Change debugserver from using the mach port number (in debugserver's
own port namepsace) as the thread identifier to using the system-wide
globally unique thread id as the thread identifier number.

MachThread.cpp keeps both the unique id and the mach port number
for each thread.  All layers outside MachThread class use the unique
id with three exceptions: (1) Mach exceptions come in with the port
number (thread_port) which needs to be translated, (2) any calls to
low-level thread_get_state/thread_set_state/thread_suspend etc need
to use the mach port number, (3) MachThreadList::UpdateThreadList 
which creates the MachThread objects gets the unique id and passes
it to the MachThread ctor as an argument.

In general, any time nub_thread_t is used, it is now referring to a
unique thread id.  Any time a thread_t is used, it is now referring
to a mach port number.  There was some interchangability of these 
types previously.  nub_thread_t has also been changed to a 64-bit
type which necessitated some printf specification string changes.

I haven't been able to test these changes extensively yet but want
to checkpoint the work.  The scenarios I've been testing are all
working correctly so while there may be some corner cases I haven't
hit yet, I think it is substantially correct.

<rdar://problem/12931414> 

llvm-svn: 175870
2013-02-22 07:27:08 +00:00

77 lines
3.4 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;
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 (nub_thread_t tid);
nub_state_t GetState (nub_thread_t tid);
nub_thread_t SetCurrentThread (nub_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 ();
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 NumSupportedHardwareWatchpoints () const;
uint32_t GetThreadIndexForThreadStoppedWithSignal (const int signo) const;
MachThreadSP GetThreadByID (nub_thread_t tid) const;
MachThreadSP GetThreadByMachPortNumber (thread_t mach_port_number) const;
nub_thread_t GetThreadIDByMachPortNumber (thread_t mach_port_number) const;
protected:
typedef std::vector<MachThreadSP> collection;
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
uint32_t UpdateThreadList (MachProcess *process, bool update, collection *num_threads = NULL);
// const_iterator FindThreadByID (thread_t tid) const;
collection m_threads;
mutable PThreadMutex m_threads_mutex;
MachThreadSP m_current_thread;
};
#endif // #ifndef __MachThreadList_h__