[Lldb-commits] [lldb] r362946 - [lldb] [Process/NetBSD] Fix error handling in register operations
Michal Gorny via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 10 08:03:50 PDT 2019
Author: mgorny
Date: Mon Jun 10 08:03:49 2019
New Revision: 362946
URL: http://llvm.org/viewvc/llvm-project?rev=362946&view=rev
Log:
[lldb] [Process/NetBSD] Fix error handling in register operations
Ensure that errors are passed through correctly when performing
register read/write operations. Currently, any ptrace() errors are
silently discarded and LLDB behaves as if operation was successful.
Differential Revision: https://reviews.llvm.org/D63054
Modified:
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp?rev=362946&r1=362945&r2=362946&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp Mon Jun 10 08:03:49 2019
@@ -210,37 +210,28 @@ int NativeRegisterContextNetBSD_x86_64::
return -1;
}
-int NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
+Status NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
switch (set) {
case GPRegSet:
- ReadGPR();
- return 0;
+ return ReadGPR();
case FPRegSet:
- ReadFPR();
- return 0;
+ return ReadFPR();
case DBRegSet:
- ReadDBR();
- return 0;
- default:
- break;
+ return ReadDBR();
}
- return -1;
+ llvm_unreachable("NativeRegisterContextNetBSD_x86_64::ReadRegisterSet");
}
-int NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
+
+Status NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
switch (set) {
case GPRegSet:
- WriteGPR();
- return 0;
+ return WriteGPR();
case FPRegSet:
- WriteFPR();
- return 0;
+ return WriteFPR();
case DBRegSet:
- WriteDBR();
- return 0;
- default:
- break;
+ return WriteDBR();
}
- return -1;
+ llvm_unreachable("NativeRegisterContextNetBSD_x86_64::WriteRegisterSet");
}
Status
@@ -272,13 +263,9 @@ NativeRegisterContextNetBSD_x86_64::Read
return error;
}
- if (ReadRegisterSet(set) != 0) {
- // This is likely an internal register for lldb use only and should not be
- // directly queried.
- error.SetErrorStringWithFormat(
- "reading register set for register \"%s\" failed", reg_info->name);
+ error = ReadRegisterSet(set);
+ if (error.Fail())
return error;
- }
switch (reg) {
case lldb_rax_x86_64:
@@ -468,13 +455,9 @@ Status NativeRegisterContextNetBSD_x86_6
return error;
}
- if (ReadRegisterSet(set) != 0) {
- // This is likely an internal register for lldb use only and should not be
- // directly queried.
- error.SetErrorStringWithFormat(
- "reading register set for register \"%s\" failed", reg_info->name);
+ error = ReadRegisterSet(set);
+ if (error.Fail())
return error;
- }
switch (reg) {
case lldb_rax_x86_64:
@@ -632,10 +615,7 @@ Status NativeRegisterContextNetBSD_x86_6
break;
}
- if (WriteRegisterSet(set) != 0)
- error.SetErrorStringWithFormat("failed to write register set");
-
- return error;
+ return WriteRegisterSet(set);
}
Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h?rev=362946&r1=362945&r2=362946&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h Mon Jun 10 08:03:49 2019
@@ -82,8 +82,8 @@ private:
int GetSetForNativeRegNum(int reg_num) const;
- int ReadRegisterSet(uint32_t set);
- int WriteRegisterSet(uint32_t set);
+ Status ReadRegisterSet(uint32_t set);
+ Status WriteRegisterSet(uint32_t set);
};
} // namespace process_netbsd
More information about the lldb-commits
mailing list