[Lldb-commits] [lldb] a3bb9c2 - [cmake] Prevent implicitly passing `-no_exported_symbols` (#87846)
Author: Cyndy Ishida Date: 2024-04-07T10:22:34-07:00 New Revision: a3bb9c2b0e2f4eb005179ca7eef3313b6be5 URL: https://github.com/llvm/llvm-project/commit/a3bb9c2b0e2f4eb005179ca7eef3313b6be5 DIFF: https://github.com/llvm/llvm-project/commit/a3bb9c2b0e2f4eb005179ca7eef3313b6be5.diff LOG: [cmake] Prevent implicitly passing `-no_exported_symbols` (#87846) * It is possible to setup llvm-project builds without going through `llvm/CMakeList.txt` so the fatal error handling should be smarter. * Disable option on Apple style lldb-linux builds. Added: Modified: lldb/cmake/caches/Apple-lldb-Linux.cmake llvm/cmake/modules/AddLLVM.cmake Removed: diff --git a/lldb/cmake/caches/Apple-lldb-Linux.cmake b/lldb/cmake/caches/Apple-lldb-Linux.cmake index b2d3cf595fe18d..9258f01e2ec26a 100644 --- a/lldb/cmake/caches/Apple-lldb-Linux.cmake +++ b/lldb/cmake/caches/Apple-lldb-Linux.cmake @@ -1,4 +1,5 @@ include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake) +set(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES ON CACHE BOOL "") set(LLVM_DISTRIBUTION_COMPONENTS lldb diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 81398ddb5c92e3..693fd5669f63f9 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1038,9 +1038,15 @@ macro(add_llvm_executable name) add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} ) endif(LLVM_EXPORTED_SYMBOL_FILE) - if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) + if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND + NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES) +if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS) set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-no_exported_symbols") +else() + message(FATAL_ERROR +"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when linker does not support \"-no_exported_symbols\"") +endif() endif() if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [cmake] Prevent implicitly passing `-no_exported_symbols` (PR #87846)
https://github.com/cyndyishida closed https://github.com/llvm/llvm-project/pull/87846 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)
@@ -1089,6 +1089,116 @@ int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) { return fail_value; } +llvm::APSInt ValueObject::GetValueAsAPSInt() { + lldb::TargetSP target = GetTargetSP(); + uint64_t byte_size = 0; + if (auto temp = GetCompilerType().GetByteSize(target.get())) +byte_size = temp.value(); + + unsigned bit_width = static_cast(byte_size * CHAR_BIT); + bool success = true; + uint64_t fail_value = 0; + uint64_t ret_val = GetValueAsUnsigned(fail_value, &success); + uint64_t new_value = fail_value; + if (success) +new_value = ret_val; + bool is_signed = GetCompilerType().IsSigned(); + + return llvm::APSInt(llvm::APInt(bit_width, new_value, is_signed), !is_signed); cmtice wrote: The call to GetValueAsUnsigned included a boolean, 'success' which would be set correctly if the call fails, and which I was checking upon return. But, if I use Greg's code from above then I omit the call to GetValueAsUnsigned, anyway. And yes, I am converting these GetValueAs... functions to return an llvm::Expected<> value. https://github.com/llvm/llvm-project/pull/87197 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)
@@ -1089,6 +1089,116 @@ int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) { return fail_value; } +llvm::APSInt ValueObject::GetValueAsAPSInt() { + lldb::TargetSP target = GetTargetSP(); + uint64_t byte_size = 0; + if (auto temp = GetCompilerType().GetByteSize(target.get())) +byte_size = temp.value(); + + unsigned bit_width = static_cast(byte_size * CHAR_BIT); + bool success = true; + uint64_t fail_value = 0; + uint64_t ret_val = GetValueAsUnsigned(fail_value, &success); + uint64_t new_value = fail_value; + if (success) +new_value = ret_val; + bool is_signed = GetCompilerType().IsSigned(); + + return llvm::APSInt(llvm::APInt(bit_width, new_value, is_signed), !is_signed); +} + +llvm::APFloat ValueObject::GetValueAsFloat() { + lldb::BasicType basic_type = + GetCompilerType().GetCanonicalType().GetBasicTypeEnumeration(); + lldb::DataExtractorSP data_sp(new DataExtractor()); + Status error; + + switch (basic_type) { + case lldb::eBasicTypeFloat: { +float v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read float data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(float)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + case lldb::eBasicTypeDouble: +// No way to get more precision at the moment. + case lldb::eBasicTypeLongDouble: { +double v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read long double data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(double)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + default: +return llvm::APFloat(NAN); cmtice wrote: I think it was coming from a stdlib definition; but I'm updating the code to set an error message here instead. https://github.com/llvm/llvm-project/pull/87197 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)
@@ -1089,6 +1089,116 @@ int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) { return fail_value; } +llvm::APSInt ValueObject::GetValueAsAPSInt() { + lldb::TargetSP target = GetTargetSP(); + uint64_t byte_size = 0; + if (auto temp = GetCompilerType().GetByteSize(target.get())) +byte_size = temp.value(); + + unsigned bit_width = static_cast(byte_size * CHAR_BIT); + bool success = true; + uint64_t fail_value = 0; + uint64_t ret_val = GetValueAsUnsigned(fail_value, &success); + uint64_t new_value = fail_value; + if (success) +new_value = ret_val; + bool is_signed = GetCompilerType().IsSigned(); + + return llvm::APSInt(llvm::APInt(bit_width, new_value, is_signed), !is_signed); +} + +llvm::APFloat ValueObject::GetValueAsFloat() { + lldb::BasicType basic_type = + GetCompilerType().GetCanonicalType().GetBasicTypeEnumeration(); + lldb::DataExtractorSP data_sp(new DataExtractor()); + Status error; + + switch (basic_type) { + case lldb::eBasicTypeFloat: { +float v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read float data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(float)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + case lldb::eBasicTypeDouble: +// No way to get more precision at the moment. + case lldb::eBasicTypeLongDouble: { +double v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read long double data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(double)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + default: +return llvm::APFloat(NAN); + } +} + +bool ValueObject::GetValueAsBool() { + CompilerType val_type = GetCompilerType(); + if (val_type.IsInteger() || val_type.IsUnscopedEnumerationType() || + val_type.IsPointerType()) { +return GetValueAsAPSInt().getBoolValue(); + } + if (val_type.IsFloat()) { +return GetValueAsFloat().isNonZero(); + } + if (val_type.IsArrayType()) { +lldb::ValueObjectSP new_val = +ValueObject::ValueObject::CreateValueObjectFromAddress( +GetName().GetStringRef(), GetAddressOf(), GetExecutionContextRef(), +val_type); +return new_val->GetValueAsUnsigned(0) != 0; + } cmtice wrote: Hm...What I was trying to do (and I can see I didn't do it well here) is to check to see if the array had a real value(pointer address) or not. I'm updating the code to be cleaner and more clear. https://github.com/llvm/llvm-project/pull/87197 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)
@@ -1089,6 +1089,116 @@ int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) { return fail_value; } +llvm::APSInt ValueObject::GetValueAsAPSInt() { + lldb::TargetSP target = GetTargetSP(); + uint64_t byte_size = 0; + if (auto temp = GetCompilerType().GetByteSize(target.get())) +byte_size = temp.value(); + + unsigned bit_width = static_cast(byte_size * CHAR_BIT); + bool success = true; + uint64_t fail_value = 0; + uint64_t ret_val = GetValueAsUnsigned(fail_value, &success); + uint64_t new_value = fail_value; + if (success) +new_value = ret_val; + bool is_signed = GetCompilerType().IsSigned(); + + return llvm::APSInt(llvm::APInt(bit_width, new_value, is_signed), !is_signed); +} + +llvm::APFloat ValueObject::GetValueAsFloat() { + lldb::BasicType basic_type = + GetCompilerType().GetCanonicalType().GetBasicTypeEnumeration(); + lldb::DataExtractorSP data_sp(new DataExtractor()); + Status error; + + switch (basic_type) { + case lldb::eBasicTypeFloat: { +float v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read float data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(float)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + case lldb::eBasicTypeDouble: +// No way to get more precision at the moment. + case lldb::eBasicTypeLongDouble: { +double v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read long double data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(double)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + default: +return llvm::APFloat(NAN); + } +} + +bool ValueObject::GetValueAsBool() { + CompilerType val_type = GetCompilerType(); + if (val_type.IsInteger() || val_type.IsUnscopedEnumerationType() || + val_type.IsPointerType()) { +return GetValueAsAPSInt().getBoolValue(); + } + if (val_type.IsFloat()) { +return GetValueAsFloat().isNonZero(); + } + if (val_type.IsArrayType()) { +lldb::ValueObjectSP new_val = +ValueObject::ValueObject::CreateValueObjectFromAddress( +GetName().GetStringRef(), GetAddressOf(), GetExecutionContextRef(), +val_type); +return new_val->GetValueAsUnsigned(0) != 0; + } + return false; +} + +void ValueObject::UpdateIntegerValue(const llvm::APInt &value) { cmtice wrote: The intent is to only call this function on ValueObjects that are intermediate objects in the new parser/evaluator, not ValueObjects that are associated with program variables. I'll add a check for that while I'm updating the other asserts & error checks. So no, this function should not update values in memory, heap or register, only in the ValueObject itself. https://github.com/llvm/llvm-project/pull/87197 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)
@@ -1089,6 +1089,116 @@ int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) { return fail_value; } +llvm::APSInt ValueObject::GetValueAsAPSInt() { + lldb::TargetSP target = GetTargetSP(); + uint64_t byte_size = 0; + if (auto temp = GetCompilerType().GetByteSize(target.get())) +byte_size = temp.value(); + + unsigned bit_width = static_cast(byte_size * CHAR_BIT); + bool success = true; + uint64_t fail_value = 0; + uint64_t ret_val = GetValueAsUnsigned(fail_value, &success); + uint64_t new_value = fail_value; + if (success) +new_value = ret_val; + bool is_signed = GetCompilerType().IsSigned(); + + return llvm::APSInt(llvm::APInt(bit_width, new_value, is_signed), !is_signed); +} + +llvm::APFloat ValueObject::GetValueAsFloat() { + lldb::BasicType basic_type = + GetCompilerType().GetCanonicalType().GetBasicTypeEnumeration(); + lldb::DataExtractorSP data_sp(new DataExtractor()); + Status error; + + switch (basic_type) { + case lldb::eBasicTypeFloat: { +float v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read float data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(float)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + case lldb::eBasicTypeDouble: +// No way to get more precision at the moment. + case lldb::eBasicTypeLongDouble: { +double v = 0; +GetData(*data_sp, error); +assert(error.Success() && "Unable to read long double data from value"); + +lldb::offset_t offset = 0; +uint32_t old_offset = offset; +void *ok = nullptr; +ok = data_sp->GetU8(&offset, (void *)&v, sizeof(double)); +assert(offset != old_offset && ok != nullptr && "unable to read data"); + +return llvm::APFloat(v); + } + default: +return llvm::APFloat(NAN); + } +} + +bool ValueObject::GetValueAsBool() { + CompilerType val_type = GetCompilerType(); + if (val_type.IsInteger() || val_type.IsUnscopedEnumerationType() || + val_type.IsPointerType()) { +return GetValueAsAPSInt().getBoolValue(); + } + if (val_type.IsFloat()) { +return GetValueAsFloat().isNonZero(); + } + if (val_type.IsArrayType()) { +lldb::ValueObjectSP new_val = +ValueObject::ValueObject::CreateValueObjectFromAddress( +GetName().GetStringRef(), GetAddressOf(), GetExecutionContextRef(), +val_type); +return new_val->GetValueAsUnsigned(0) != 0; + } + return false; +} + +void ValueObject::UpdateIntegerValue(const llvm::APInt &value) { + lldb::TargetSP target = GetTargetSP(); + uint64_t byte_size = 0; + if (auto temp = GetCompilerType().GetByteSize(target.get())) +byte_size = temp.value(); + + assert(value.getBitWidth() == byte_size * CHAR_BIT && + "illegal argument: new value should be of the same size"); + + lldb::DataExtractorSP data_sp; + Status error; + data_sp->SetData(value.getRawData(), byte_size, + target->GetArchitecture().GetByteOrder()); cmtice wrote: Just for the record: This call is not crashing for me; I am calling this code in my light-weight parser/evaluator, and it seems to work just fine. I am ok with changing this code, if you really think it should be changed, but I'd appreciate suggestions on how to make this work "properly" -- I've been looking through ValueObject.cpp & ValueObject.h and not seeing much that looks helpful to me. This does seem to be the way SBValue::SetData works (which was the original basis for this function...) https://github.com/llvm/llvm-project/pull/87197 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits