MachThread.cpp revision 716cefbded5b438eeb8d310d3965dd1be86bcc46
1//===-- MachThread.cpp ------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// Created by Greg Clayton on 6/19/07. 11// 12//===----------------------------------------------------------------------===// 13 14#include "MachThread.h" 15#include "MachProcess.h" 16#include "DNBLog.h" 17#include "DNB.h" 18 19static uint32_t 20GetSequenceID() 21{ 22 static uint32_t g_nextID = 0; 23 return ++g_nextID; 24} 25 26MachThread::MachThread (MachProcess *process, thread_t tid) : 27 m_process (process), 28 m_tid (tid), 29 m_seq_id (GetSequenceID()), 30 m_state (eStateUnloaded), 31 m_state_mutex (PTHREAD_MUTEX_RECURSIVE), 32 m_break_id (INVALID_NUB_BREAK_ID), 33 m_suspend_count (0), 34 m_stop_exception (), 35 m_arch_ap (DNBArchProtocol::Create (this)), 36 m_reg_sets (NULL), 37 m_num_reg_sets (0) 38#ifdef THREAD_IDENTIFIER_INFO_COUNT 39 , m_ident_info(), 40 m_proc_threadinfo(), 41 m_dispatch_queue_name() 42#endif 43{ 44 nub_size_t num_reg_sets = 0; 45 m_reg_sets = m_arch_ap->GetRegisterSetInfo (&num_reg_sets); 46 m_num_reg_sets = num_reg_sets; 47 48 // Get the thread state so we know if a thread is in a state where we can't 49 // muck with it and also so we get the suspend count correct in case it was 50 // already suspended 51 GetBasicInfo(); 52 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::MachThread ( process = %p, tid = 0x%4.4x, seq_id = %u )", &m_process, m_tid, m_seq_id); 53} 54 55MachThread::~MachThread() 56{ 57 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::~MachThread() for tid = 0x%4.4x (%u)", m_tid, m_seq_id); 58} 59 60 61 62void 63MachThread::Suspend() 64{ 65 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__); 66 if (ThreadIDIsValid(m_tid)) 67 { 68 DNBError err(::thread_suspend (m_tid), DNBError::MachKernel); 69 if (err.Success()) 70 m_suspend_count++; 71 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) 72 err.LogThreaded("::thread_suspend (%4.4x)", m_tid); 73 } 74} 75 76void 77MachThread::Resume(bool others_stopped) 78{ 79 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__); 80 if (ThreadIDIsValid(m_tid)) 81 { 82 SetSuspendCountBeforeResume(others_stopped); 83 } 84} 85 86bool 87MachThread::SetSuspendCountBeforeResume(bool others_stopped) 88{ 89 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__); 90 DNBError err; 91 if (ThreadIDIsValid(m_tid) == false) 92 return false; 93 94 size_t times_to_resume; 95 96 if (others_stopped) 97 { 98 times_to_resume = GetBasicInfo()->suspend_count; 99 m_suspend_count = - (times_to_resume - m_suspend_count); 100 } 101 else 102 { 103 times_to_resume = m_suspend_count; 104 m_suspend_count = 0; 105 } 106 107 if (times_to_resume > 0) 108 { 109 while (times_to_resume > 0) 110 { 111 err = ::thread_resume (m_tid); 112 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) 113 err.LogThreaded("::thread_resume (%4.4x)", m_tid); 114 if (err.Success()) 115 --times_to_resume; 116 else 117 { 118 if (GetBasicInfo()) 119 times_to_resume = m_basic_info.suspend_count; 120 else 121 times_to_resume = 0; 122 return false; // ??? 123 } 124 } 125 } 126 return true; 127} 128 129bool 130MachThread::RestoreSuspendCountAfterStop () 131{ 132 DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__); 133 DNBError err; 134 if (ThreadIDIsValid(m_tid) == false) 135 return false; 136 137 if (m_suspend_count > 0) 138 { 139 while (m_suspend_count > 0) 140 { 141 err = ::thread_resume (m_tid); 142 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) 143 err.LogThreaded("::thread_resume (%4.4x)", m_tid); 144 if (err.Success()) 145 --m_suspend_count; 146 else 147 { 148 if (GetBasicInfo()) 149 m_suspend_count = m_basic_info.suspend_count; 150 else 151 m_suspend_count = 0; 152 return false; // ??? 153 } 154 } 155 } 156 else if (m_suspend_count < 0) 157 { 158 while (m_suspend_count < 0) 159 { 160 err = ::thread_suspend (m_tid); 161 if (err.Success()) 162 ++m_suspend_count; 163 if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) 164 err.LogThreaded("::thread_suspend (%4.4x)", m_tid); 165 } 166 } 167 return true; 168} 169 170 171const char * 172MachThread::GetBasicInfoAsString () const 173{ 174 static char g_basic_info_string[1024]; 175 struct thread_basic_info basicInfo; 176 177 if (GetBasicInfo(m_tid, &basicInfo)) 178 { 179 180// char run_state_str[32]; 181// size_t run_state_str_size = sizeof(run_state_str); 182// switch (basicInfo.run_state) 183// { 184// case TH_STATE_RUNNING: strncpy(run_state_str, "running", run_state_str_size); break; 185// case TH_STATE_STOPPED: strncpy(run_state_str, "stopped", run_state_str_size); break; 186// case TH_STATE_WAITING: strncpy(run_state_str, "waiting", run_state_str_size); break; 187// case TH_STATE_UNINTERRUPTIBLE: strncpy(run_state_str, "uninterruptible", run_state_str_size); break; 188// case TH_STATE_HALTED: strncpy(run_state_str, "halted", run_state_str_size); break; 189// default: snprintf(run_state_str, run_state_str_size, "%d", basicInfo.run_state); break; // ??? 190// } 191 float user = (float)basicInfo.user_time.seconds + (float)basicInfo.user_time.microseconds / 1000000.0f; 192 float system = (float)basicInfo.user_time.seconds + (float)basicInfo.user_time.microseconds / 1000000.0f; 193 snprintf(g_basic_info_string, sizeof(g_basic_info_string), "Thread 0x%4.4x: user=%f system=%f cpu=%d sleep_time=%d", 194 InferiorThreadID(), 195 user, 196 system, 197 basicInfo.cpu_usage, 198 basicInfo.sleep_time); 199 200 return g_basic_info_string; 201 } 202 return NULL; 203} 204 205thread_t 206MachThread::InferiorThreadID() const 207{ 208 mach_msg_type_number_t i; 209 mach_port_name_array_t names; 210 mach_port_type_array_t types; 211 mach_msg_type_number_t ncount, tcount; 212 thread_t inferior_tid = INVALID_NUB_THREAD; 213 task_t my_task = ::mach_task_self(); 214 task_t task = m_process->Task().TaskPort(); 215 216 kern_return_t kret = ::mach_port_names (task, &names, &ncount, &types, &tcount); 217 if (kret == KERN_SUCCESS) 218 { 219 220 for (i = 0; i < ncount; i++) 221 { 222 mach_port_t my_name; 223 mach_msg_type_name_t my_type; 224 225 kret = ::mach_port_extract_right (task, names[i], MACH_MSG_TYPE_COPY_SEND, &my_name, &my_type); 226 if (kret == KERN_SUCCESS) 227 { 228 ::mach_port_deallocate (my_task, my_name); 229 if (my_name == m_tid) 230 { 231 inferior_tid = names[i]; 232 break; 233 } 234 } 235 } 236 // Free up the names and types 237 ::vm_deallocate (my_task, (vm_address_t) names, ncount * sizeof (mach_port_name_t)); 238 ::vm_deallocate (my_task, (vm_address_t) types, tcount * sizeof (mach_port_type_t)); 239 } 240 return inferior_tid; 241} 242 243bool 244MachThread::IsUserReady() 245{ 246 if (m_basic_info.run_state == 0) 247 GetBasicInfo (); 248 249 switch (m_basic_info.run_state) 250 { 251 default: 252 case TH_STATE_UNINTERRUPTIBLE: 253 break; 254 255 case TH_STATE_RUNNING: 256 case TH_STATE_STOPPED: 257 case TH_STATE_WAITING: 258 case TH_STATE_HALTED: 259 return true; 260 } 261 return false; 262} 263 264struct thread_basic_info * 265MachThread::GetBasicInfo () 266{ 267 if (MachThread::GetBasicInfo(m_tid, &m_basic_info)) 268 return &m_basic_info; 269 return NULL; 270} 271 272 273bool 274MachThread::GetBasicInfo(thread_t thread, struct thread_basic_info *basicInfoPtr) 275{ 276 if (ThreadIDIsValid(thread)) 277 { 278 unsigned int info_count = THREAD_BASIC_INFO_COUNT; 279 kern_return_t err = ::thread_info (thread, THREAD_BASIC_INFO, (thread_info_t) basicInfoPtr, &info_count); 280 if (err == KERN_SUCCESS) 281 return true; 282 } 283 ::memset (basicInfoPtr, 0, sizeof (struct thread_basic_info)); 284 return false; 285} 286 287 288bool 289MachThread::ThreadIDIsValid(thread_t thread) 290{ 291 return thread != THREAD_NULL; 292} 293 294bool 295MachThread::GetRegisterState(int flavor, bool force) 296{ 297 return m_arch_ap->GetRegisterState(flavor, force) == KERN_SUCCESS; 298} 299 300bool 301MachThread::SetRegisterState(int flavor) 302{ 303 return m_arch_ap->SetRegisterState(flavor) == KERN_SUCCESS; 304} 305 306uint64_t 307MachThread::GetPC(uint64_t failValue) 308{ 309 // Get program counter 310 return m_arch_ap->GetPC(failValue); 311} 312 313bool 314MachThread::SetPC(uint64_t value) 315{ 316 // Set program counter 317 return m_arch_ap->SetPC(value); 318} 319 320uint64_t 321MachThread::GetSP(uint64_t failValue) 322{ 323 // Get stack pointer 324 return m_arch_ap->GetSP(failValue); 325} 326 327nub_process_t 328MachThread::ProcessID() const 329{ 330 if (m_process) 331 return m_process->ProcessID(); 332 return INVALID_NUB_PROCESS; 333} 334 335void 336MachThread::Dump(uint32_t index) 337{ 338 const char * thread_run_state = NULL; 339 340 switch (m_basic_info.run_state) 341 { 342 case TH_STATE_RUNNING: thread_run_state = "running"; break; // 1 thread is running normally 343 case TH_STATE_STOPPED: thread_run_state = "stopped"; break; // 2 thread is stopped 344 case TH_STATE_WAITING: thread_run_state = "waiting"; break; // 3 thread is waiting normally 345 case TH_STATE_UNINTERRUPTIBLE: thread_run_state = "uninter"; break; // 4 thread is in an uninterruptible wait 346 case TH_STATE_HALTED: thread_run_state = "halted "; break; // 5 thread is halted at a 347 default: thread_run_state = "???"; break; 348 } 349 350 DNBLogThreaded("[%3u] #%3u tid: 0x%4.4x, pc: 0x%16.16llx, sp: 0x%16.16llx, breakID: %3d, user: %d.%06.6d, system: %d.%06.6d, cpu: %2d, policy: %2d, run_state: %2d (%s), flags: %2d, suspend_count: %2d (current %2d), sleep_time: %d", 351 index, 352 m_seq_id, 353 m_tid, 354 GetPC(INVALID_NUB_ADDRESS), 355 GetSP(INVALID_NUB_ADDRESS), 356 m_break_id, 357 m_basic_info.user_time.seconds, m_basic_info.user_time.microseconds, 358 m_basic_info.system_time.seconds, m_basic_info.system_time.microseconds, 359 m_basic_info.cpu_usage, 360 m_basic_info.policy, 361 m_basic_info.run_state, 362 thread_run_state, 363 m_basic_info.flags, 364 m_basic_info.suspend_count, m_suspend_count, 365 m_basic_info.sleep_time); 366 //DumpRegisterState(0); 367} 368 369void 370MachThread::ThreadWillResume(const DNBThreadResumeAction *thread_action, bool others_stopped) 371{ 372 if (thread_action->addr != INVALID_NUB_ADDRESS) 373 SetPC (thread_action->addr); 374 375 SetState (thread_action->state); 376 switch (thread_action->state) 377 { 378 case eStateStopped: 379 case eStateSuspended: 380 assert (others_stopped == false); 381 Suspend(); 382 break; 383 384 case eStateRunning: 385 case eStateStepping: 386 Resume(others_stopped); 387 break; 388 default: 389 break; 390 } 391 m_arch_ap->ThreadWillResume(); 392 m_stop_exception.Clear(); 393} 394 395nub_break_t 396MachThread::CurrentBreakpoint() 397{ 398 return m_process->Breakpoints().FindIDByAddress(GetPC()); 399} 400 401bool 402MachThread::ShouldStop(bool &step_more) 403{ 404 // See if this thread is at a breakpoint? 405 nub_break_t breakID = CurrentBreakpoint(); 406 407 if (NUB_BREAK_ID_IS_VALID(breakID)) 408 { 409 // This thread is sitting at a breakpoint, ask the breakpoint 410 // if we should be stopping here. 411 if (Process()->Breakpoints().ShouldStop(ProcessID(), ThreadID(), breakID)) 412 return true; 413 else 414 { 415 // The breakpoint said we shouldn't stop, but we may have gotten 416 // a signal or the user may have requested to stop in some other 417 // way. Stop if we have a valid exception (this thread won't if 418 // another thread was the reason this process stopped) and that 419 // exception, is NOT a breakpoint exception (a common case would 420 // be a SIGINT signal). 421 if (GetStopException().IsValid() && !GetStopException().IsBreakpoint()) 422 return true; 423 } 424 } 425 else 426 { 427 if (m_arch_ap->StepNotComplete()) 428 { 429 step_more = true; 430 return false; 431 } 432 // The thread state is used to let us know what the thread was 433 // trying to do. MachThread::ThreadWillResume() will set the 434 // thread state to various values depending if the thread was 435 // the current thread and if it was to be single stepped, or 436 // resumed. 437 if (GetState() == eStateRunning) 438 { 439 // If our state is running, then we should continue as we are in 440 // the process of stepping over a breakpoint. 441 return false; 442 } 443 else 444 { 445 // Stop if we have any kind of valid exception for this 446 // thread. 447 if (GetStopException().IsValid()) 448 return true; 449 } 450 } 451 return false; 452} 453bool 454MachThread::IsStepping() 455{ 456#if ENABLE_AUTO_STEPPING_OVER_BP 457 // Return true if this thread is currently being stepped. 458 // MachThread::ThreadWillResume currently determines this by looking if we 459 // have been asked to single step, or if we are at a breakpoint instruction 460 // and have been asked to resume. In the latter case we need to disable the 461 // breakpoint we are at, single step, re-enable and continue. 462 nub_state_t state = GetState(); 463 return ((state == eStateStepping) || 464 (state == eStateRunning && NUB_BREAK_ID_IS_VALID(CurrentBreakpoint()))); 465#else 466 return GetState() == eStateStepping; 467#endif 468} 469 470 471bool 472MachThread::ThreadDidStop() 473{ 474 // This thread has existed prior to resuming under debug nub control, 475 // and has just been stopped. Do any cleanup that needs to be done 476 // after running. 477 478 // The thread state and breakpoint will still have the same values 479 // as they had prior to resuming the thread, so it makes it easy to check 480 // if we were trying to step a thread, or we tried to resume while being 481 // at a breakpoint. 482 483 // When this method gets called, the process state is still in the 484 // state it was in while running so we can act accordingly. 485 m_arch_ap->ThreadDidStop(); 486 487 488 // We may have suspended this thread so the primary thread could step 489 // without worrying about race conditions, so lets restore our suspend 490 // count. 491 RestoreSuspendCountAfterStop(); 492 493 // Update the basic information for a thread 494 MachThread::GetBasicInfo(m_tid, &m_basic_info); 495 496#if ENABLE_AUTO_STEPPING_OVER_BP 497 // See if we were at a breakpoint when we last resumed that we disabled, 498 // re-enable it. 499 nub_break_t breakID = CurrentBreakpoint(); 500 501 if (NUB_BREAK_ID_IS_VALID(breakID)) 502 { 503 m_process->EnableBreakpoint(breakID); 504 if (m_basic_info.suspend_count > 0) 505 { 506 SetState(eStateSuspended); 507 } 508 else 509 { 510 // If we last were at a breakpoint and we single stepped, our state 511 // will be "running" to indicate we need to continue after stepping 512 // over the breakpoint instruction. If we step over a breakpoint 513 // instruction, we need to stop. 514 if (GetState() == eStateRunning) 515 { 516 // Leave state set to running so we will continue automatically 517 // from this breakpoint 518 } 519 else 520 { 521 SetState(eStateStopped); 522 } 523 } 524 } 525 else 526 { 527 if (m_basic_info.suspend_count > 0) 528 { 529 SetState(eStateSuspended); 530 } 531 else 532 { 533 SetState(eStateStopped); 534 } 535 } 536#else 537 if (m_basic_info.suspend_count > 0) 538 SetState(eStateSuspended); 539 else 540 SetState(eStateStopped); 541#endif 542 return true; 543} 544 545bool 546MachThread::NotifyException(MachException::Data& exc) 547{ 548 if (m_stop_exception.IsValid()) 549 { 550 // We may have more than one exception for a thread, but we need to 551 // only remember the one that we will say is the reason we stopped. 552 // We may have been single stepping and also gotten a signal exception, 553 // so just remember the most pertinent one. 554 if (m_stop_exception.IsBreakpoint()) 555 m_stop_exception = exc; 556 } 557 else 558 { 559 m_stop_exception = exc; 560 } 561 bool handled = m_arch_ap->NotifyException(exc); 562 if (!handled) 563 { 564 handled = true; 565// switch (exc.exc_type) 566// { 567// case EXC_BAD_ACCESS: 568// break; 569// case EXC_BAD_INSTRUCTION: 570// break; 571// case EXC_ARITHMETIC: 572// break; 573// case EXC_EMULATION: 574// break; 575// case EXC_SOFTWARE: 576// break; 577// case EXC_BREAKPOINT: 578// break; 579// case EXC_SYSCALL: 580// break; 581// case EXC_MACH_SYSCALL: 582// break; 583// case EXC_RPC_ALERT: 584// break; 585// } 586 } 587 return handled; 588} 589 590 591nub_state_t 592MachThread::GetState() 593{ 594 // If any other threads access this we will need a mutex for it 595 PTHREAD_MUTEX_LOCKER (locker, m_state_mutex); 596 return m_state; 597} 598 599void 600MachThread::SetState(nub_state_t state) 601{ 602 PTHREAD_MUTEX_LOCKER (locker, m_state_mutex); 603 m_state = state; 604 DNBLogThreadedIf(LOG_THREAD, "MachThread::SetState ( %s ) for tid = 0x%4.4x", DNBStateAsString(state), m_tid); 605} 606 607uint32_t 608MachThread::GetNumRegistersInSet(int regSet) const 609{ 610 if (regSet < m_num_reg_sets) 611 return m_reg_sets[regSet].num_registers; 612 return 0; 613} 614 615const char * 616MachThread::GetRegisterSetName(int regSet) const 617{ 618 if (regSet < m_num_reg_sets) 619 return m_reg_sets[regSet].name; 620 return NULL; 621} 622 623const DNBRegisterInfo * 624MachThread::GetRegisterInfo(int regSet, int regIndex) const 625{ 626 if (regSet < m_num_reg_sets) 627 if (regIndex < m_reg_sets[regSet].num_registers) 628 return &m_reg_sets[regSet].registers[regIndex]; 629 return NULL; 630} 631void 632MachThread::DumpRegisterState(int regSet) 633{ 634 if (regSet == REGISTER_SET_ALL) 635 { 636 for (regSet = 1; regSet < m_num_reg_sets; regSet++) 637 DumpRegisterState(regSet); 638 } 639 else 640 { 641 if (m_arch_ap->RegisterSetStateIsValid(regSet)) 642 { 643 const size_t numRegisters = GetNumRegistersInSet(regSet); 644 size_t regIndex = 0; 645 DNBRegisterValueClass reg; 646 for (regIndex = 0; regIndex < numRegisters; ++regIndex) 647 { 648 if (m_arch_ap->GetRegisterValue(regSet, regIndex, ®)) 649 { 650 reg.Dump(NULL, NULL); 651 } 652 } 653 } 654 else 655 { 656 DNBLog("%s: registers are not currently valid.", GetRegisterSetName(regSet)); 657 } 658 } 659} 660 661const DNBRegisterSetInfo * 662MachThread::GetRegisterSetInfo(nub_size_t *num_reg_sets ) const 663{ 664 *num_reg_sets = m_num_reg_sets; 665 return &m_reg_sets[0]; 666} 667 668bool 669MachThread::GetRegisterValue ( uint32_t set, uint32_t reg, DNBRegisterValue *value ) 670{ 671 return m_arch_ap->GetRegisterValue(set, reg, value); 672} 673 674bool 675MachThread::SetRegisterValue ( uint32_t set, uint32_t reg, const DNBRegisterValue *value ) 676{ 677 return m_arch_ap->SetRegisterValue(set, reg, value); 678} 679 680nub_size_t 681MachThread::GetRegisterContext (void *buf, nub_size_t buf_len) 682{ 683 return m_arch_ap->GetRegisterContext(buf, buf_len); 684} 685 686nub_size_t 687MachThread::SetRegisterContext (const void *buf, nub_size_t buf_len) 688{ 689 return m_arch_ap->SetRegisterContext(buf, buf_len); 690} 691 692uint32_t 693MachThread::EnableHardwareBreakpoint (const DNBBreakpoint *bp) 694{ 695 if (bp != NULL && bp->IsBreakpoint()) 696 return m_arch_ap->EnableHardwareBreakpoint(bp->Address(), bp->ByteSize()); 697 return INVALID_NUB_HW_INDEX; 698} 699 700uint32_t 701MachThread::EnableHardwareWatchpoint (const DNBBreakpoint *wp) 702{ 703 if (wp != NULL && wp->IsWatchpoint()) 704 return m_arch_ap->EnableHardwareWatchpoint(wp->Address(), wp->ByteSize(), wp->WatchpointRead(), wp->WatchpointWrite()); 705 return INVALID_NUB_HW_INDEX; 706} 707 708bool 709MachThread::DisableHardwareBreakpoint (const DNBBreakpoint *bp) 710{ 711 if (bp != NULL && bp->IsHardware()) 712 return m_arch_ap->DisableHardwareBreakpoint(bp->GetHardwareIndex()); 713 return false; 714} 715 716bool 717MachThread::DisableHardwareWatchpoint (const DNBBreakpoint *wp) 718{ 719 if (wp != NULL && wp->IsHardware()) 720 return m_arch_ap->DisableHardwareWatchpoint(wp->GetHardwareIndex()); 721 return false; 722} 723 724bool 725MachThread::GetIdentifierInfo () 726{ 727#ifdef THREAD_IDENTIFIER_INFO_COUNT 728 // Don't try to get the thread info once and cache it for the life of the thread. It changes over time, for instance 729 // if the thread name changes, then the thread_handle also changes... So you have to refetch it every time. 730 mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; 731 kern_return_t kret = ::thread_info (ThreadID(), THREAD_IDENTIFIER_INFO, (thread_info_t) &m_ident_info, &count); 732 return kret == KERN_SUCCESS; 733#endif 734 735 return false; 736} 737 738 739const char * 740MachThread::GetName () 741{ 742 if (GetIdentifierInfo ()) 743 { 744 int len = ::proc_pidinfo (m_process->ProcessID(), PROC_PIDTHREADINFO, m_ident_info.thread_handle, &m_proc_threadinfo, sizeof (m_proc_threadinfo)); 745 746 if (len && m_proc_threadinfo.pth_name[0]) 747 return m_proc_threadinfo.pth_name; 748 } 749 return NULL; 750} 751 752