aboutsummaryrefslogtreecommitdiffstats
path: root/source/Plugins/Process/POSIX
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
commitead246455adf1a215ec2715dad6533073a6beb4e (patch)
treef3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/Plugins/Process/POSIX
parentfdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff)
downloadsrc-vendor/lldb.tar.gz
src-vendor/lldb.zip
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes: svn path=/vendor/lldb/dist/; revision=353952 svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'source/Plugins/Process/POSIX')
-rw-r--r--source/Plugins/Process/POSIX/CrashReason.cpp7
-rw-r--r--source/Plugins/Process/POSIX/NativeProcessELF.cpp72
-rw-r--r--source/Plugins/Process/POSIX/NativeProcessELF.h7
-rw-r--r--source/Plugins/Process/POSIX/ProcessMessage.cpp7
4 files changed, 77 insertions, 16 deletions
diff --git a/source/Plugins/Process/POSIX/CrashReason.cpp b/source/Plugins/Process/POSIX/CrashReason.cpp
index 70c2687e3b8c..9678e48436e7 100644
--- a/source/Plugins/Process/POSIX/CrashReason.cpp
+++ b/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -229,11 +229,6 @@ std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
}
const char *CrashReasonAsString(CrashReason reason) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
- // Just return the code in ascii for integration builds.
- chcar str[8];
- sprintf(str, "%d", reason);
-#else
const char *str = nullptr;
switch (reason) {
@@ -315,8 +310,6 @@ const char *CrashReasonAsString(CrashReason reason) {
str = "eFloatSubscriptRange";
break;
}
-#endif
-
return str;
}
diff --git a/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/source/Plugins/Process/POSIX/NativeProcessELF.cpp
index 559b16c8fd69..058dc5ae2338 100644
--- a/source/Plugins/Process/POSIX/NativeProcessELF.cpp
+++ b/source/Plugins/Process/POSIX/NativeProcessELF.cpp
@@ -21,7 +21,7 @@ NativeProcessELF::GetAuxValue(enum AuxVector::EntryType type) {
DataExtractor auxv_data(buffer_or_error.get()->getBufferStart(),
buffer_or_error.get()->getBufferSize(),
GetByteOrder(), GetAddressByteSize());
- m_aux_vector = llvm::make_unique<AuxVector>(auxv_data);
+ m_aux_vector = std::make_unique<AuxVector>(auxv_data);
}
return m_aux_vector->GetAuxValue(type);
@@ -107,4 +107,72 @@ lldb::addr_t NativeProcessELF::GetELFImageInfoAddress() {
return LLDB_INVALID_ADDRESS;
}
-} // namespace lldb_private \ No newline at end of file
+template <typename T>
+llvm::Expected<SVR4LibraryInfo>
+NativeProcessELF::ReadSVR4LibraryInfo(lldb::addr_t link_map_addr) {
+ ELFLinkMap<T> link_map;
+ size_t bytes_read;
+ auto error =
+ ReadMemory(link_map_addr, &link_map, sizeof(link_map), bytes_read);
+ if (!error.Success())
+ return error.ToError();
+
+ char name_buffer[PATH_MAX];
+ llvm::Expected<llvm::StringRef> string_or_error = ReadCStringFromMemory(
+ link_map.l_name, &name_buffer[0], sizeof(name_buffer), bytes_read);
+ if (!string_or_error)
+ return string_or_error.takeError();
+
+ SVR4LibraryInfo info;
+ info.name = string_or_error->str();
+ info.link_map = link_map_addr;
+ info.base_addr = link_map.l_addr;
+ info.ld_addr = link_map.l_ld;
+ info.next = link_map.l_next;
+
+ return info;
+}
+
+llvm::Expected<std::vector<SVR4LibraryInfo>>
+NativeProcessELF::GetLoadedSVR4Libraries() {
+ // Address of DT_DEBUG.d_ptr which points to r_debug
+ lldb::addr_t info_address = GetSharedLibraryInfoAddress();
+ if (info_address == LLDB_INVALID_ADDRESS)
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Invalid shared library info address");
+ // Address of r_debug
+ lldb::addr_t address = 0;
+ size_t bytes_read;
+ auto status =
+ ReadMemory(info_address, &address, GetAddressByteSize(), bytes_read);
+ if (!status.Success())
+ return status.ToError();
+ if (address == 0)
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Invalid r_debug address");
+ // Read r_debug.r_map
+ lldb::addr_t link_map = 0;
+ status = ReadMemory(address + GetAddressByteSize(), &link_map,
+ GetAddressByteSize(), bytes_read);
+ if (!status.Success())
+ return status.ToError();
+ if (address == 0)
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Invalid link_map address");
+
+ std::vector<SVR4LibraryInfo> library_list;
+ while (link_map) {
+ llvm::Expected<SVR4LibraryInfo> info =
+ GetAddressByteSize() == 8 ? ReadSVR4LibraryInfo<uint64_t>(link_map)
+ : ReadSVR4LibraryInfo<uint32_t>(link_map);
+ if (!info)
+ return info.takeError();
+ if (!info->name.empty() && info->base_addr != 0)
+ library_list.push_back(*info);
+ link_map = info->next;
+ }
+
+ return library_list;
+}
+
+} // namespace lldb_private
diff --git a/source/Plugins/Process/POSIX/NativeProcessELF.h b/source/Plugins/Process/POSIX/NativeProcessELF.h
index 84dc8d08a340..4fb513baebf0 100644
--- a/source/Plugins/Process/POSIX/NativeProcessELF.h
+++ b/source/Plugins/Process/POSIX/NativeProcessELF.h
@@ -37,6 +37,13 @@ protected:
template <typename ELF_EHDR, typename ELF_PHDR, typename ELF_DYN>
lldb::addr_t GetELFImageInfoAddress();
+ llvm::Expected<std::vector<SVR4LibraryInfo>>
+ GetLoadedSVR4Libraries() override;
+
+ template <typename T>
+ llvm::Expected<SVR4LibraryInfo>
+ ReadSVR4LibraryInfo(lldb::addr_t link_map_addr);
+
std::unique_ptr<AuxVector> m_aux_vector;
llvm::Optional<lldb::addr_t> m_shared_library_info_addr;
};
diff --git a/source/Plugins/Process/POSIX/ProcessMessage.cpp b/source/Plugins/Process/POSIX/ProcessMessage.cpp
index aa8449131a68..66286dd3d9e3 100644
--- a/source/Plugins/Process/POSIX/ProcessMessage.cpp
+++ b/source/Plugins/Process/POSIX/ProcessMessage.cpp
@@ -15,11 +15,6 @@ const char *ProcessMessage::PrintCrashReason() const {
}
const char *ProcessMessage::PrintKind(Kind kind) {
-#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION
- // Just return the code in ascii for integration builds.
- chcar str[8];
- sprintf(str, "%d", reason);
-#else
const char *str = nullptr;
switch (kind) {
@@ -60,8 +55,6 @@ const char *ProcessMessage::PrintKind(Kind kind) {
str = "eExecMessage";
break;
}
-#endif
-
return str;
}