[Lldb-commits] [PATCH] D89842: [lldb/DWARF] Add support DW_OP_implicit_value

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 20 19:19:42 PDT 2020


mib created this revision.
mib added reviewers: labath, JDevlieghere, aprantl.
mib added projects: LLDB, debug-info.
Herald added a subscriber: lldb-commits.
mib requested review of this revision.

This patch completes https://reviews.llvm.org/D83560. Now that the
compiler can emit `DW_OP_implicit_value` into DWARF expressions, lldb
needed to learn to read these opcodes for variable inspection and
expression evaluation.

This implicit location descriptor specifies an immediate value with two
operands: a length (ULEB128) followed by a block representing the value
in the target memory representation.

Note that, at the moment, this feature is only supported when emitting
DWARFv5 debugging information. However, since dsymutil doesn't support
that version yet, the test is disabled on macOS and only ran in Linux.

rdar://67406091

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89842

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/test/Shell/SymbolFile/DWARF/Inputs/implicit_value.c


Index: lldb/test/Shell/SymbolFile/DWARF/Inputs/implicit_value.c
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/Inputs/implicit_value.c
@@ -0,0 +1,6 @@
+int main() {
+  double d = 3.14;
+  printf("break here");
+  d *= d;
+  return 0;
+}
Index: lldb/source/Expression/DWARFExpression.cpp
===================================================================
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -846,6 +846,26 @@
   return true;
 }
 
+static bool Evaluate_DW_OP_implicit_value(std::vector<Value> &stack,
+                                          ExecutionContext *exe_ctx,
+                                          RegisterContext *reg_ctx,
+                                          const DataExtractor &opcodes,
+                                          lldb::offset_t &opcode_offset,
+                                          Status *error_ptr, Log *log) {
+
+  const uint32_t len = opcodes.GetULEB128(&opcode_offset);
+  const void *data = opcodes.GetData(&opcode_offset, len);
+
+  if (!data) {
+    LLDB_LOG(log, "Evaluate_DW_OP_implicit_value: could not be read data");
+    return false;
+  }
+
+  Value result(data, len);
+  stack.push_back(result);
+  return true;
+}
+
 bool DWARFExpression::Evaluate(ExecutionContextScope *exe_scope,
                                lldb::addr_t loclist_base_load_addr,
                                const Value *initial_value_ptr,
@@ -2248,6 +2268,23 @@
       }
       break;
 
+    // OPCODE: DW_OP_implicit_value
+    // OPERANDS: 2
+    //      ULEB128  size of the value block in bytes
+    //      uint8_t* block bytes encoding value in target's memory
+    //      representation
+    // DESCRIPTION: Value is immediately stored in block in the debug info with
+    // the memory representation of the target.
+    case DW_OP_implicit_value: {
+      if (!Evaluate_DW_OP_implicit_value(stack, exe_ctx, reg_ctx, opcodes,
+                                         offset, error_ptr, log)) {
+        LLDB_ERRORF(error_ptr, "Could not evaluate %s.",
+                    DW_OP_value_to_name(op));
+        return false;
+      }
+      break;
+    }
+
     // OPCODE: DW_OP_push_object_address
     // OPERANDS: none
     // DESCRIPTION: Pushes the address of the object currently being


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89842.299538.patch
Type: text/x-patch
Size: 2372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201021/5c1e2323/attachment-0001.bin>


More information about the lldb-commits mailing list