[Lldb-commits] [PATCH 2/2] elf-core: Parse FreeBSD thread names
Ed Maste
emaste at freebsd.org
Fri Jul 19 13:41:32 PDT 2013
---
source/Plugins/Process/elf-core/ProcessElfCore.cpp | 13 ++++++++++++-
source/Plugins/Process/elf-core/ProcessElfCore.h | 19 ++++++++++---------
source/Plugins/Process/elf-core/ThreadElfCore.cpp | 9 +++++++--
source/Plugins/Process/elf-core/ThreadElfCore.h | 3 ++-
4 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 20d47a6..92614bf 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -246,7 +246,8 @@ ProcessElfCore::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_t
{
const ThreadData &td = m_thread_data[tid];
lldb::ThreadSP thread_sp(new ThreadElfCore (*this, tid, td.prstatus,
- td.prpsinfo, td.fpregset));
+ td.prpsinfo, td.fpregset,
+ td.name));
new_thread_list.AddThread (thread_sp);
}
return new_thread_list.GetSize(false) > 0;
@@ -425,6 +426,13 @@ struct ELFNote
}
};
+static void
+ParseFreeBSDThrMisc(ThreadData *thread_data, DataExtractor &data)
+{
+ lldb::offset_t offset = 0;
+ thread_data->name = data.GetCStr(&offset, 20);
+}
+
/// Parse Thread context from PT_NOTE segment and store it in the thread list
/// Notes:
/// 1) A PT_NOTE segment is composed of one or more NOTE entries.
@@ -493,6 +501,9 @@ ProcessElfCore::ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *
have_prpsinfo = true;
thread_data->prpsinfo = note_data;
break;
+ case NT_FREEBSD_THRMISC:
+ ParseFreeBSDThrMisc(thread_data, note_data);
+ break;
default:
break;
}
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.h b/source/Plugins/Process/elf-core/ProcessElfCore.h
index 34ac05c..0577c7a 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -28,6 +28,16 @@
#include "Plugins/ObjectFile/ELF/ELFHeader.h"
+// In ELF core file thread context is described mainly by 3 Note entries
+// The following structure holds pointers to those note entries.
+struct ThreadData
+{
+ lldb_private::DataExtractor prstatus;
+ lldb_private::DataExtractor fpregset;
+ lldb_private::DataExtractor prpsinfo;
+ std::string name;
+};
+
class ProcessElfCore : public lldb_private::Process
{
public:
@@ -135,15 +145,6 @@ private:
typedef lldb_private::Range<lldb::addr_t, lldb::addr_t> FileRange;
typedef lldb_private::RangeDataArray<lldb::addr_t, lldb::addr_t, FileRange, 1> VMRangeToFileOffset;
- // In ELF core file thread context is described mainly by 3 Note entries
- // The following structure holds pointers to those note entries.
- struct ThreadData
- {
- lldb_private::DataExtractor prstatus;
- lldb_private::DataExtractor fpregset;
- lldb_private::DataExtractor prpsinfo;
- };
-
lldb::ModuleSP m_core_module_sp;
lldb_private::FileSpec m_core_file;
std::string m_dyld_plugin_name;
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 6ac12fe..1a84cfa 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -26,7 +26,8 @@ using namespace lldb_private;
// Construct a Thread object with given PRSTATUS, PRPSINFO and FPREGSET
//----------------------------------------------------------------------
ThreadElfCore::ThreadElfCore (Process &process, tid_t tid, DataExtractor prstatus,
- DataExtractor prpsinfo, DataExtractor fpregset) :
+ DataExtractor prpsinfo, DataExtractor fpregset,
+ std::string name) :
Thread(process, tid),
m_thread_reg_ctx_sp ()
{
@@ -40,7 +41,11 @@ ThreadElfCore::ThreadElfCore (Process &process, tid_t tid, DataExtractor prstatu
m_prstatus_data = prstatus;
m_fpregset_data = fpregset;
- m_thread_name = std::string(m_prpsinfo.pr_fname);
+ if (!name.empty()) {
+ m_thread_name = name;
+ } else {
+ m_thread_name = std::string(m_prpsinfo.pr_fname);
+ }
}
ThreadElfCore::~ThreadElfCore ()
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.h b/source/Plugins/Process/elf-core/ThreadElfCore.h
index ad0f67a..f4bdfb9 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -131,7 +131,8 @@ public:
ThreadElfCore (lldb_private::Process &process, lldb::tid_t tid,
lldb_private::DataExtractor prstatus,
lldb_private::DataExtractor prpsinfo,
- lldb_private::DataExtractor fpregset);
+ lldb_private::DataExtractor fpregset,
+ std::string name);
virtual
~ThreadElfCore ();
--
1.7.11.5
More information about the lldb-commits
mailing list