From: Manoj Iyer <manjo@austin.ibm.com>
To: gdb-patches@sources.redhat.com
Subject: [RFC] new GDB server testcase
Date: Wed, 04 May 2005 14:27:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.58.0505040918090.30511@lazy> (raw)
[-- Attachment #1: Type: TEXT/PLAIN, Size: 3451 bytes --]
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.
========================================================================
2005-05-04 Manoj Iyer <manjo@austin.ibm.com>
* gdb.server/basictest.c: New testcase
* gdb.server/basictest.exp: New testcase
============= basictest.c =========================
/* File: test basic remote debug functionality through TCP connection. */
/* Author: Manoj Iyer <manjo@austin.ibm.com> */
#include <stdio.h>
#include <stdlib.h>
static void
function3()
{
printf("In function 3\n");
exit(0);
}
static void
function2()
{
function3();
}
static void
function1()
{
function2();
}
main()
{
printf("hello gdb\n");
function1();
}
======================================================================
======================= basictest.exp ===============================
# This testcase is part of GDB, the GNU debugger.
# Copyright 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Test the remote TCP debug functionality of GDB.
# Author: Manoj Iyer <manjo@austin.ibm.com>
load_lib gdbserver-support.exp
set testfile "basictest"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
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
send_gdb "list \n"
gdb_expect {
-re ".*function1.*main.*\{.*printf.*$gdb_prompt $" {
pass "list commands can display source code" }
timeout { fail "list command failed to display source code" }
}
gdb_test "br main" "Breakpoint 1.*at.* file .*$srcfile, line \[0-9\]+.*"
gdb_test "continue" ".*Continuing\\..*Breakpoint \[0-9\]+, main.*at .*$srcfile:\[0-9\].*"
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 .*basictest.c:\[0-9\]+"
"#1.*function2.*at .*basictest.c:\[0-9\]+"
"#2.*function1.*at .*basictest.c:\[0-9\]+"
"#3.*main.*at .*basictest.c:\[0-9\]+"
}
============================ basictest.exp ====================
-----
manjo
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Cogito ergo sum +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[-- Attachment #2: expect script (new testcase) --]
[-- Type: TEXT/PLAIN, Size: 2278 bytes --]
# This testcase is part of GDB, the GNU debugger.
# Copyright 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Test the remote TCP debug functionality of GDB.
# Author: Manoj Iyer <manjo@austin.ibm.com>
load_lib gdbserver-support.exp
set testfile "basictest"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
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
send_gdb "list \n"
gdb_expect {
-re ".*function1.*main.*\{.*printf.*$gdb_prompt $" {
pass "list commands can display source code" }
timeout { fail "list command failed to display source code" }
}
gdb_test "br main" "Breakpoint 1.*at.* file .*$srcfile, line \[0-9\]+.*"
gdb_test "continue" ".*Continuing\\..*Breakpoint \[0-9\]+, main.*at .*$srcfile:\[0-9\].*"
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 .*basictest.c:\[0-9\]+"
"#1.*function2.*at .*basictest.c:\[0-9\]+"
"#2.*function1.*at .*basictest.c:\[0-9\]+"
"#3.*main.*at .*basictest.c:\[0-9\]+"
}
[-- Attachment #3: C source code (New testcase) --]
[-- Type: TEXT/x-csrc, Size: 448 bytes --]
/* File: test basic remote debug functionality through TCP connection. */
/* Author: Manoj Iyer <manjo@austin.ibm.com> */
#include <stdio.h>
#include <stdlib.h>
static void
function3()
{
printf("In function 3\n");
exit(0);
}
static void
function2()
{
function3();
}
static void
function1()
{
function2();
}
main()
{
printf("hello gdb\n");
function1();
}
next reply other threads:[~2005-05-04 14:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-04 14:27 Manoj Iyer [this message]
2005-05-04 14:43 ` Daniel Jacobowitz
2005-05-04 18:39 ` Manoj Iyer
2005-05-04 18:46 ` Daniel Jacobowitz
2005-05-04 21:59 ` Manoj Iyer
2005-05-04 22:07 ` Daniel Jacobowitz
2005-05-05 16:23 ` Manoj Iyer
2005-05-05 16:27 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0505040918090.30511@lazy \
--to=manjo@austin.ibm.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox