]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-01-20 David Carlton <carlton@math.stanford.edu>
authorDavid Carlton <carlton@bactrian.org>
Tue, 21 Jan 2003 01:02:30 +0000 (01:02 +0000)
committerDavid Carlton <carlton@bactrian.org>
Tue, 21 Jan 2003 01:02:30 +0000 (01:02 +0000)
* p-exp.y: Add block to OP_FUNCALL.
* objc-exp.y: Add block to OP_FUNCALL.
* m2-exp.y: Add block to OP_FUNCALL.
* c-exp.y: Add block to OP_FUNCALL.
* ada-exp.y: Add block to OP_FUNCALL.
(write_object_renaming): Ditto.
* parse.c (length_of_subexp): Split off OP_FUNCALL.
(prefixify_subexp): Ditto.
* expprint.c (print_subexp): Change offset for OP_FUNCALL.
(dump_subexp): Ditto.
* eval.c (evaluate_subexp_standard): Change offset for
OP_FUNCALL.
* ada-lang.c (ada_resolve_subexp): Add comment on OP_FUNCALL.
(replace_operator_with_call): Add block to OP_FUNCALL.
(ada_evaluate_subexp): Change offset for OP_FUNCALL.
* expression.h (exp_opcode): Change comments before OP_FUNCALL and
OP_F77_UNDETERMINED_ARGLIST.

2003-01-14  David Carlton  <carlton@math.stanford.edu>

* symtab.c (search_symbols): Add comment.
(lookup_symbol_aux_using): Function name should start line.
(lookup_symbol_aux_using_loop): Ditto.
(lookup_block_symbol): Add comment.

2003-01-13  David Carlton  <carlton@math.stanford.edu>

* dwarf2read.c (read_structure_scope): Add comment.
(add_partial_structure): Ditto.
* symtab.c (lookup_transparent_type): Add comment.

13 files changed:
gdb/ChangeLog
gdb/ada-exp.y
gdb/ada-lang.c
gdb/c-exp.y
gdb/dwarf2read.c
gdb/eval.c
gdb/expprint.c
gdb/expression.h
gdb/m2-exp.y
gdb/objc-exp.y
gdb/p-exp.y
gdb/parse.c
gdb/symtab.c

index f932e7c90ffd62d2027c2541dab8ff04532e83b2..cc4bc224271b75f85f68a679dd13f7345bef9e46 100644 (file)
@@ -1,3 +1,36 @@
+2003-01-20  David Carlton  <carlton@math.stanford.edu>
+
+       * p-exp.y: Add block to OP_FUNCALL.
+       * objc-exp.y: Add block to OP_FUNCALL.
+       * m2-exp.y: Add block to OP_FUNCALL.
+       * c-exp.y: Add block to OP_FUNCALL.
+       * ada-exp.y: Add block to OP_FUNCALL.
+       (write_object_renaming): Ditto.
+       * parse.c (length_of_subexp): Split off OP_FUNCALL.
+       (prefixify_subexp): Ditto.
+       * expprint.c (print_subexp): Change offset for OP_FUNCALL.
+       (dump_subexp): Ditto.
+       * eval.c (evaluate_subexp_standard): Change offset for
+       OP_FUNCALL.
+       * ada-lang.c (ada_resolve_subexp): Add comment on OP_FUNCALL.
+       (replace_operator_with_call): Add block to OP_FUNCALL.
+       (ada_evaluate_subexp): Change offset for OP_FUNCALL.
+       * expression.h (exp_opcode): Change comments before OP_FUNCALL and
+       OP_F77_UNDETERMINED_ARGLIST.
+
+2003-01-14  David Carlton  <carlton@math.stanford.edu>
+
+       * symtab.c (search_symbols): Add comment.
+       (lookup_symbol_aux_using): Function name should start line.
+       (lookup_symbol_aux_using_loop): Ditto.
+       (lookup_block_symbol): Add comment.
+
+2003-01-13  David Carlton  <carlton@math.stanford.edu>
+
+       * dwarf2read.c (read_structure_scope): Add comment.
+       (add_partial_structure): Ditto.
+       * symtab.c (lookup_transparent_type): Add comment.
+
 2003-01-10  David Carlton  <carlton@math.stanford.edu>
 
        * objfiles.c (allocate_objfile): Always set name.
