Don't edit bogus sh_link on reading relocatable objects (Oracle fix)
[binutils-gdb.git] / gdb / varobj.c
index 19a90c7119613f158f697c49fd8f23eac3ecc1ff..c448fc82d75b04a144c3757a63415b596cdb0370 100644 (file)
@@ -1,6 +1,6 @@
 /* Implementation of the GDB variable objects API.
 
-   Copyright (C) 1999-2020 Free Software Foundation, Inc.
+   Copyright (C) 1999-2021 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -311,9 +311,10 @@ varobj_create (const char *objname,
        }
 
       /* Don't allow variables to be created for types.  */
-      if (var->root->exp->elts[0].opcode == OP_TYPE
-         || var->root->exp->elts[0].opcode == OP_TYPEOF
-         || var->root->exp->elts[0].opcode == OP_DECLTYPE)
+      enum exp_opcode opcode = var->root->exp->first_opcode ();
+      if (opcode == OP_TYPE
+         || opcode == OP_TYPEOF
+         || opcode == OP_DECLTYPE)
        {
          fprintf_unfiltered (gdb_stderr, "Attempt to use a type name"
                              " as an expression.\n");
@@ -660,8 +661,7 @@ varobj_get_iterator (struct varobj *var)
     return py_varobj_get_iterator (var, var->dynamic->pretty_printer);
 #endif
 
-  gdb_assert_not_reached (_("\
-requested an iterator from a non-dynamic varobj"));
+  gdb_assert_not_reached ("requested an iterator from a non-dynamic varobj");
 }
 
 static bool
@@ -1843,10 +1843,12 @@ varobj::~varobj ()
     }
 #endif
 
+  /* This must be deleted before the root object, because Python-based
+     destructors need access to some components.  */
+  delete var->dynamic;
+
   if (is_root_p (var))
     delete var->root;
-
-  delete var->dynamic;
 }
 
 /* Return the type of the value that's stored in VAR,
@@ -2206,7 +2208,7 @@ varobj_value_get_print_value (struct value *value,
 
                          thevalue = std::string (s.get ());
                          len = thevalue.size ();
-                         gdbarch = get_type_arch (value_type (value));
+                         gdbarch = value_type (value)->arch ();
                          type = builtin_type (gdbarch)->builtin_char;
 
                          if (!string_print)