This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] Don't lose language determined from the "main" name (fix gdb.ada/minsyms.exp)


On 11/21/2017 04:42 PM, Pedro Alves wrote:
> On 11/21/2017 04:23 PM, Sergio Durigan Junior wrote:

>> Since this is guaranteed to be an stap probe, WDYT about moving this
>> scoped_restore_current_language to
>> stap-probe.c:stap_evaluate_probe_argument?  This way we won't be bit by
>> this problem in other parts that also evaluate arguments of probes.
>>
>> Arguably, this should be set for every probe type IMHO, but it's fine if
>> we just do it for stap probes for now.
> 
> That sounds like a good idea.  But we could do it in 
> evaluate_probe_argument then, which handles all probe types?
> 
> [In your probe C++ification, that translates to evaluate_probe_argument
> becoming a  non-virtual method of probe, which then calls into a
> protected virtual method that is overridden by the actual probe
> implementation (see e.g., the do_xxx methods of class ui_out).]

Hmm, maybe what we need instead is to make expression evaluation
never set the selected frame (and thus language as side effect)
if it wasn't selected/set already.  Like below.  This fixes
the testcase too.  I'll run the full testsuite now.  WDYT?

>From c5fd954787e058abcc72aca329414b0edb40ac1b Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 21 Nov 2017 16:50:32 +0000
Subject: [PATCH] alternative

---
 gdb/eval.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index 14a3e05..086ac59 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1319,7 +1319,6 @@ evaluate_subexp_standard (struct type *expect_type,
 
       {
 	struct symbol *sym = exp->elts[pc + 1].symbol;
-	struct frame_info *frame;
 
 	if (noside == EVAL_AVOID_SIDE_EFFECTS)
 	  return value_zero (SYMBOL_TYPE (sym), not_lval);
@@ -1329,7 +1328,9 @@ evaluate_subexp_standard (struct type *expect_type,
 	  error (_("Symbol \"%s\" does not have any specific entry value"),
 		 SYMBOL_PRINT_NAME (sym));
 
-	frame = get_selected_frame (NULL);
+	frame_info *frame = get_selected_frame_if_set ();
+	if (frame == NULL)
+	  frame = get_current_frame ();
 	return SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry (sym, frame);
       }
 
@@ -1381,7 +1382,12 @@ evaluate_subexp_standard (struct type *expect_type,
 			+ gdbarch_num_pseudo_regs (exp->gdbarch))
 	  val = value_zero (register_type (exp->gdbarch, regno), not_lval);
 	else
-	  val = value_of_register (regno, get_selected_frame (NULL));
+	  {
+	    frame_info *frame = get_selected_frame_if_set ();
+	    if (frame == NULL)
+	      frame = get_current_frame ();
+	    val = value_of_register (regno, frame);
+	  }
 	if (val == NULL)
 	  error (_("Value of register %s not available."), name);
 	else
-- 
2.5.5



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]