Add xml selftests for aarch64 target description.
[deliverable/binutils-gdb.git] / gdb / ax-gdb.c
index 3fdf81afee587f6bd2f1e06d38650025c23701e6..52ca081a8280d66befa4195720062e0ba261dd5f 100644 (file)
@@ -42,7 +42,7 @@
 #include "linespec.h"
 #include "location.h"
 #include "objfiles.h"
-
+#include "typeprint.h"
 #include "valprint.h"
 #include "c-lang.h"
 
@@ -158,8 +158,6 @@ static void gen_expr_binop_rest (struct expression *exp,
                                 struct axs_value *value,
                                 struct axs_value *value1,
                                 struct axs_value *value2);
-
-static void agent_command (char *exp, int from_tty);
 \f
 
 /* Detecting constant expressions.  */
@@ -1765,6 +1763,40 @@ gen_sizeof (struct expression *exp, union exp_element **pc,
 }
 \f
 
+/* Generate bytecode for a cast to TO_TYPE.  Advance *PC over the
+   subexpression.  */
+
+static void
+gen_expr_for_cast (struct expression *exp, union exp_element **pc,
+                  struct agent_expr *ax, struct axs_value *value,
+                  struct type *to_type)
+{
+  enum exp_opcode op = (*pc)[0].opcode;
+
+  /* Don't let symbols be handled with gen_expr because that throws an
+     "unknown type" error for no-debug data symbols.  Instead, we want
+     the cast to reinterpret such symbols.  */
+  if (op == OP_VAR_MSYM_VALUE || op == OP_VAR_VALUE)
+    {
+      if (op == OP_VAR_VALUE)
+       {
+         gen_var_ref (ax, value, (*pc)[2].symbol);
+
+         if (value->optimized_out)
+           error (_("`%s' has been optimized out, cannot use"),
+                  SYMBOL_PRINT_NAME ((*pc)[2].symbol));
+       }
+      else
+       gen_msym_var_ref (ax, value, (*pc)[2].msymbol, (*pc)[1].objfile);
+      if (TYPE_CODE (value->type) == TYPE_CODE_ERROR)
+       value->type = to_type;
+      (*pc) += 4;
+    }
+  else
+    gen_expr (exp, pc, ax, value);
+  gen_cast (ax, value, to_type);
+}
+
 /* Generating bytecode from GDB expressions: general recursive thingy  */
 
 /* XXX: i18n */
@@ -1978,11 +2010,18 @@ gen_expr (struct expression *exp, union exp_element **pc,
        error (_("`%s' has been optimized out, cannot use"),
               SYMBOL_PRINT_NAME ((*pc)[2].symbol));
 
+      if (TYPE_CODE (value->type) == TYPE_CODE_ERROR)
+       error_unknown_type (SYMBOL_PRINT_NAME ((*pc)[2].symbol));
+
       (*pc) += 4;
       break;
 
     case OP_VAR_MSYM_VALUE:
       gen_msym_var_ref (ax, value, (*pc)[2].msymbol, (*pc)[1].objfile);
+
+      if (TYPE_CODE (value->type) == TYPE_CODE_ERROR)
+       error_unknown_type (MSYMBOL_PRINT_NAME ((*pc)[2].msymbol));
+
       (*pc) += 4;
       break;
 
@@ -2043,8 +2082,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
        struct type *type = (*pc)[1].type;
 
        (*pc) += 3;
-       gen_expr (exp, pc, ax, value);
-       gen_cast (ax, value, type);
+       gen_expr_for_cast (exp, pc, ax, value, type);
       }
       break;
 
@@ -2059,9 +2097,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
        val = evaluate_subexp (NULL, exp, &offset, EVAL_AVOID_SIDE_EFFECTS);
        type = value_type (val);
        *pc = &exp->elts[offset];
-
-       gen_expr (exp, pc, ax, value);
-       gen_cast (ax, value, type);
+       gen_expr_for_cast (exp, pc, ax, value, type);
       }
       break;
 
@@ -2584,7 +2620,7 @@ agent_eval_command_one (const char *exp, int eval, CORE_ADDR pc)
 }
 
 static void
-agent_command_1 (char *exp, int eval)
+agent_command_1 (const char *exp, int eval)
 {
   /* We don't deal with overlay debugging at the moment.  We need to
      think more carefully about this.  If you copy this code into
@@ -2623,7 +2659,7 @@ agent_command_1 (char *exp, int eval)
 }
 
 static void
-agent_command (char *exp, int from_tty)
+agent_command (const char *exp, int from_tty)
 {
   agent_command_1 (exp, 0);
 }
@@ -2633,7 +2669,7 @@ agent_command (char *exp, int from_tty)
    expression.  */
 
 static void
-agent_eval_command (char *exp, int from_tty)
+agent_eval_command (const char *exp, int from_tty)
 {
   agent_command_1 (exp, 1);
 }
@@ -2642,12 +2678,11 @@ agent_eval_command (char *exp, int from_tty)
    that does a printf, and display the resulting expression.  */
 
 static void
-maint_agent_printf_command (char *exp, int from_tty)
+maint_agent_printf_command (const char *cmdrest, int from_tty)
 {
   struct cleanup *old_chain = 0;
   struct expression *argvec[100];
   struct frame_info *fi = get_current_frame ();        /* need current scope */
-  const char *cmdrest;
   const char *format_start, *format_end;
   struct format_piece *fpieces;
   int nargs;
@@ -2659,12 +2694,10 @@ maint_agent_printf_command (char *exp, int from_tty)
   if (overlay_debugging)
     error (_("GDB can't do agent expression translation with overlays."));
 
-  if (exp == 0)
+  if (cmdrest == 0)
     error_no_arg (_("expression to translate"));
 
-  cmdrest = exp;
-
-  cmdrest = skip_spaces_const (cmdrest);
+  cmdrest = skip_spaces (cmdrest);
 
   if (*cmdrest++ != '"')
     error (_("Must start with a format string."));
@@ -2680,14 +2713,14 @@ maint_agent_printf_command (char *exp, int from_tty)
   if (*cmdrest++ != '"')
     error (_("Bad format string, non-terminated '\"'."));
   
-  cmdrest = skip_spaces_const (cmdrest);
+  cmdrest = skip_spaces (cmdrest);
 
   if (*cmdrest != ',' && *cmdrest != 0)
     error (_("Invalid argument syntax"));
 
   if (*cmdrest == ',')
     cmdrest++;
-  cmdrest = skip_spaces_const (cmdrest);
+  cmdrest = skip_spaces (cmdrest);
 
   nargs = 0;
   while (*cmdrest != '\0')
@@ -2718,11 +2751,9 @@ maint_agent_printf_command (char *exp, int from_tty)
   do_cleanups (old_chain);
   dont_repeat ();
 }
-\f
 
 /* Initialization code.  */
 
-void _initialize_ax_gdb (void);
 void
 _initialize_ax_gdb (void)
 {
This page took 0.029151 seconds and 4 git commands to generate.