gdb:
authorTom Tromey <tromey@redhat.com>
Sun, 27 Jul 2008 02:00:04 +0000 (02:00 +0000)
committerTom Tromey <tromey@redhat.com>
Sun, 27 Jul 2008 02:00:04 +0000 (02:00 +0000)
PR gdb/1158:
* valops.c (value_struct_elt): Treat function-valued field as a
static method.
gdb/testsuite:
* gdb.base/callfuncs.c (struct struct_with_fnptr): New struct.
(function_struct, function_struct_ptr): New globals.
* gdb.base/callfuncs.exp (do_function_calls): Test calling via a
function pointer in a struct.

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/callfuncs.c
gdb/testsuite/gdb.base/callfuncs.exp
gdb/valops.c

index 5db0b0c53cf19f7b1a88c82a07d20dd8b1eaf007..99b8f54209d0a97b3295492868effbc241ac6c25 100644 (file)
@@ -1,3 +1,9 @@
+2008-07-26  Tom Tromey  <tromey@redhat.com>
+
+       PR gdb/1158:
+       * valops.c (value_struct_elt): Treat function-valued field as a
+       static method.
+
 2008-07-26  Tom Tromey  <tromey@redhat.com>
 
        PR gdb/1136:
index 4047c48bca0d72c16c443f637a098b795fa116c0..75b90e1add0c6dfdc73909fd8d9d5da6c3c4bd39 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-26  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.base/callfuncs.c (struct struct_with_fnptr): New struct.
+       (function_struct, function_struct_ptr): New globals.
+       * gdb.base/callfuncs.exp (do_function_calls): Test calling via a
+       function pointer in a struct.
+
 2008-07-26  Tom Tromey  <tromey@redhat.com>
 
        * gdb.base/macscp.exp: Add test for macro lexing bug.
index 5a150b09718ce805d58a697c532330ffc16220d2..655c698121bf537df1aed342954c0ca6387c7136 100644 (file)
@@ -490,6 +490,14 @@ int a, b;
   return ((*func_arg1)(a, b));
 }
 
+struct struct_with_fnptr
+{
+  int (*func) PARAMS((int));
+};
+
+struct struct_with_fnptr function_struct = { doubleit };
+
+struct struct_with_fnptr *function_struct_ptr = &function_struct;
 
 /* Gotta have a main to be able to generate a linked, runnable
    executable, and also provide a useful place to set a breakpoint. */
index 1a4da6e0b69332b2bcc9058baf79012aedaa0265..bb855083da046ab1ebce9374a993d2096b3d6ddb 100644 (file)
@@ -190,6 +190,9 @@ proc do_function_calls {} {
     gdb_test "p t_func_values(func_val2,func_val1)" " = 0"
     gdb_test "p t_func_values(func_val1,func_val2)" " = 1"
 
+    gdb_test "p function_struct.func(5)" " = 10"
+    gdb_test "p function_struct_ptr->func(10)" " = 20"
+
     # GDB currently screws up the passing of function parameters for
     # ABIs that use function descriptors.  Instead of passing the
     # address of te function descriptor, GDB passes the address of the
index aad9871f7139ae11eb1869612d6b28572a3212ec..8c99218683e6e765be7f917c013497bee5e8f18a 100644 (file)
@@ -1819,6 +1819,10 @@ value_struct_elt (struct value **argp, struct value **args,
          back.  If it's not callable (i.e., a pointer to function),
          gdb should give an error.  */
       v = search_struct_field (name, *argp, 0, t, 0);
+      /* If we found an ordinary field, then it is not a method call.
+        So, treat it as if it were a static member function.  */
+      if (v && static_memfuncp)
+       *static_memfuncp = 1;
     }
 
   if (!v)
This page took 0.039009 seconds and 4 git commands to generate.