[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions on RTEMS GDB stub over a serial line



Till Straumann wrote:
> Ian Jiang wrote:
>   
>> Hi rtems-usersall!
>>
>> I am establishing a remote debug enviroment of RTEMS in a VMware workstation. I am using Till Straumann's GDB Agent for RTEMS. I referred http://www.slac.stanford.edu/~strauman/rtems/gdb/ but I am not clear enough about how to setup a session between the host and the target using a serial port.
>>
>> Questions
>> =========
>>
>> 1) Where is the serial device? 
>> Some codes were added to list all file under /dev/ but only /dev/console was found.
>>   
>>     
> You'd have to add 'TTY1_DRIVER_TABLE_ENTRY' to the driver table.
> Since this driver is unkown to confdefs.h you would have to
>
> #define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
>
> and add a device driver table, see e.g, cpukit/pppd/example/system.h
>   
FWIW at Eric Norum's suggestion, I just added
CONFIGURE_APPLICATION_EXTRA_DRIVERS to CVS head and 4.8.
This lets you insert driver entries at the end of the table.
Not a big deal but it should reduce the number of reasons to
write your own driver table.
> BTW: AFAIK, hello normally uses a minimal configuration w/o a
> clock driver but the gdb stub probably won't work w/o a clock.
> Thus, make sure you add CLOCK_DRIVER_TABLE_ENTRY to
> the device driver table.
>
>   
>> 2) Is my test program correct?
>> The source codes are attached at last.
>>   
>>     
> I believe the tty driver creates file-system entries /dev/ttyS1 (and 
> /dev/ttyS2
> if the second device is configured). Hence, you'd have to call
>
> rtems_gdb_start(0, "/dev/ttyS1")
>
> Also, you might want to insert a breakpoint - otherwise
> your application executes to the end before you have a chance
> to attach the debugger and interrupt the program.
>
> Just call
>
> rtems_gdb_breakpoint()
>
> (anywhere after rtems_gdb_start())
>   
>> 3) Why no debugging symbols found in the hello.exe although flag -g was used?
>>   
>>     
> Has been answered already; you want to use 'hello.nxe'.
>
> HTH
> -- Till
>
> (PS: could you get the network driver working? I still have to look
> at the binaries you sent -- just haven't found the time yet, sorry)
>   
>> ian at IanVM-1:~/src/examples-4.7.1/hello4gdb> /opt/gdb-6.5/i386-rtems-gdb
>> GNU gdb 6.5
>> Copyright (C) 2006 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 "--host=i686-pc-linux-gnu --target=i386-ssrl-rtems".
>> (gdb) file ./o-optimize/hello.exe
>> Reading symbols from /home/ian/src/examples-4.7.1/hello4gdb/o-optimize/hello.exe...(no debugging symbols found)...done.
>>
>>
>>
>> More Information
>> ================
>>
>> -------------------
>> RTEMS Configuration
>> -------------------
>> My host is Suse-10.1 with RTEMS-4.7.1 that configured as
>> ian at IanVM-1:~/rtems/b-rtems_debug> ../../src/rtems-4.7.1/configure --target=i386-rtems4.7 --quiet --enable-posix --enable-networking --enable-cxx --enable-rtemsbsp=pc386 --enable-rdbg --prefix=/home/ian/rtems/rtems_debug-4.7.1 CFLAGS=-fno-strict-aliasing
>>
>>
>> ----------------
>> GDB and the Stub
>> ----------------
>> I installed GDB 6.5 with patches of GDB stub for RTEMS 1.4(http://www.slac.stanford.edu/~strauman/rtems/gdb/RTEMS_gdb_stub_1_4.tgz) and the GDB stub for RTEMS without using Cexp or libbspext.
>> I also installed libbspExt-1.3beta and "bsd_eth_drivers" from Till , because they were required while building my simple hello-world test.
>>
>>
>> -----------------------------
>> About the two Vitual Machines
>> -----------------------------
>> One is the host that has RTEMS developing tools, the other is the target where RTEMS hello-world runs. They are connected with a serial line (a virtual line provided by the VMware workstation).
>>
>>
>> -------------------
>> Output of hello.exe
>> -------------------
>> Initialized console on port CONSOLE
>>
>> List of dir /:
>> name			inode	offset	reclen	type
>> dev					2		0		268i
>> List of dir /dev/:
>> name			inode	offset	reclen	type
>> console				8		0		268i
>> Task App Enter
>> GDB daemon (Release $Name: RTEMS_gdb_stub_1_4 $): starting up
>>
>> *** HELLO WORLD TEST ***
>> Hello World
>> *** END OF HELLO WORLD TEST ***
>> Task App Exit
>> GDB daemon - opening tty: No such file or directory
>> GDB daemon: shutting down
>>
>>
>> ------------------------
>> Souce Codes of hello.exe
>> ------------------------
>>
>>
>> ian at IanVM-1:~/src/examples-4.7.1/hello4gdb> cat test.c
>> -------------------------------------------------------
>> /*
>>  *      Simple test program -- simplified version of sample test hello.
>>  */
>>
>> #define TEST_INIT
>> #include <tmacros.h>
>>
>> #include <bsp.h>
>>
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <sys/types.h>
>> #include <fcntl.h>
>> #include <dirent.h>
>> #include <errno.h>
>> #include <string.h>
>>
>> #include <rtems/rtems_bsdnet.h>
>> #include <rtems-gdb-stub.h>
>> #include <bsp/bspExt.h>
>>
>> #include "networkconfig.h"
>>
>> #define TASK_PRIORITY_APP 4
>>
>> void printdir(char *dir_name)
>> {
>>         struct dirent *d;
>>         DIR *dir;
>>
>>         if (dir_name == NULL) {
>>                 printf("NULL dir name\n");
>>                 return;
>>         }
>>
>>         dir = opendir(dir_name);
>>         if (dir == NULL) {
>>                 printf("open dir %s failed:%s\n", dir_name, strerror(errno));
>>                 return;
>>         }
>>
>>         printf("List of dir %s:\n", dir_name);
>>         printf( "%-20s %8s %8s %8s %4s\n",
>>                  "name", "      inode", " offset", "reclen", " type" );
>>         d = readdir(dir);
>>
>>         while (d) {
>>                 printf( "%-20s %8d %8d %6di\n",
>>                          d->d_name, (int)d->d_ino, (int)d->d_off, d->d_reclen);
>>                 d = readdir(dir);
>>         }
>>
>>         return;
>> }
>>
>>
>> rtems_task
>> app_task (rtems_task_argument ignored)
>> {
>>         rtems_status_code ret;
>>
>>         printf("Task App Enter\n");
>>
>>
>>         rtems_gdb_start(0, "/dev/ttyS0");
>>
>>         printf( "\n\n*** HELLO WORLD TEST ***\n" );
>>         printf( "Hello World\n" );
>>         printf( "*** END OF HELLO WORLD TEST ***\n" );
>>
>>         /* delete myself and exit */
>>         printf("Task App Exit\n");
>>         ret = rtems_task_delete(RTEMS_SELF);
>>         directive_failed(ret, "Delete task App");
>> }
>>
>> rtems_task Init(
>>         rtems_task_argument ignored
>> )
>> {
>>         rtems_name app_name;
>>         rtems_id app_id;
>>         rtems_status_code ret;
>>
>>         printdir("/");
>>         printdir("/dev/");
>>
>>         /* create and start application task */
>>         app_name = rtems_build_name('a', 'p', 'p', '0');
>>         ret = rtems_task_create(app_name,
>>                         TASK_PRIORITY_APP,
>>                         RTEMS_MINIMUM_STACK_SIZE,
>>                         RTEMS_DEFAULT_MODES,
>>                         RTEMS_DEFAULT_ATTRIBUTES,
>>                         &app_id);
>>         directive_failed(ret, "Create task App");
>>
>>         ret = rtems_task_start(app_id, app_task, 0);
>>         directive_failed(ret, "Start task App");
>>
>>         /* delete myself and exit */
>>         ret = rtems_task_delete(RTEMS_SELF);
>>         directive_failed(ret, "Delete task Init");
>> }
>>
>> /* configuration information */
>>
>> #define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
>> #define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
>> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>> #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
>> #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
>> #define CONFIGURE_MAXIMUM_TASKS 4
>> #define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
>>
>> #define CONFIGURE_INIT
>>
>> #include <rtems/confdefs.h>
>>
>> /* end of file */
>>
>>
>> ian at IanVM-1:~/src/examples-4.7.1/hello4gdb> cat Makefile
>> --------------------------------------------------------
>> #
>> #  $Id: Makefile,v 1.4 1998/08/21 13:26:05 joel Exp $
>> #
>>
>> SAMPLE=hello
>> PGM=${ARCH}/$(SAMPLE).exe
>>
>> MANAGERS=all
>>
>> # C source names, if any, go here -- minus the .c
>> C_PIECES= test
>> C_FILES=$(C_PIECES:%=%.c)
>> C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
>>
>> H_FILES=
>>
>> DOCTYPES=
>> DOCS=$(DOCTYPES:%=$(SAMPLE).%)
>>
>> SRCS=$(DOCS) $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
>> OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
>>
>> PRINT_SRCS=$(DOCS)
>>
>> PGM=${ARCH}/$(SAMPLE).exe
>>
>> include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
>> include $(RTEMS_CUSTOM)
>> include $(PROJECT_ROOT)/make/leaf.cfg
>>
>> #
>> # (OPTIONAL) Add local stuff here using +=
>> #
>>
>> DEFINES  +=
>> CPPFLAGS +=
>> CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000
>> CFLAGS_OPTIMIZE_V   +=
>> CFLAGS_DEBUG_V   += -v -qrtems_debug
>>
>> CFLAGS_LD += -g
>>
>>
>> CFLAGS   += -fno-strict-aliasing -O
>> CFLAGS   += -I${RTEMS_MAKEFILE_PATH}/include
>> CFLAGS   += -I/home/ian/src/examples-4.7.1/test_includes
>> CFLAGS   += -g
>> CFLAGS   += -Wall
>>
>> #OP_SYS_LDFLAGS = -g
>>
>> LD_PATHS  += -L${RTEMS_MAKEFILE_PATH}/lib
>> #LD_LIBS   += -lif_le -lbsdport -lbspExt
>> LD_LIBS   += -lrtems-gdb-stub -lif_le -lbsdport -lbspExt
>> #LD_LIBS   += -lrtems-gdb-stub
>> LIBS   +=  -lrtemsall -lc
>>
>> #
>> # Add your list of files to delete here.  The config files
>> #  already know how to delete some stuff, so you may want
>> #  to just run 'make clean' first to see what gets missed.
>> #  'make clobber' already includes 'make clean'
>> #
>>
>> CLEAN_ADDITIONS +=
>> CLOBBER_ADDITIONS +=
>>
>> all:    ${ARCH} $(SRCS) $(PGM)
>>
>> ${PGM}: $(OBJS) $(LINK_FILES)
>>         $(make-exe)
>>
>> # Install the program(s), appending _g or _p as appropriate.
>> # for include files, just use $(INSTALL)
>> install:  all
>>         $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
>>
>>
>> ian at IanVM-1:~/src/examples-4.7.1/hello4gdb> cat networkconfig.h
>> ---------------------------------------------------------------
>> /*
>>  * Network configuration
>>  *
>>  ************************************************************
>>  * EDIT THIS FILE TO REFLECT YOUR NETWORK CONFIGURATION     *
>>  * BEFORE RUNNING ANY RTEMS PROGRAMS WHICH USE THE NETWORK! *
>>  ************************************************************
>>  *
>>  *  $Id: networkconfig.h,v 1.8 2001/08/31 18:11:43 joel Exp $
>>  */
>>
>> #ifndef _RTEMS_NETWORKCONFIG_H_
>> #define _RTEMS_NETWORKCONFIG_H_
>>
>> //#define USE_QEMU
>>
>>
>> /*
>>  *  The following will normally be set by the BSP if it supports
>>  *  a single network device driver.  In the event, it supports
>>  *  multiple network device drivers, then the user's default
>>  *  network device driver will have to be selected by a BSP
>>  *  specific mechanism.
>>  */
>>
>> #ifdef RTEMS_BSP_NETWORK_DRIVER_NAME
>> #undef RTEMS_BSP_NETWORK_DRIVER_NAME
>> #endif
>> #ifdef USE_QEMU
>> #define RTEMS_BSP_NETWORK_DRIVER_NAME BSP_NE2000_NETWORK_DRIVER_NAME
>> #else
>> #define RTEMS_BSP_NETWORK_DRIVER_NAME "le1"
>> #endif
>>
>>
>>
>> #ifdef RTEMS_BSP_NETWORK_DRIVER_ATTACH
>> #undef RTEMS_BSP_NETWORK_DRIVER_ATTACH
>> #endif
>>
>> #ifdef USE_QEMU
>> #define RTEMS_BSP_NETWORK_DRIVER_ATTACH BSP_NE2000_NETWORK_DRIVER_ATTACH
>> #else
>> #define RTEMS_BSP_NETWORK_DRIVER_ATTACH libbsdport_netdriver_attach
>> #endif
>>
>> #include <rtems/pci.h>
>> #include <rtems/irq.h>
>>
>> #ifndef USE_QEMU
>> #include <bsp/libbsdport_api.h>
>> extern driver_t libbsdport_le_pci_driver;
>>
>> driver_t *libbsdport_netdriver_table[] = {
>>         &libbsdport_le_pci_driver,
>>         /* other drivers here or upstream of 'le' if they support
>>         * the same hardware but are preferred.
>>         */
>>         0
>> };
>> #endif
>>
>> /* #define RTEMS_USE_BOOTP */
>>
>> #include <bsp.h>
>>
>> /*
>>  * Define RTEMS_SET_ETHERNET_ADDRESS if you want to specify the
>>  * Ethernet address here.  If RTEMS_SET_ETHERNET_ADDRESS is not
>>  * defined the driver will choose an address.
>>  */
>> #ifndef USE_QEMU
>> #define RTEMS_SET_ETHERNET_ADDRESS
>> #endif
>> #if (defined (RTEMS_SET_ETHERNET_ADDRESS))
>> /* static char ethernet_address[6] = { 0x08, 0x00, 0x3e, 0x12, 0x28, 0xb1 }; */
>> static char ethernet_address[6] = { 0x00, 0x80, 0x7F, 0x22, 0x61, 0x77 };
>>
>> #endif
>>
>> #ifdef RTEMS_USE_LOOPBACK
>> /*
>>  * Loopback interface
>>  */
>> extern void rtems_bsdnet_loopattach();
>> static struct rtems_bsdnet_ifconfig loopback_config = {
>>         "lo0",                          /* name */
>>         rtems_bsdnet_loopattach,        /* attach function */
>>
>>         NULL,                           /* link to next interface */
>>
>>         "127.0.0.1",                    /* IP address */
>>         "255.0.0.0",                    /* IP net mask */
>> };
>> #endif
>>
>>
>> /*
>>  * Default network interface
>>  */
>> static struct rtems_bsdnet_ifconfig netdriver_config = {
>>         RTEMS_BSP_NETWORK_DRIVER_NAME,          /* name */
>>         RTEMS_BSP_NETWORK_DRIVER_ATTACH,        /* attach function */
>>
>>
>> #ifdef RTEMS_USE_LOOPBACK
>>         &loopback_config,               /* link to next interface */
>> #else
>>         NULL,                           /* No more interfaces */
>> #endif
>>
>> #if (defined (RTEMS_USE_BOOTP))
>>         NULL,                           /* BOOTP supplies IP address */
>>         NULL,                           /* BOOTP supplies IP net mask */
>> #else
>>         //"XXX.YYY.ZZZ.XYZ",            /* IP address */
>>
>> #ifdef USE_QEMU
>>         "192.168.10.230",               /* IP address */
>> #else
>>         "192.168.1.230",                /* IP address */
>> #endif
>>
>>         "255.255.255.0",                /* IP net mask */
>> #endif /* !RTEMS_USE_BOOTP */
>>
>> #if (defined (RTEMS_SET_ETHERNET_ADDRESS))
>>         ethernet_address,               /* Ethernet hardware address */
>> #else
>>         NULL,                           /* Driver supplies hardware address */
>> #endif
>>
>>
>> #ifndef USE_QEMU
>>         0                               /* Use default driver parameters */
>> #else
>>         0,                              /* Use default driver parameters */
>>         0,
>>         0,
>>         0,
>>
>>         0x300,
>>         9,
>>         0
>> #endif
>> };
>>
>> /*
>>  * Network configuration
>>  */
>> struct rtems_bsdnet_config rtems_bsdnet_config = {
>>         &netdriver_config,
>>
>> #if (defined (RTEMS_USE_BOOTP))
>>         rtems_bsdnet_do_bootp,
>> #else
>>         NULL,
>> #endif
>>
>>         0,                      /* Default network task priority */
>>         0,                      /* Default mbuf capacity */
>>         0,                      /* Default mbuf cluster capacity */
>>
>> #if (!defined (RTEMS_USE_BOOTP))
>>         "IanVM-N0",             /* Host name */
>>         "nodomain.com",         /* Domain name */
>>         "192.168.1.254",        /* Gateway */
>>         "192.168.1.241",        /* Log host */
>>         {"192.168.1.106" },     /* Name server(s) */
>>         {"192.168.1.241" },     /* NTP server(s) */
>>
>>         /*
>>          *  A real example -- DO NOT USE THIS YOURSELF!!!
>>          */
>>
>> #if 0
>>         "dy4",                  /* Host name */
>>         "NOT_oarcorp.com",      /* Domain name */
>>         "192.168.1.2",          /* Gateway */
>>         "192.168.1.2",          /* Log host */
>>         {"192.168.1.2" },       /* Name server(s) */
>>         {"192.168.1.2" },       /* NTP server(s) */
>> #endif
>> #endif /* !RTEMS_USE_BOOTP */
>>
>> };
>>
>> /*
>>  * For TFTP test application
>>  */
>> #if (defined (RTEMS_USE_BOOTP))
>> #define RTEMS_TFTP_TEST_HOST_NAME "BOOTP_HOST"
>> #define RTEMS_TFTP_TEST_FILE_NAME "BOOTP_FILE"
>> #else
>> #define RTEMS_TFTP_TEST_HOST_NAME "XXX.YYY.ZZZ.XYZ"
>> #define RTEMS_TFTP_TEST_FILE_NAME "tftptest"
>> #endif
>>
>> #endif /* _RTEMS_NETWORKCONFIG_H_ */
>>
>>
>>
>>
>>
>>
>>  				
>> --------------
>> Ian Jiang
>> ianjiang.cn at gmail.com
>> 2007-11-27 20:09:23
>>
>> _______________________________________________
>> rtems-users mailing list
>> rtems-users at rtems.com
>> http://rtems.rtems.org/mailman/listinfo/rtems-users
>>   
>>     
>
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>