summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 18:45:14 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 18:45:14 +0000
commit38e660c46fb9f2b2a33b2f771dc8777d50ace53a (patch)
tree316b04d5f7db0352a4ebe6c9447ad3f5ff86af59
parent94994d372d014ce4c8758b9605d63fae651bd8aa (diff)
Notes
-rw-r--r--include/lldb/Host/openbsd/HostInfoOpenBSD.h3
-rw-r--r--source/Core/Value.cpp34
-rw-r--r--source/Host/openbsd/HostInfoOpenBSD.cpp11
3 files changed, 27 insertions, 21 deletions
diff --git a/include/lldb/Host/openbsd/HostInfoOpenBSD.h b/include/lldb/Host/openbsd/HostInfoOpenBSD.h
index 5a0388ffdd977..809a6f4461f51 100644
--- a/include/lldb/Host/openbsd/HostInfoOpenBSD.h
+++ b/include/lldb/Host/openbsd/HostInfoOpenBSD.h
@@ -12,12 +12,13 @@
#include "lldb/Host/posix/HostInfoPosix.h"
#include "lldb/Utility/FileSpec.h"
+#include "llvm/Support/VersionTuple.h"
namespace lldb_private {
class HostInfoOpenBSD : public HostInfoPosix {
public:
- static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static llvm::VersionTuple GetOSVersion();
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index 8e18458b90c20..98a39ea95315a 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -210,31 +210,35 @@ bool Value::ValueOf(ExecutionContext *exe_ctx) {
}
uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) {
+ uint64_t byte_size = 0;
+
switch (m_context_type) {
case eContextTypeRegisterInfo: // RegisterInfo *
- if (GetRegisterInfo()) {
- if (error_ptr)
- error_ptr->Clear();
- return GetRegisterInfo()->byte_size;
- }
+ if (GetRegisterInfo())
+ byte_size = GetRegisterInfo()->byte_size;
break;
case eContextTypeInvalid:
case eContextTypeLLDBType: // Type *
case eContextTypeVariable: // Variable *
{
- auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
- if (llvm::Optional<uint64_t> size = GetCompilerType().GetByteSize(scope)) {
- if (error_ptr)
- error_ptr->Clear();
- return *size;
- }
- break;
+ const CompilerType &ast_type = GetCompilerType();
+ if (ast_type.IsValid())
+ if (llvm::Optional<uint64_t> size = ast_type.GetByteSize(
+ exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
+ byte_size = *size;
+ } break;
}
+
+ if (error_ptr) {
+ if (byte_size == 0) {
+ if (error_ptr->Success())
+ error_ptr->SetErrorString("Unable to determine byte size.");
+ } else {
+ error_ptr->Clear();
+ }
}
- if (error_ptr && error_ptr->Success())
- error_ptr->SetErrorString("Unable to determine byte size.");
- return 0;
+ return byte_size;
}
const CompilerType &Value::GetCompilerType() {
diff --git a/source/Host/openbsd/HostInfoOpenBSD.cpp b/source/Host/openbsd/HostInfoOpenBSD.cpp
index 548958899322c..cf7acb79da00e 100644
--- a/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -17,16 +17,17 @@
using namespace lldb_private;
-bool HostInfoOpenBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
- uint32_t &update) {
+llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
struct utsname un;
::memset(&un, 0, sizeof(utsname));
if (uname(&un) < 0)
- return false;
+ return llvm::VersionTuple();
- int status = sscanf(un.release, "%u.%u", &major, &minor);
- return status == 2;
+ unsigned major, minor;
+ if (2 == sscanf(un.release, "%u.%u", &major, &minor))
+ return llvm::VersionTuple(major, minor);
+ return llvm::VersionTuple();
}
bool HostInfoOpenBSD::GetOSBuildString(std::string &s) {