@@ -321,8 +321,6 @@ static char *c_name_of_child (struct varobj *parent, int index);
321321
322322static char * c_path_expr_of_child (struct varobj * child );
323323
324- static struct value * c_value_of_root (struct varobj * * var_handle );
325-
326324static struct value * c_value_of_child (struct varobj * parent , int index );
327325
328326static struct type * c_type_of_child (struct varobj * parent , int index );
@@ -342,8 +340,6 @@ static char *cplus_name_of_child (struct varobj *parent, int index);
342340
343341static char * cplus_path_expr_of_child (struct varobj * child );
344342
345- static struct value * cplus_value_of_root (struct varobj * * var_handle );
346-
347343static struct value * cplus_value_of_child (struct varobj * parent , int index );
348344
349345static struct type * cplus_type_of_child (struct varobj * parent , int index );
@@ -361,8 +357,6 @@ static char *java_name_of_child (struct varobj *parent, int index);
361357
362358static char * java_path_expr_of_child (struct varobj * child );
363359
364- static struct value * java_value_of_root (struct varobj * * var_handle );
365-
366360static struct value * java_value_of_child (struct varobj * parent , int index );
367361
368362static struct type * java_type_of_child (struct varobj * parent , int index );
@@ -380,8 +374,6 @@ static char *ada_name_of_child (struct varobj *parent, int index);
380374
381375static char * ada_path_expr_of_child (struct varobj * child );
382376
383- static struct value * ada_value_of_root (struct varobj * * var_handle );
384-
385377static struct value * ada_value_of_child (struct varobj * parent , int index );
386378
387379static struct type * ada_type_of_child (struct varobj * parent , int index );
@@ -411,9 +403,6 @@ struct language_specific
411403 obtain that has some parent. */
412404 char * (* path_expr_of_child ) (struct varobj * child );
413405
414- /* The ``struct value *'' of the root variable ROOT. */
415- struct value * (* value_of_root ) (struct varobj * * root_handle );
416-
417406 /* The ``struct value *'' of the INDEX'th child of PARENT. */
418407 struct value * (* value_of_child ) (struct varobj * parent , int index );
419408
@@ -458,7 +447,6 @@ static struct language_specific languages[vlang_end] = {
458447 c_name_of_variable ,
459448 c_name_of_child ,
460449 c_path_expr_of_child ,
461- c_value_of_root ,
462450 c_value_of_child ,
463451 c_type_of_child ,
464452 c_value_of_variable ,
@@ -471,7 +459,6 @@ static struct language_specific languages[vlang_end] = {
471459 cplus_name_of_variable ,
472460 cplus_name_of_child ,
473461 cplus_path_expr_of_child ,
474- cplus_value_of_root ,
475462 cplus_value_of_child ,
476463 cplus_type_of_child ,
477464 cplus_value_of_variable ,
@@ -484,7 +471,6 @@ static struct language_specific languages[vlang_end] = {
484471 java_name_of_variable ,
485472 java_name_of_child ,
486473 java_path_expr_of_child ,
487- java_value_of_root ,
488474 java_value_of_child ,
489475 java_type_of_child ,
490476 java_value_of_variable ,
@@ -496,7 +482,6 @@ static struct language_specific languages[vlang_end] = {
496482 ada_name_of_variable ,
497483 ada_name_of_child ,
498484 ada_path_expr_of_child ,
499- ada_value_of_root ,
500485 ada_value_of_child ,
501486 ada_type_of_child ,
502487 ada_value_of_variable ,
@@ -2710,6 +2695,86 @@ name_of_child (struct varobj *var, int index)
27102695 return (* var -> root -> lang -> name_of_child ) (var , index );
27112696}
27122697
2698+ /* If frame associated with VAR can be found, switch
2699+ to it and return 1. Otherwise, return 0. */
2700+
2701+ static int
2702+ check_scope (struct varobj * var )
2703+ {
2704+ struct frame_info * fi ;
2705+ int scope ;
2706+
2707+ fi = frame_find_by_id (var -> root -> frame );
2708+ scope = fi != NULL ;
2709+
2710+ if (fi )
2711+ {
2712+ CORE_ADDR pc = get_frame_pc (fi );
2713+
2714+ if (pc < BLOCK_START (var -> root -> valid_block ) ||
2715+ pc >= BLOCK_END (var -> root -> valid_block ))
2716+ scope = 0 ;
2717+ else
2718+ select_frame (fi );
2719+ }
2720+ return scope ;
2721+ }
2722+
2723+ /* Helper function to value_of_root. */
2724+
2725+ static struct value *
2726+ value_of_root_1 (struct varobj * * var_handle )
2727+ {
2728+ struct value * new_val = NULL ;
2729+ struct varobj * var = * var_handle ;
2730+ int within_scope = 0 ;
2731+ struct cleanup * back_to ;
2732+
2733+ /* Only root variables can be updated... */
2734+ if (!is_root_p (var ))
2735+ /* Not a root var. */
2736+ return NULL ;
2737+
2738+ back_to = make_cleanup_restore_current_thread ();
2739+
2740+ /* Determine whether the variable is still around. */
2741+ if (var -> root -> valid_block == NULL || var -> root -> floating )
2742+ within_scope = 1 ;
2743+ else if (var -> root -> thread_id == 0 )
2744+ {
2745+ /* The program was single-threaded when the variable object was
2746+ created. Technically, it's possible that the program became
2747+ multi-threaded since then, but we don't support such
2748+ scenario yet. */
2749+ within_scope = check_scope (var );
2750+ }
2751+ else
2752+ {
2753+ ptid_t ptid = thread_id_to_pid (var -> root -> thread_id );
2754+ if (in_thread_list (ptid ))
2755+ {
2756+ switch_to_thread (ptid );
2757+ within_scope = check_scope (var );
2758+ }
2759+ }
2760+
2761+ if (within_scope )
2762+ {
2763+ volatile struct gdb_exception except ;
2764+
2765+ /* We need to catch errors here, because if evaluate
2766+ expression fails we want to just return NULL. */
2767+ TRY_CATCH (except , RETURN_MASK_ERROR )
2768+ {
2769+ new_val = evaluate_expression (var -> root -> exp );
2770+ }
2771+ }
2772+
2773+ do_cleanups (back_to );
2774+
2775+ return new_val ;
2776+ }
2777+
27132778/* What is the ``struct value *'' of the root variable VAR?
27142779 For floating variable object, evaluation can get us a value
27152780 of different type from what is stored in varobj already. In
@@ -2787,7 +2852,7 @@ value_of_root (struct varobj **var_handle, int *type_changed)
27872852 {
27882853 struct value * value ;
27892854
2790- value = ( * var -> root -> lang -> value_of_root ) (var_handle );
2855+ value = value_of_root_1 (var_handle );
27912856 if (var -> value == NULL || value == NULL )
27922857 {
27932858 /* For root varobj-s, a NULL value indicates a scoping issue.
@@ -3382,83 +3447,6 @@ c_path_expr_of_child (struct varobj *child)
33823447 return child -> path_expr ;
33833448}
33843449
3385- /* If frame associated with VAR can be found, switch
3386- to it and return 1. Otherwise, return 0. */
3387- static int
3388- check_scope (struct varobj * var )
3389- {
3390- struct frame_info * fi ;
3391- int scope ;
3392-
3393- fi = frame_find_by_id (var -> root -> frame );
3394- scope = fi != NULL ;
3395-
3396- if (fi )
3397- {
3398- CORE_ADDR pc = get_frame_pc (fi );
3399-
3400- if (pc < BLOCK_START (var -> root -> valid_block ) ||
3401- pc >= BLOCK_END (var -> root -> valid_block ))
3402- scope = 0 ;
3403- else
3404- select_frame (fi );
3405- }
3406- return scope ;
3407- }
3408-
3409- static struct value *
3410- c_value_of_root (struct varobj * * var_handle )
3411- {
3412- struct value * new_val = NULL ;
3413- struct varobj * var = * var_handle ;
3414- int within_scope = 0 ;
3415- struct cleanup * back_to ;
3416-
3417- /* Only root variables can be updated... */
3418- if (!is_root_p (var ))
3419- /* Not a root var. */
3420- return NULL ;
3421-
3422- back_to = make_cleanup_restore_current_thread ();
3423-
3424- /* Determine whether the variable is still around. */
3425- if (var -> root -> valid_block == NULL || var -> root -> floating )
3426- within_scope = 1 ;
3427- else if (var -> root -> thread_id == 0 )
3428- {
3429- /* The program was single-threaded when the variable object was
3430- created. Technically, it's possible that the program became
3431- multi-threaded since then, but we don't support such
3432- scenario yet. */
3433- within_scope = check_scope (var );
3434- }
3435- else
3436- {
3437- ptid_t ptid = thread_id_to_pid (var -> root -> thread_id );
3438- if (in_thread_list (ptid ))
3439- {
3440- switch_to_thread (ptid );
3441- within_scope = check_scope (var );
3442- }
3443- }
3444-
3445- if (within_scope )
3446- {
3447- volatile struct gdb_exception except ;
3448-
3449- /* We need to catch errors here, because if evaluate
3450- expression fails we want to just return NULL. */
3451- TRY_CATCH (except , RETURN_MASK_ERROR )
3452- {
3453- new_val = evaluate_expression (var -> root -> exp );
3454- }
3455- }
3456-
3457- do_cleanups (back_to );
3458-
3459- return new_val ;
3460- }
3461-
34623450static struct value *
34633451c_value_of_child (struct varobj * parent , int index )
34643452{
@@ -3892,12 +3880,6 @@ cplus_path_expr_of_child (struct varobj *child)
38923880 return child -> path_expr ;
38933881}
38943882
3895- static struct value *
3896- cplus_value_of_root (struct varobj * * var_handle )
3897- {
3898- return c_value_of_root (var_handle );
3899- }
3900-
39013883static struct value *
39023884cplus_value_of_child (struct varobj * parent , int index )
39033885{
@@ -3982,12 +3964,6 @@ java_path_expr_of_child (struct varobj *child)
39823964 return NULL ;
39833965}
39843966
3985- static struct value *
3986- java_value_of_root (struct varobj * * var_handle )
3987- {
3988- return cplus_value_of_root (var_handle );
3989- }
3990-
39913967static struct value *
39923968java_value_of_child (struct varobj * parent , int index )
39933969{
@@ -4040,12 +4016,6 @@ ada_path_expr_of_child (struct varobj *child)
40404016 child -> index );
40414017}
40424018
4043- static struct value *
4044- ada_value_of_root (struct varobj * * var_handle )
4045- {
4046- return c_value_of_root (var_handle );
4047- }
4048-
40494019static struct value *
40504020ada_value_of_child (struct varobj * parent , int index )
40514021{
0 commit comments