index aece48a7316ca613e306a8fac267ab47dfd8ed55..45d09a99a91dcc9748d2d00c272a292c42a70256 100644 (file)
@@ -233,6 +233,7 @@ simple_exp :        simple_exp '(' arglist ')'
                        {
                          write_exp_elt_opcode (OP_FUNCALL);
                          write_exp_elt_longcst ($3);
+                         write_exp_elt_block (expression_context_block);
                          write_exp_elt_opcode (OP_FUNCALL);
                        }
        ;
@@ -902,6 +903,7 @@ write_object_renaming (orig_left_context, renaming)
          { 
            write_exp_elt_opcode (OP_FUNCALL);
            write_exp_elt_longcst ((LONGEST) 1);
+           write_exp_elt_block (expression_context_block);
            write_exp_elt_opcode (OP_FUNCALL);
          }
        else if (slice_state == LOWER_BOUND)
index 23c882714868f3229230830679b5af3367e83307..1af40286e0252ac6fdf3d7f40e183592ca1f4fa3 100644 (file)
@@ -1973,6 +1973,9 @@ ada_resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
       break;
 
     case OP_FUNCALL:
+      /* FIXME: carlton/2002-01-20: I don't understand this well
+        enough to know if it should be changed after I added the
+        current block to an OP_FUNCALL.  */
       nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1;
       /* FIXME:  OP_UNRESOLVED_VALUE should be defined in expression.h */
       /*      if (exp->elts[pc+3].opcode == OP_UNRESOLVED_VALUE)        
@@ -2787,10 +2790,11 @@ replace_operator_with_call (struct expression **expp, int pc, int nargs,
 
   newexp->elts[pc].opcode = newexp->elts[pc + 2].opcode = OP_FUNCALL;
   newexp->elts[pc + 1].longconst = (LONGEST) nargs;
+  newexp->elts[pc + 2].block = block;
 
-  newexp->elts[pc + 3].opcode = newexp->elts[pc + 6].opcode = OP_VAR_VALUE;
-  newexp->elts[pc + 4].block = block;
-  newexp->elts[pc + 5].symbol = sym;
+  newexp->elts[pc + 4].opcode = newexp->elts[pc + 6].opcode = OP_VAR_VALUE;
+  newexp->elts[pc + 5].block = block;
+  newexp->elts[pc + 6].symbol = sym;
 
   *expp = newexp;
   xfree (exp);
@@ -6992,7 +6996,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       return value_array (tem2, tem3, argvec);
 
     case OP_FUNCALL:
-      (*pos) += 2;
+      (*pos) += 3;
 
       /* Allocate arg vector, including space for the function to be
          called in argvec[0] and a terminating NULL */
index f2094b5ba9b01d5ea4d6e6cb2cdc1f829535b411..1faea77e8e694386a114d9698e9e0c74d3a5509f 100644 (file)
@@ -333,6 +333,7 @@ exp :       exp '('
                arglist ')'     %prec ARROW
                        { write_exp_elt_opcode (OP_FUNCALL);
                          write_exp_elt_longcst ((LONGEST) end_arglist ());
+                         write_exp_elt_block (expression_context_block);
                          write_exp_elt_opcode (OP_FUNCALL); }
        ;
 
