@@ -181,14 +181,14 @@ void EvaluateRequestHandler::operator()(
181181 expression = dap.last_nonempty_var_expression ;
182182 else
183183 dap.last_nonempty_var_expression = expression;
184- } else {
185- // If this isn't a REPL context, trim leading pointer/reference characters
184+ } else if (context == " hover " ) {
185+ // If we're in the hover context trim leading pointer/reference characters
186186 // to ensure we return the actual value of the expression.
187187 // This can come up if you hover over a pointer or reference declaration
188188 // like 'MyType *foo;' or `void fn(std::string &arg)`, which results in
189- // the hover request sending '*foo' or `&arg`. When we're not in the REPL,
190- // we should trim these characters to get to the actual variable, which
191- // should have the proper type encoded by the compiler.
189+ // the hover request sending '*foo' or `&arg`. Trim these characters to
190+ // get to the actual variable, which should have the proper type encoded
191+ // by the compiler.
192192 expression = llvm::StringRef (expression).ltrim (" *&" ).str ();
193193 }
194194
@@ -205,7 +205,10 @@ void EvaluateRequestHandler::operator()(
205205 if (value.GetError ().Success () && context == " repl" )
206206 value = value.Persist ();
207207
208- if (value.GetError ().Fail () && context != " hover" )
208+ // Only the repl should evaluate expressions, which can mutate application
209+ // state. Other contexts are used for observing debuggee state only, not
210+ // mutating state.
211+ if (value.GetError ().Fail () && context == " repl" )
209212 value = frame.EvaluateExpression (expression.data ());
210213
211214 if (value.GetError ().Fail ()) {
0 commit comments