================
@@ -511,22 +513,58 @@ ValueObjectSP
StackFrame::GetValueForVariableExpressionPath(
VariableSP &var_sp, Status &error) {
ExecutionContext exe_ctx;
CalculateExecutionContext(exe_ctx);
+
bool use_DIL = exe_ctx.GetTargetRef().GetUseDIL(&exe_ctx);
+
if (use_DIL)
return DILGetValueForVariableExpressionPath(var_expr, use_dynamic, options,
var_sp, error);
-
- return LegacyGetValueForVariableExpressionPath(var_expr, use_dynamic,
options,
- var_sp, error);
+ else
+ return LegacyGetValueForVariableExpressionPath(var_expr, use_dynamic,
+ options, var_sp, error);
}
ValueObjectSP StackFrame::DILGetValueForVariableExpressionPath(
llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
uint32_t options, lldb::VariableSP &var_sp, Status &error) {
- // This is a place-holder for the calls into the DIL parser and
- // evaluator. For now, just call the "real" frame variable implementation.
- return LegacyGetValueForVariableExpressionPath(var_expr, use_dynamic,
options,
- var_sp, error);
+ ValueObjectSP ret_val;
+ std::shared_ptr<std::string> source =
+ std::make_shared<std::string>(var_expr.data());
----------------
labath wrote:
To convert a StringRef to a string, you should use the `.str()` method.
`.data()` is more expensive (calls `strlen`) and can produce bad results or
even crashes because StringRefs don't need to be null-terminated.
*However*, a `shared_ptr<string>` is really unusual. What are you trying to
achieve here? I don't think you are/should be modifying the string, so are you
trying to avoid copies? If so, the usual way to deal with that is to std::move
the string to transfer ownership and use non-owning references (i.e. a
StringRef) everywhere else).
In this case, I think none of the DIL classes should outlive this function (if
that's not the case, I'd like to know why), so I think you should just use the
StringRef you got as an argument and avoid making any copies of at all.
https://github.com/llvm/llvm-project/pull/120971
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits