Report original thread ID for FreeBSD core files
On FreeBSD the tid is (somewhat unintuitively) found in the pr_pid field of the NT_PRSTATUS note. Collect it when parsing the note and store it in the thread data. For Linux I've left the original behaviour of using sequential TIDs (0, 1, 2...) as I don't yet have code to obtain it. Differential Revision: http://reviews.llvm.org/D11652 llvm-svn: 243748
This commit is contained in:
		
							parent
							
								
									b4fbb173f0
								
							
						
					
					
						commit
						343ad62374
					
				| 
						 | 
					@ -258,7 +258,7 @@ ProcessElfCore::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_t
 | 
				
			||||||
    for (lldb::tid_t tid = 0; tid < num_threads; ++tid)
 | 
					    for (lldb::tid_t tid = 0; tid < num_threads; ++tid)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        const ThreadData &td = m_thread_data[tid];
 | 
					        const ThreadData &td = m_thread_data[tid];
 | 
				
			||||||
        lldb::ThreadSP thread_sp(new ThreadElfCore (*this, tid, td));
 | 
					        lldb::ThreadSP thread_sp(new ThreadElfCore (*this, td));
 | 
				
			||||||
        new_thread_list.AddThread (thread_sp);
 | 
					        new_thread_list.AddThread (thread_sp);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return new_thread_list.GetSize(false) > 0;
 | 
					    return new_thread_list.GetSize(false) > 0;
 | 
				
			||||||
| 
						 | 
					@ -429,7 +429,7 @@ ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
 | 
				
			||||||
        offset += 16;
 | 
					        offset += 16;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    thread_data.signo = data.GetU32(&offset); // pr_cursig
 | 
					    thread_data.signo = data.GetU32(&offset); // pr_cursig
 | 
				
			||||||
    offset += 4;        // pr_pid
 | 
					    thread_data.tid = data.GetU32(&offset); // pr_pid
 | 
				
			||||||
    if (lp64)
 | 
					    if (lp64)
 | 
				
			||||||
        offset += 4;
 | 
					        offset += 4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -543,6 +543,8 @@ ProcessElfCore::ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *
 | 
				
			||||||
                    header_size = ELFLinuxPrStatus::GetSize(arch);
 | 
					                    header_size = ELFLinuxPrStatus::GetSize(arch);
 | 
				
			||||||
                    len = note_data.GetByteSize() - header_size;
 | 
					                    len = note_data.GetByteSize() - header_size;
 | 
				
			||||||
                    thread_data->gpregset = DataExtractor(note_data, header_size, len);
 | 
					                    thread_data->gpregset = DataExtractor(note_data, header_size, len);
 | 
				
			||||||
 | 
					                    // FIXME: Obtain actual tid on Linux
 | 
				
			||||||
 | 
					                    thread_data->tid = m_thread_data.size();
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                case NT_FPREGSET:
 | 
					                case NT_FPREGSET:
 | 
				
			||||||
                    thread_data->fpregset = note_data;
 | 
					                    thread_data->fpregset = note_data;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,9 +37,8 @@ using namespace lldb_private;
 | 
				
			||||||
//----------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------
 | 
				
			||||||
// Construct a Thread object with given data
 | 
					// Construct a Thread object with given data
 | 
				
			||||||
//----------------------------------------------------------------------
 | 
					//----------------------------------------------------------------------
 | 
				
			||||||
ThreadElfCore::ThreadElfCore (Process &process, tid_t tid,
 | 
					ThreadElfCore::ThreadElfCore (Process &process, const ThreadData &td) :
 | 
				
			||||||
                              const ThreadData &td) :
 | 
					    Thread(process, td.tid),
 | 
				
			||||||
    Thread(process, tid),
 | 
					 | 
				
			||||||
    m_thread_name(td.name),
 | 
					    m_thread_name(td.name),
 | 
				
			||||||
    m_thread_reg_ctx_sp (),
 | 
					    m_thread_reg_ctx_sp (),
 | 
				
			||||||
    m_signo(td.signo),
 | 
					    m_signo(td.signo),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,6 +112,7 @@ struct ThreadData
 | 
				
			||||||
    lldb_private::DataExtractor gpregset;
 | 
					    lldb_private::DataExtractor gpregset;
 | 
				
			||||||
    lldb_private::DataExtractor fpregset;
 | 
					    lldb_private::DataExtractor fpregset;
 | 
				
			||||||
    lldb_private::DataExtractor vregset;
 | 
					    lldb_private::DataExtractor vregset;
 | 
				
			||||||
 | 
					    lldb::tid_t tid;
 | 
				
			||||||
    int signo;
 | 
					    int signo;
 | 
				
			||||||
    std::string name;
 | 
					    std::string name;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -119,8 +120,7 @@ struct ThreadData
 | 
				
			||||||
class ThreadElfCore : public lldb_private::Thread
 | 
					class ThreadElfCore : public lldb_private::Thread
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    ThreadElfCore (lldb_private::Process &process, lldb::tid_t tid,
 | 
					    ThreadElfCore (lldb_private::Process &process, const ThreadData &td);
 | 
				
			||||||
                   const ThreadData &td);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual
 | 
					    virtual
 | 
				
			||||||
    ~ThreadElfCore ();
 | 
					    ~ThreadElfCore ();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue