2014-07-01 05:05:18 +08:00
//===-- NativeThreadLinux.cpp --------------------------------- -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
# include "NativeThreadLinux.h"
# include <signal.h>
2015-02-03 09:51:47 +08:00
# include <sstream>
2014-07-01 05:05:18 +08:00
# include "NativeProcessLinux.h"
2015-04-14 15:30:20 +08:00
# include "NativeRegisterContextLinux_arm.h"
2015-03-13 19:36:47 +08:00
# include "NativeRegisterContextLinux_arm64.h"
2014-07-01 07:51:35 +08:00
# include "NativeRegisterContextLinux_x86_64.h"
2015-03-17 19:43:56 +08:00
# include "NativeRegisterContextLinux_mips64.h"
2014-07-01 07:51:35 +08:00
2014-07-01 05:05:18 +08:00
# include "lldb/Core/Log.h"
# include "lldb/Core/State.h"
2014-09-10 04:54:56 +08:00
# include "lldb/Host/HostNativeThread.h"
2015-03-20 07:28:10 +08:00
# include "lldb/Utility/LLDBAssert.h"
2014-07-01 05:05:18 +08:00
# include "lldb/lldb-enumerations.h"
2014-09-10 04:54:56 +08:00
# include "llvm/ADT/SmallString.h"
2015-02-03 09:51:25 +08:00
# include "Plugins/Process/POSIX/CrashReason.h"
2015-05-11 18:03:10 +08:00
# include <sys/syscall.h>
// Try to define a macro to encapsulate the tgkill syscall
# define tgkill(pid, tid, sig) \
2015-08-10 03:04:41 +08:00
syscall ( SYS_tgkill , static_cast < : : pid_t > ( pid ) , static_cast < : : pid_t > ( tid ) , sig )
2015-05-11 18:03:10 +08:00
2014-07-01 05:05:18 +08:00
using namespace lldb ;
using namespace lldb_private ;
2015-03-31 17:52:22 +08:00
using namespace lldb_private : : process_linux ;
2014-07-01 05:05:18 +08:00
namespace
{
void LogThreadStopInfo ( Log & log , const ThreadStopInfo & stop_info , const char * const header )
{
switch ( stop_info . reason )
{
2015-03-20 22:45:13 +08:00
case eStopReasonNone :
log . Printf ( " %s: %s no stop reason " , __FUNCTION__ , header ) ;
return ;
case eStopReasonTrace :
log . Printf ( " %s: %s trace, stopping signal 0x% " PRIx32 , __FUNCTION__ , header , stop_info . details . signal . signo ) ;
return ;
case eStopReasonBreakpoint :
log . Printf ( " %s: %s breakpoint, stopping signal 0x% " PRIx32 , __FUNCTION__ , header , stop_info . details . signal . signo ) ;
return ;
case eStopReasonWatchpoint :
log . Printf ( " %s: %s watchpoint, stopping signal 0x% " PRIx32 , __FUNCTION__ , header , stop_info . details . signal . signo ) ;
return ;
2014-07-01 05:05:18 +08:00
case eStopReasonSignal :
2015-02-03 09:50:46 +08:00
log . Printf ( " %s: %s signal 0x%02 " PRIx32 , __FUNCTION__ , header , stop_info . details . signal . signo ) ;
2014-07-01 05:05:18 +08:00
return ;
case eStopReasonException :
2015-02-03 09:50:46 +08:00
log . Printf ( " %s: %s exception type 0x%02 " PRIx64 , __FUNCTION__ , header , stop_info . details . exception . type ) ;
2014-08-28 23:46:54 +08:00
return ;
case eStopReasonExec :
log . Printf ( " %s: %s exec, stopping signal 0x% " PRIx32 , __FUNCTION__ , header , stop_info . details . signal . signo ) ;
2014-07-01 05:05:18 +08:00
return ;
2015-03-20 22:45:13 +08:00
case eStopReasonPlanComplete :
log . Printf ( " %s: %s plan complete " , __FUNCTION__ , header ) ;
return ;
case eStopReasonThreadExiting :
log . Printf ( " %s: %s thread exiting " , __FUNCTION__ , header ) ;
return ;
case eStopReasonInstrumentation :
log . Printf ( " %s: %s instrumentation " , __FUNCTION__ , header ) ;
return ;
2014-07-01 05:05:18 +08:00
default :
2014-08-28 23:46:54 +08:00
log . Printf ( " %s: %s invalid stop reason % " PRIu32 , __FUNCTION__ , header , static_cast < uint32_t > ( stop_info . reason ) ) ;
2014-07-01 05:05:18 +08:00
}
}
}
NativeThreadLinux : : NativeThreadLinux ( NativeProcessLinux * process , lldb : : tid_t tid ) :
NativeThreadProtocol ( process , tid ) ,
m_state ( StateType : : eStateInvalid ) ,
m_stop_info ( ) ,
2015-02-03 09:51:25 +08:00
m_reg_context_sp ( ) ,
m_stop_description ( )
2014-07-01 05:05:18 +08:00
{
}
2014-09-13 06:51:49 +08:00
std : : string
2014-07-01 05:05:18 +08:00
NativeThreadLinux : : GetName ( )
{
NativeProcessProtocolSP process_sp = m_process_wp . lock ( ) ;
if ( ! process_sp )
return " <unknown: no process> " ;
// const NativeProcessLinux *const process = reinterpret_cast<NativeProcessLinux*> (process_sp->get ());
2014-09-10 04:54:56 +08:00
llvm : : SmallString < 32 > thread_name ;
HostNativeThread : : GetName ( GetID ( ) , thread_name ) ;
return thread_name . c_str ( ) ;
2014-07-01 05:05:18 +08:00
}
lldb : : StateType
NativeThreadLinux : : GetState ( )
{
return m_state ;
}
bool
2015-02-03 09:51:25 +08:00
NativeThreadLinux : : GetStopReason ( ThreadStopInfo & stop_info , std : : string & description )
2014-07-01 05:05:18 +08:00
{
Log * log ( GetLogIfAllCategoriesSet ( LIBLLDB_LOG_THREAD ) ) ;
2015-02-03 09:51:25 +08:00
description . clear ( ) ;
2014-07-01 05:05:18 +08:00
switch ( m_state )
{
case eStateStopped :
case eStateCrashed :
case eStateExited :
case eStateSuspended :
case eStateUnloaded :
if ( log )
2014-08-28 23:46:54 +08:00
LogThreadStopInfo ( * log , m_stop_info , " m_stop_info in thread: " ) ;
2014-07-01 05:05:18 +08:00
stop_info = m_stop_info ;
Report inferior SIGSEGV as a signal instead of an exception on linux
Summary:
Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.
This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.
I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).
Test Plan: All tests pass on linux and osx.
Reviewers: ovyalov, clayborg, emaste
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D10057
llvm-svn: 238549
2015-05-29 18:13:03 +08:00
description = m_stop_description ;
2014-07-01 05:05:18 +08:00
if ( log )
2014-08-28 23:46:54 +08:00
LogThreadStopInfo ( * log , stop_info , " returned stop_info: " ) ;
2015-02-03 09:51:25 +08:00
2014-07-01 05:05:18 +08:00
return true ;
case eStateInvalid :
case eStateConnected :
case eStateAttaching :
case eStateLaunching :
case eStateRunning :
case eStateStepping :
case eStateDetached :
if ( log )
{
log - > Printf ( " NativeThreadLinux::%s tid % " PRIu64 " in state %s cannot answer stop reason " ,
__FUNCTION__ , GetID ( ) , StateAsCString ( m_state ) ) ;
}
return false ;
}
2014-09-16 14:34:29 +08:00
llvm_unreachable ( " unhandled StateType! " ) ;
2014-07-01 05:05:18 +08:00
}
2015-03-31 17:52:22 +08:00
NativeRegisterContextSP
2014-07-01 05:05:18 +08:00
NativeThreadLinux : : GetRegisterContext ( )
{
// Return the register context if we already created it.
if ( m_reg_context_sp )
return m_reg_context_sp ;
NativeProcessProtocolSP m_process_sp = m_process_wp . lock ( ) ;
if ( ! m_process_sp )
return NativeRegisterContextSP ( ) ;
ArchSpec target_arch ;
if ( ! m_process_sp - > GetArchitecture ( target_arch ) )
return NativeRegisterContextSP ( ) ;
2015-05-26 19:58:52 +08:00
const uint32_t concrete_frame_idx = 0 ;
m_reg_context_sp . reset ( NativeRegisterContextLinux : : CreateHostNativeRegisterContextLinux ( target_arch ,
* this ,
concrete_frame_idx ) ) ;
2014-07-01 05:05:18 +08:00
return m_reg_context_sp ;
}
Error
NativeThreadLinux : : SetWatchpoint ( lldb : : addr_t addr , size_t size , uint32_t watch_flags , bool hardware )
{
2015-02-03 09:51:47 +08:00
if ( ! hardware )
return Error ( " not implemented " ) ;
2015-02-27 03:48:15 +08:00
if ( m_state = = eStateLaunching )
return Error ( ) ;
2015-02-03 09:51:47 +08:00
Error error = RemoveWatchpoint ( addr ) ;
if ( error . Fail ( ) ) return error ;
NativeRegisterContextSP reg_ctx = GetRegisterContext ( ) ;
uint32_t wp_index =
reg_ctx - > SetHardwareWatchpoint ( addr , size , watch_flags ) ;
if ( wp_index = = LLDB_INVALID_INDEX32 )
return Error ( " Setting hardware watchpoint failed. " ) ;
m_watchpoint_index_map . insert ( { addr , wp_index } ) ;
return Error ( ) ;
2014-07-01 05:05:18 +08:00
}
Error
NativeThreadLinux : : RemoveWatchpoint ( lldb : : addr_t addr )
{
2015-02-03 09:51:47 +08:00
auto wp = m_watchpoint_index_map . find ( addr ) ;
if ( wp = = m_watchpoint_index_map . end ( ) )
return Error ( ) ;
uint32_t wp_index = wp - > second ;
m_watchpoint_index_map . erase ( wp ) ;
if ( GetRegisterContext ( ) - > ClearHardwareWatchpoint ( wp_index ) )
return Error ( ) ;
return Error ( " Clearing hardware watchpoint failed. " ) ;
2014-07-01 05:05:18 +08:00
}
void
NativeThreadLinux : : SetRunning ( )
{
const StateType new_state = StateType : : eStateRunning ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_info . reason = StopReason : : eStopReasonNone ;
2015-02-03 09:51:25 +08:00
m_stop_description . clear ( ) ;
2015-02-03 09:51:47 +08:00
// If watchpoints have been set, but none on this thread,
// then this is a new thread. So set all existing watchpoints.
if ( m_watchpoint_index_map . empty ( ) )
{
2015-02-20 01:58:04 +08:00
const auto process_sp = GetProcess ( ) ;
if ( process_sp )
2015-02-03 09:51:47 +08:00
{
2015-02-20 01:58:04 +08:00
const auto & watchpoint_map = process_sp - > GetWatchpointMap ( ) ;
if ( watchpoint_map . empty ( ) ) return ;
GetRegisterContext ( ) - > ClearAllHardwareWatchpoints ( ) ;
for ( const auto & pair : watchpoint_map )
{
const auto & wp = pair . second ;
SetWatchpoint ( wp . m_addr , wp . m_size , wp . m_watch_flags , wp . m_hardware ) ;
}
2015-02-03 09:51:47 +08:00
}
}
2014-07-01 05:05:18 +08:00
}
void
NativeThreadLinux : : SetStepping ( )
{
const StateType new_state = StateType : : eStateStepping ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_info . reason = StopReason : : eStopReasonNone ;
}
void
Report inferior SIGSEGV as a signal instead of an exception on linux
Summary:
Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.
This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.
I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).
Test Plan: All tests pass on linux and osx.
Reviewers: ovyalov, clayborg, emaste
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D10057
llvm-svn: 238549
2015-05-29 18:13:03 +08:00
NativeThreadLinux : : SetStoppedBySignal ( uint32_t signo , const siginfo_t * info )
2014-07-01 05:05:18 +08:00
{
Log * log ( GetLogIfAllCategoriesSet ( LIBLLDB_LOG_THREAD ) ) ;
if ( log )
2015-02-03 09:50:51 +08:00
log - > Printf ( " NativeThreadLinux::%s called with signal 0x%02 " PRIx32 , __FUNCTION__ , signo ) ;
2014-07-01 05:05:18 +08:00
const StateType new_state = StateType : : eStateStopped ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_info . reason = StopReason : : eStopReasonSignal ;
m_stop_info . details . signal . signo = signo ;
Report inferior SIGSEGV as a signal instead of an exception on linux
Summary:
Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.
This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.
I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).
Test Plan: All tests pass on linux and osx.
Reviewers: ovyalov, clayborg, emaste
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D10057
llvm-svn: 238549
2015-05-29 18:13:03 +08:00
m_stop_description . clear ( ) ;
2015-07-30 13:38:11 +08:00
if ( info )
Report inferior SIGSEGV as a signal instead of an exception on linux
Summary:
Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.
This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.
I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).
Test Plan: All tests pass on linux and osx.
Reviewers: ovyalov, clayborg, emaste
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D10057
llvm-svn: 238549
2015-05-29 18:13:03 +08:00
{
2015-07-30 13:38:11 +08:00
switch ( signo )
{
case SIGSEGV :
case SIGBUS :
case SIGFPE :
case SIGILL :
//In case of MIPS64 target, SI_KERNEL is generated for invalid 64bit address.
const auto reason = ( info - > si_signo = = SIGBUS & & info - > si_code = = SI_KERNEL ) ?
CrashReason : : eInvalidAddress : GetCrashReason ( * info ) ;
m_stop_description = GetCrashReasonString ( reason , reinterpret_cast < uintptr_t > ( info - > si_addr ) ) ;
break ;
}
Report inferior SIGSEGV as a signal instead of an exception on linux
Summary:
Previously, we reported inferior receiving SIGSEGV (or SIGILL, SIGFPE, SIGBUS) as an "exception"
to LLDB, presumably to match OSX behaviour. Beside the fact that we were basically lying to the
user, this was also causing problems with inferiors which handle SIGSEGV by themselves, since
LLDB was unable to reinject this signal back into the inferior.
This commit changes LLGS to report SIGSEGV as a signal. This has necessitated some changes in the
test-suite, which had previously used eStopReasonException to locate threads that crashed. Now it
uses platform-specific logic, which in the case of linux searches for eStopReasonSignaled with
signal=SIGSEGV.
I have also added the ability to set the description of StopInfoUnixSignal using the description
field of the gdb-remote packet. The linux stub uses this to display additional information about
the segfault (invalid address, address access protected, etc.).
Test Plan: All tests pass on linux and osx.
Reviewers: ovyalov, clayborg, emaste
Subscribers: emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D10057
llvm-svn: 238549
2015-05-29 18:13:03 +08:00
}
2014-07-01 05:05:18 +08:00
}
2014-09-12 07:29:14 +08:00
bool
NativeThreadLinux : : IsStopped ( int * signo )
{
if ( ! StateIsStoppedState ( m_state , false ) )
return false ;
// If we are stopped by a signal, return the signo.
if ( signo & &
m_state = = StateType : : eStateStopped & &
m_stop_info . reason = = StopReason : : eStopReasonSignal )
{
* signo = m_stop_info . details . signal . signo ;
}
// Regardless, we are stopped.
return true ;
}
2014-08-28 23:46:54 +08:00
void
NativeThreadLinux : : SetStoppedByExec ( )
{
Log * log ( GetLogIfAllCategoriesSet ( LIBLLDB_LOG_THREAD ) ) ;
if ( log )
log - > Printf ( " NativeThreadLinux::%s() " , __FUNCTION__ ) ;
const StateType new_state = StateType : : eStateStopped ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_info . reason = StopReason : : eStopReasonExec ;
m_stop_info . details . signal . signo = SIGSTOP ;
}
2014-07-01 05:05:18 +08:00
void
NativeThreadLinux : : SetStoppedByBreakpoint ( )
{
const StateType new_state = StateType : : eStateStopped ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
2015-02-03 09:51:25 +08:00
m_stop_info . reason = StopReason : : eStopReasonBreakpoint ;
2014-07-01 05:05:18 +08:00
m_stop_info . details . signal . signo = SIGTRAP ;
2015-02-03 09:51:47 +08:00
m_stop_description . clear ( ) ;
}
void
2015-03-20 07:28:10 +08:00
NativeThreadLinux : : SetStoppedByWatchpoint ( uint32_t wp_index )
2015-02-03 09:51:47 +08:00
{
const StateType new_state = StateType : : eStateStopped ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_description . clear ( ) ;
2015-03-17 22:40:57 +08:00
2015-03-20 07:28:10 +08:00
lldbassert ( wp_index ! = LLDB_INVALID_INDEX32 & &
" wp_index cannot be invalid " ) ;
2015-03-17 22:40:57 +08:00
2015-03-20 07:28:10 +08:00
std : : ostringstream ostr ;
ostr < < GetRegisterContext ( ) - > GetWatchpointAddress ( wp_index ) < < " " ;
ostr < < wp_index ;
2015-08-13 11:44:09 +08:00
/*
* MIPS : Last 3 bits of the watchpoint address are masked by the kernel . For example :
* ' n ' is at 0x120010d00 and ' m ' is 0x120010d04 . When a watchpoint is set at ' m ' , then
* watch exception is generated even when ' n ' is read / written . To handle this case ,
* find the base address of the load / store instruction and append it in the stop - info
* packet .
*/
ostr < < " " < < GetRegisterContext ( ) - > GetWatchpointHitAddress ( wp_index ) ;
2015-03-20 07:28:10 +08:00
m_stop_description = ostr . str ( ) ;
2015-03-17 22:40:57 +08:00
2015-03-20 07:28:10 +08:00
m_stop_info . reason = StopReason : : eStopReasonWatchpoint ;
m_stop_info . details . signal . signo = SIGTRAP ;
2014-07-01 05:05:18 +08:00
}
bool
NativeThreadLinux : : IsStoppedAtBreakpoint ( )
{
2015-02-03 09:51:47 +08:00
return GetState ( ) = = StateType : : eStateStopped & &
m_stop_info . reason = = StopReason : : eStopReasonBreakpoint ;
}
2014-07-01 05:05:18 +08:00
2015-02-03 09:51:47 +08:00
bool
NativeThreadLinux : : IsStoppedAtWatchpoint ( )
{
return GetState ( ) = = StateType : : eStateStopped & &
m_stop_info . reason = = StopReason : : eStopReasonWatchpoint ;
2014-07-01 05:05:18 +08:00
}
void
2015-02-03 09:51:25 +08:00
NativeThreadLinux : : SetStoppedByTrace ( )
{
const StateType new_state = StateType : : eStateStopped ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_info . reason = StopReason : : eStopReasonTrace ;
m_stop_info . details . signal . signo = SIGTRAP ;
}
2014-07-01 05:05:18 +08:00
void
2015-07-23 17:09:29 +08:00
NativeThreadLinux : : SetStoppedWithNoReason ( )
2014-07-01 05:05:18 +08:00
{
2015-07-23 17:09:29 +08:00
const StateType new_state = StateType : : eStateStopped ;
2014-07-01 05:05:18 +08:00
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_info . reason = StopReason : : eStopReasonNone ;
2015-07-23 17:09:29 +08:00
m_stop_info . details . signal . signo = 0 ;
2014-07-01 05:05:18 +08:00
}
void
NativeThreadLinux : : SetExited ( )
{
const StateType new_state = StateType : : eStateExited ;
MaybeLogStateChange ( new_state ) ;
m_state = new_state ;
m_stop_info . reason = StopReason : : eStopReasonThreadExiting ;
}
2015-05-11 18:03:10 +08:00
Error
NativeThreadLinux : : RequestStop ( )
{
Log * log ( GetLogIfAllCategoriesSet ( LIBLLDB_LOG_THREAD ) ) ;
const auto process_sp = GetProcess ( ) ;
if ( ! process_sp )
return Error ( " Process is null. " ) ;
lldb : : pid_t pid = process_sp - > GetID ( ) ;
lldb : : tid_t tid = GetID ( ) ;
if ( log )
log - > Printf ( " NativeThreadLinux::%s requesting thread stop(pid: % " PRIu64 " , tid: % " PRIu64 " ) " , __FUNCTION__ , pid , tid ) ;
Error err ;
errno = 0 ;
if ( : : tgkill ( pid , tid , SIGSTOP ) ! = 0 )
{
err . SetErrorToErrno ( ) ;
if ( log )
log - > Printf ( " NativeThreadLinux::%s tgkill(% " PRIu64 " , % " PRIu64 " , SIGSTOP) failed: %s " , __FUNCTION__ , pid , tid , err . AsCString ( ) ) ;
}
return err ;
}
2014-07-01 05:05:18 +08:00
void
NativeThreadLinux : : MaybeLogStateChange ( lldb : : StateType new_state )
{
Log * log ( GetLogIfAllCategoriesSet ( LIBLLDB_LOG_THREAD ) ) ;
// If we're not logging, we're done.
if ( ! log )
return ;
// If this is a state change to the same state, we're done.
lldb : : StateType old_state = m_state ;
if ( new_state = = old_state )
return ;
NativeProcessProtocolSP m_process_sp = m_process_wp . lock ( ) ;
lldb : : pid_t pid = m_process_sp ? m_process_sp - > GetID ( ) : LLDB_INVALID_PROCESS_ID ;
// Log it.
log - > Printf ( " NativeThreadLinux: thread (pid=% " PRIu64 " , tid=% " PRIu64 " ) changing from state %s to %s " , pid , GetID ( ) , StateAsCString ( old_state ) , StateAsCString ( new_state ) ) ;
}