index fd7483a9a4e3e3336be235adf229c5aa631c5862..1952ad47498148d4f85aba9af13ba7e7853fe8bc 100644 (file)
@@ -1625,6 +1625,13 @@ add_partial_structure (struct partial_die_info *struct_pdi, char *info_ptr,
         can figure out if this structure lives in a namespace.  Look
         for a member function; its demangled name will contain
         namespace info, if there is any.  */
+
+      /* NOTE: carlton/2003-01-13: Getting the info this way changes
+        what template types look like, because the demangler
+        frequently doesn't give the same name as the debug info.  We
+        could fix this by only using the demangled name to get the
+        prefix (but see comment in read_structure_scope).  */
+
       char *next_child = info_ptr;
 
       while (1)
@@ -2811,6 +2818,14 @@ read_structure_scope (struct die_info *die, struct objfile *objfile,
                  /* FIXME: carlton/2003-01-10: The excessive
                     demangling here is a bit wasteful, as is the
                     memory usage for names.  */
+
+                 /* NOTE: carlton/2003-01-13: As commented in
+                    add_partial_structure, the demangler sometimes
+                    prints the type info in a different form from the
+                    debug info.  We could solve this by using the
+                    demangled name to get the prefix; if doing so,
+                    however, we'd need to be careful when reading a
+                    class that's nested inside a template class.  */
                  char *actual_class_name
                    = class_name_from_physname (dwarf2_linkage_name
                                                (child_die));
index 67afcd165fb1fdc6a71d1737f98e6f6c90d0ac06..d71967143a3bb396d556d3c4dcd64c6db2da609d 100644 (file)
@@ -664,7 +664,7 @@ evaluate_subexp_standard (struct type *expect_type,
        }
 
     case OP_FUNCALL:
-      (*pos) += 2;
+      (*pos) += 3;
       op = exp->elts[*pos].opcode;
       nargs = longest_to_int (exp->elts[pc + 1].longconst);
       /* Allocate arg vector, including space for the function to be
index 31b82c007fa28c101840cdf111eac1b046e9dd15..63d6d3b35c79375d0457f7c491a8c58128790b8c 100644 (file)
@@ -144,7 +144,7 @@ print_subexp (register struct expression *exp, register int *pos,
       return;
 
     case OP_FUNCALL:
-      (*pos) += 2;
+      (*pos) += 3;
       nargs = longest_to_int (exp->elts[pc + 1].longconst);
       print_subexp (exp, pos, stream, PREC_SUFFIX);
       fputs_filtered (" (", stream);
@@ -933,7 +933,7 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt)
        nargs = longest_to_int (exp->elts[elt].longconst);
 
        fprintf_filtered (stream, "Number of args: %d", nargs);
-       elt += 2;
+       elt += 3;
 
        for (i = 1; i <= nargs + 1; i++)
          elt = dump_subexp (exp, stream, elt);
index 85329224d3b2ba1e96043ed5c0f4c3f181e0644c..f831337f6342ed8c307eb6f7e54176e1f3dfd40c 100644 (file)
@@ -174,11 +174,12 @@ enum exp_opcode
     OP_INTERNALVAR,
 
     /* OP_FUNCALL is followed by an integer in the next exp_element.
-       The integer is the number of args to the function call.
-       That many plus one values from following subexpressions
-       are used, the first one being the function.
-       The integer is followed by a repeat of OP_FUNCALL,
-       making three exp_elements.  */
+       The integer is the number of args to the function call.  That
+       many plus one values from following subexpressions are used,
+       the first one being the function.  Next comes the current
+       block: this is used when doing operator overloading in C++.
+       Finally, there is a repeat of OP_FUNCALL, making four
+       exp_elements.  */
     OP_FUNCALL,
 
     /* OP_OBJC_MSGCALL is followed by a string in the next exp_element and then an
@@ -192,6 +193,9 @@ enum exp_opcode
        and function calls are  all exactly the same syntactically. They may 
        only be dismabiguated at runtime.  Thus this operator, which 
        indicates that we have found something of the form <name> ( <stuff> ) */
+
+    /* NOTE: carlton/2003-01-20: Now that I've added a block to
+       OP_FUNCALL, it's no longer exactly like OP_FUNCALL.  */
     OP_F77_UNDETERMINED_ARGLIST,
 
     /* The following OP is a special one, it introduces a F77 complex
index 39fdebae27bb171bd656873072d2f7647c633e31..ad406edddf16551497954072fe44fd9c2bf4e7bd 100644 (file)
@@ -360,6 +360,7 @@ exp :       exp '('
                arglist ')'     %prec DOT
                        { write_exp_elt_opcode (OP_FUNCALL);
                          write_exp_elt_longcst ((LONGEST) end_arglist ());
+                         write_exp_elt_block (expression_context_block);
                          write_exp_elt_opcode (OP_FUNCALL); }
        ;
 
index 42ee124ef2ac65cab9da9484dee9007aaa8bf70d..d9e75a35cb5b7ec2d3f9e4ddc4b7583bb6c5eda7 100644 (file)
@@ -396,6 +396,7 @@ exp :       exp '('
                arglist ')'     %prec ARROW
                        { write_exp_elt_opcode (OP_FUNCALL);
                          write_exp_elt_longcst ((LONGEST) end_arglist ());
+                         write_exp_elt_block (expression_context_block);
                          write_exp_elt_opcode (OP_FUNCALL); }
        ;
 
index c52c0a54438d1c0afd9d824122f99544f7993ce9..01877114bd68844ae467303a3af62f98ee0fcf4c 100644 (file)
@@ -331,6 +331,7 @@ exp :       exp '('
                arglist ')'     %prec ARROW
                        { write_exp_elt_opcode (OP_FUNCALL);
                          write_exp_elt_longcst ((LONGEST) end_arglist ());
+                         write_exp_elt_block (expression_context_block);
                          write_exp_elt_opcode (OP_FUNCALL); 
                          pop_current_type (); }
        ;
index cb598339799b16aba22e0b7764681db0ae85180b..1b69344121b1feca43f0a23cc8cbee177df533b3 100644 (file)
@@ -825,6 +825,10 @@ length_of_subexp (register struct expression *expr, register int endpos)
       break;
 
     case OP_FUNCALL:
+      oplen = 4;
+      args = 1 + longest_to_int (expr->elts[endpos - 3].longconst);
+      break;
+
     case OP_F77_UNDETERMINED_ARGLIST:
       oplen = 3;
       args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
@@ -970,6 +974,10 @@ prefixify_subexp (register struct expression *inexpr,
       break;
 
     case OP_FUNCALL:
+      oplen = 4;
+      args = 1 + longest_to_int (inexpr->elts[inend - 3].longconst);
+      break;
+
     case OP_F77_UNDETERMINED_ARGLIST:
       oplen = 3;
       args = 1 + longest_to_int (inexpr->elts[inend - 2].longconst);
index 33baa65b8a3fc292b87237b46e0c8fd231f0deec..730e27085d15fa48169e95a177f658a35003bd0a 100644 (file)
@@ -1183,11 +1183,12 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name,
    appropriate namespaces scope for BLOCK, and searches for NAME in
    each of the namespaces that are in scope.  */
 
-static struct symbol *lookup_symbol_aux_using (const char *name,
-                                              const char *linkage_name,
-                                              const struct block *block,
-                                              const namespace_enum namespace,
-                                              struct symtab **symtab)
+static struct symbol *
+lookup_symbol_aux_using (const char *name,
+                        const char *linkage_name,
+                        const struct block *block,
+                        const namespace_enum namespace,
+                        struct symtab **symtab)
 {
   const char *scope = block_scope (block);
 
@@ -1196,14 +1197,14 @@ static struct symbol *lookup_symbol_aux_using (const char *name,
                                       scope, 0);
 }
 
-static struct
-symbol *lookup_symbol_aux_using_loop (const char *name,
-                                     const char *linkage_name,
-                                     const struct block *block,
-                                     namespace_enum namespace,
-                                     struct symtab **symtab,
-                                     const char *scope,
-                                     int scope_len)
+static struct symbol *
+lookup_symbol_aux_using_loop (const char *name,
+                             const char *linkage_name,
+                             const struct block *block,
+                             namespace_enum namespace,
+                             struct symtab **symtab,
+                             const char *scope,
+                             int scope_len)
 {
   if (scope[scope_len] != '\0')
     {
@@ -1517,6 +1518,10 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
    wrong one.  Something to keep in mind when we have iterators,
    though.  */
 
+/* NOTE: carlton/2003-01-13: Callers for this should have the full
+   name of the type in question, so this doesn't have to get any
+   smarter about namespace stuff.  */
+
 struct type *
 lookup_transparent_type (const char *name)
 {
@@ -1667,6 +1672,11 @@ find_main_psymtab (void)
    that strcmp and strcmp_iw don't match on it (which seems unlikely
    to me).  */
 
+/* NOTE: carlton/2003-01-14: No, there are situations where this is
+   more generous: it ignores whitespace on demangled names, too.  This
+   is good: e.g. it makes recognizing templated types more generous.
+   See PR gdb/33.  */
+
 struct symbol *
 lookup_block_symbol (register const struct block *block, const char *name,
                     const char *linkage_name, const namespace_enum namespace)
@@ -2780,6 +2790,10 @@ sort_search_symbols (struct symbol_search *prevtail, int nfound)
    The results are sorted locally; each symtab's global and static blocks are
    separately alphabetized.
  */
+
+/* NOTE: carlton/2003-01-14: I don't think this needs any namespace
+   tweaking.  */
+
 void
 search_symbols (char *regexp, namespace_enum kind, int nfiles, char *files[],
                struct symbol_search **matches)