Fix argument to compiled_cond, and add cases for compiled-condition.
[deliverable/binutils-gdb.git] / gdb / stap-probe.c
index 9ee97672bb1e480463193f9520feaf05c4612741..912505cfcbd922a38621e086e90484a21abc6aba 100644 (file)
@@ -313,9 +313,8 @@ stap_get_opcode (const char **s)
       break;
 
     default:
-      internal_error (__FILE__, __LINE__,
-                     _("Invalid opcode in expression `%s' for SystemTap"
-                       "probe"), *s);
+      error (_("Invalid opcode in expression `%s' for SystemTap"
+              "probe"), *s);
     }
 
   return op;
@@ -326,7 +325,8 @@ stap_get_opcode (const char **s)
 
 static struct type *
 stap_get_expected_argument_type (struct gdbarch *gdbarch,
-                                enum stap_arg_bitness b)
+                                enum stap_arg_bitness b,
+                                const struct stap_probe *probe)
 {
   switch (b)
     {
@@ -361,8 +361,8 @@ stap_get_expected_argument_type (struct gdbarch *gdbarch,
       return builtin_type (gdbarch)->builtin_uint64;
 
     default:
-      internal_error (__FILE__, __LINE__,
-                     _("Undefined bitness for probe."));
+      error (_("Undefined bitness for probe '%s'."),
+            probe->p.name);
       break;
     }
 }
@@ -1172,7 +1172,8 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch)
       else
        arg.bitness = STAP_ARG_BITNESS_UNDEFINED;
 
-      arg.atype = stap_get_expected_argument_type (gdbarch, arg.bitness);
+      arg.atype = stap_get_expected_argument_type (gdbarch, arg.bitness,
+                                                  probe);
 
       expr = stap_parse_argument (&cur, arg.atype, gdbarch);
 
@@ -1278,12 +1279,26 @@ stap_is_operator (const char *op)
   return ret;
 }
 
+/* Return argument N of probe PROBE.
+
+   If the probe's arguments have not been parsed yet, parse them.  If
+   there are no arguments, throw an exception (error).  Otherwise,
+   return the requested argument.  */
+
 static struct stap_probe_arg *
 stap_get_arg (struct stap_probe *probe, unsigned n, struct gdbarch *gdbarch)
 {
   if (!probe->args_parsed)
     stap_parse_probe_arguments (probe, gdbarch);
 
+  gdb_assert (probe->args_parsed);
+  if (probe->args_u.vec == NULL)
+    internal_error (__FILE__, __LINE__,
+                   _("Probe '%s' apparently does not have arguments, but \n"
+                     "GDB is requesting its argument number %u anyway.  "
+                     "This should not happen.  Please report this bug."),
+                   probe->p.name, n);
+
   return VEC_index (stap_probe_arg_s, probe->args_u.vec, n);
 }
 
@@ -1467,7 +1482,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
   const char *probe_args = NULL;
   struct stap_probe *ret;
 
-  ret = obstack_alloc (&objfile->per_bfd->storage_obstack, sizeof (*ret));
+  ret = XOBNEW (&objfile->per_bfd->storage_obstack, struct stap_probe);
   ret->p.pops = &stap_probe_ops;
   ret->p.arch = gdbarch;
 
This page took 0.025354 seconds and 4 git commands to generate.