[Lldb-commits] [lldb] r335263 - Fix an issue where DW_OP_deref might be dereferencing a file address. Convert the file address to a load address so this works.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 21 11:19:38 PDT 2018


Hi Greg,

Would you mind adding a test case for this?

Thanks,
Jonas

> On Jun 21, 2018, at 6:58 PM, Greg Clayton via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: gclayton
> Date: Thu Jun 21 10:58:06 2018
> New Revision: 335263
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=335263&view=rev
> Log:
> Fix an issue where DW_OP_deref might be dereferencing a file address. Convert the file address to a load address so this works.
> 
> https://bugs.llvm.org/show_bug.cgi?id=36871
> 
> 
> Modified:
>    lldb/trunk/source/Expression/DWARFExpression.cpp
> 
> Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=335263&r1=335262&r2=335263&view=diff
> ==============================================================================
> --- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
> +++ lldb/trunk/source/Expression/DWARFExpression.cpp Thu Jun 21 10:58:06 2018
> @@ -15,6 +15,7 @@
> // C++ Includes
> #include <vector>
> 
> +#include "lldb/Core/Module.h"
> #include "lldb/Core/RegisterValue.h"
> #include "lldb/Core/Scalar.h"
> #include "lldb/Core/Value.h"
> @@ -1452,6 +1453,33 @@ bool DWARFExpression::Evaluate(
>         stack.back().GetScalar() = ptr;
>         stack.back().ClearContext();
>       } break;
> +      case Value::eValueTypeFileAddress: {
> +        auto file_addr = stack.back().GetScalar().ULongLong(
> +            LLDB_INVALID_ADDRESS);
> +        if (!module_sp) {
> +          if (error_ptr)
> +            error_ptr->SetErrorStringWithFormat(
> +                "need module to resolve file address for DW_OP_deref");
> +          return false;
> +        }
> +        Address so_addr;
> +        if (!module_sp->ResolveFileAddress(file_addr, so_addr)) {
> +          if (error_ptr)
> +            error_ptr->SetErrorStringWithFormat(
> +                "failed to resolve file address in module");
> +          return false;
> +        }
> +        addr_t load_Addr = so_addr.GetLoadAddress(exe_ctx->GetTargetPtr());
> +        if (load_Addr == LLDB_INVALID_ADDRESS) {
> +          if (error_ptr)
> +            error_ptr->SetErrorStringWithFormat(
> +                "failed to resolve load address");
> +          return false;
> +        }
> +        stack.back().GetScalar() = load_Addr;
> +        stack.back().SetValueType(Value::eValueTypeLoadAddress);
> +        // Fall through to load address code below...
> +      } LLVM_FALLTHROUGH;
>       case Value::eValueTypeLoadAddress:
>         if (exe_ctx) {
>           if (process) {
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list