This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] new GDB server testcase


Daniel,

I added the testcases to server-run.exp and extended server.c to include a
nested function call so that I can test backtrace. Here is a patch. Please
review and comment. Following the patch is the results of the testcase
execution on x86.

2005-05-02  Manoj Iyer  <manjo@austin.ibm.com>

        * gdb.server/server-run.exp: Added new testcases
        * gdb.server/server.c: Added nested function call for backtrace
        testing.

=========Start Patch ===========================================

diff -Naurp old/src/gdb/testsuite/gdb.server/server-run.exp new/src/gdb/testsuite/gdb.server/server-run.exp
--- old/src/gdb/testsuite/gdb.server/server-run.exp	2005-05-04 10:34:16.000000000 -0500
+++ new/src/gdb/testsuite/gdb.server/server-run.exp	2005-05-04 13:26:09.000000000 -0500
@@ -38,5 +38,34 @@ gdb_start
 gdbserver_load $binfile ""
 gdb_reinitialize_dir $srcdir/$subdir

-gdb_breakpoint main
-gdb_test "continue" "Breakpoint.* main .*" "continue to main"
+gdb_test "br main" "Breakpoint 1.*at.* file .*$srcfile, line \[0-9\]+.*"
+
+gdb_test "continue" ".*Continuing\\..*Breakpoint \[0-9\]+, main.*at .*$srcfile:\[0-9\].*"
+
+send_gdb "list \n"
+gdb_expect {
+        -re ".*main.*\{.*$gdb_prompt $" {
+        pass "list commands can display source code" }
+        timeout { fail "list command failed to display source code" }
+}
+
+
+gdb_test "br function3" "Breakpoint 2.*at.* file .*$srcfile, line \[0-9\]+.*"
+
+gdb_test "continue" ".*Continuing\\..*Breakpoint \[0-9\]+, function3.*at .*$srcfile:\[0-9\].*"
+
+send_gdb "backtrace\n"
+gdb_expect_list "backtrace" ".*$gdb_prompt $" {
+    "#0.*function3.*at.*server.c:\[0-9\]+"
+    "#1.*function2.*at.*server.c:\[0-9\]+"
+    "#2.*function1.*at.*server.c:\[0-9\]+"
+    "#3.*main.*at.*server.c:\[0-9\]+"
+}
+
+gdb_test "step" "function4.*at .*$srcfile:\[0-9\]+.*"
+
+gdb_test "step 3" ".*${decimal}.*y = x.* y;.*"
+
+gdb_test "print x" ".*3.*"
+
+gdb_exit
diff -Naurp old/src/gdb/testsuite/gdb.server/server.c new/src/gdb/testsuite/gdb.server/server.c
--- old/src/gdb/testsuite/gdb.server/server.c	2005-05-04 10:34:16.000000000 -0500
+++ new/src/gdb/testsuite/gdb.server/server.c	2005-05-04 13:26:11.000000000 -0500
@@ -17,8 +17,42 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */

+static void
+function4()
+{
+
+   int x = 1;
+   int y = 2;
+
+   x = x + y;
+   y = x * y;
+   return;
+}
+
+
+static void
+function3()
+{
+   function4();
+}
+
+
+static void
+function2()
+{
+    function3();
+}
+
+
+static void
+function1()
+{
+    function2();
+}
+
 int
 main (int argc, char **argv)
 {
-  return 0;
+    function1();
+    return 0;
 }

================= End Patch ======================================

============= Test Result =============================================


Test Run By manjo on Wed May  4 13:23:25 2005
Native configuration is i686-pc-linux-gnu

		=== gdb tests ===

Schedule of variations:
    unix

Running target unix
Using ./../../dejagnu/baseboards/unix.exp as board description file for target.
Using ./../../dejagnu/config/unix.exp as generic interface file for target.
Using ./config/unix.exp as tool-and-target-specific interface file.
Running ./gdb.server/server-run.exp ...
Executing on host: gcc ./gdb.server/server.c  -g  -lm   -o /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/gdb.server/server    (timeout = 300)
spawn gcc ./gdb.server/server.c -g -lm -o /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/gdb.server/server
spawn /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/../../gdb/gdb -nw -nx
GNU gdb 6.3.50.20050421-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
(gdb) set height 0
(gdb) set width 0
(gdb) spawn /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/../../gdb/gdbserver/gdbserver :2346 /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/gdb.server/server
Process /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/gdb.server/server created; pid = 18079
Listening on port 2346
file /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/gdb.se rver/server
Reading symbols from /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/gdb.server/server...done.
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) target remote localhost:2346
Remote debugging using localhost:2346
Remote debugging from host 127.0.0.1
0x40000c20 in ?? ()
(gdb) dir
Reinitialize source path to empty? (y or n) y
Source directories searched: $cdir:$cwd
(gdb) dir ./gdb.server
Source directories searched: /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/./gdb.server:$cdir:$cwd
(gdb) br main
Breakpoint 1 at 0x80483af: file gdb.server/server.c, line 56.
(gdb) PASS: gdb.server/server-run.exp: br main
continue
Continuing.

Breakpoint 1, main (argc=1, argv=0xbffff7f4) at gdb.server/server.c:56
56	    function1();
(gdb) PASS: gdb.server/server-run.exp: continue
list
51	}
52
53	int
54	main (int argc, char **argv)
55	{
56	    function1();
57	    return 0;
58	}
(gdb) PASS: gdb.server/server-run.exp: list commands can display source code
br function3
Breakpoint 2 at 0x804837e: file gdb.server/server.c, line 36.
(gdb) PASS: gdb.server/server-run.exp: br function3
continue
Continuing.

Breakpoint 2, function3 () at gdb.server/server.c:36
36	   function4();
(gdb) PASS: gdb.server/server-run.exp: continue
backtrace
#0  function3 () at gdb.server/server.c:36
#1  0x08048390 in function2 () at gdb.server/server.c:43
#2  0x0804839d in function1 () at gdb.server/server.c:50
#3  0x080483b4 in main (argc=1, argv=0xbffff7f4) at gdb.server/server.c:56
(gdb) PASS: gdb.server/server-run.exp: backtrace
step
function4 () at gdb.server/server.c:24
24	   int x = 1;
(gdb) PASS: gdb.server/server-run.exp: step
step 3
28	   y = x * y;
(gdb) PASS: gdb.server/server-run.exp: step 3
print x
$1 = 3
(gdb) PASS: gdb.server/server-run.exp: print x
testcase ./gdb.server/server-run.exp completed in 1 seconds

		=== gdb Summary ===

# of expected passes		9
Executing on host: /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd    (timeout = 300)
spawn /home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd
GNU gdb 6.3.50.20050421-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
/home/manjo/projects/gdb/mainline/2005-04-21/src/gdb/testsuite/../../gdb/gdb version  6.3.50.20050421-cvs -nx

runtest completed at Wed May  4 13:23:27 2005

====================== End Test Result =======================

Thanks
-----
manjo
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Cogito ergo sum                                                          +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Wed, 4 May 2005, Daniel Jacobowitz wrote:

> On Wed, May 04, 2005 at 09:24:20AM -0500, Manoj Iyer wrote:
> >
> > I wrote a testcase for testing basic gdbserver functionality over TCP
> > connection. I will add more cases like step, print, etc once the testcase
> > is approved.
>
> Thanks for doing this.
>
> Can you find a better name than "basictest.exp"?  Is there a reason not
> to add these basic tests to server-run.exp?
>
> > /* File: test basic remote debug functionality through TCP connection.       */
> > /* Author: Manoj Iyer <manjo@austin.ibm.com>                                 */
>
> This needs a copyright notice.
>
> > #include <stdio.h>
> > #include <stdlib.h>
>
> Why are you using stdio?  We have no easy way to get at the program's
> output.
>
> >
> > main()
> > {
> >     printf("hello gdb\n");
> >     function1();
> > }
>
> That's not valid C, though many compilers will accept it.  "int main"
> and "return 0" please.
>
> >
> > ======================================================================
> >
> > ======================= basictest.exp ===============================
>
> Please use server-run.exp as a template instead of whatever you were
> using.  For instance, use skip_gdbserver_tests, and don't use
> gdb_suppress_entire_file.
>
> > gdb_exit
> > global gdbport
> >
> > set ret [gdbserver_spawn $binfile ""]
> > set gdbport [lindex $ret 1]
> >
> > gdb_start
> >
> > send_gdb "file $binfile \n "
> >
> > gdb_target_cmd "remote" $gdbport
>
> ... and don't duplicate any of that.  gdbserver_load.  I went to a lot
> of trouble to write the infrastructure, so please use it :-)
>
> --
> Daniel Jacobowitz
> CodeSourcery, LLC
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]