diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2002-06-27 21:25:14 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2002-06-27 21:25:14 +0000 |
commit | 9e633f58da0e7a5e07da0becdd81b43ab2ea227c (patch) | |
tree | 9600a2157eec583dabde35d2eba10a47268a64f8 /c/src/libmisc/serdbg/serdbg.c | |
parent | 2002-06-27 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-9e633f58da0e7a5e07da0becdd81b43ab2ea227c.tar.bz2 |
2002-06-25 Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
* With the addition of serdbg, the standard polled I/O functions
for gdbstub and/or printk are optionally routed to any termios-aware
device driver, that supports polled mode. See libmisc/serdbg/README.
* serdbg/Makefile.am, serdbg/README, serdbg/serdbg.c, serdbg/serdbg.h,
serdbg/serdbgcnf.h, serdbg/serdbgio.c, serdbg/termios_printk.c,
serdbg/termios_printk.h, serdbg/termios_printk_cnf.h,
serdbg/.cvsignore: New files.
* configure.ac, Makefile.am, wrapup/Makefile.am: Modified to
reflect addition.
Diffstat (limited to 'c/src/libmisc/serdbg/serdbg.c')
-rw-r--r-- | c/src/libmisc/serdbg/serdbg.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/c/src/libmisc/serdbg/serdbg.c b/c/src/libmisc/serdbg/serdbg.c new file mode 100644 index 0000000000..2f459c73de --- /dev/null +++ b/c/src/libmisc/serdbg/serdbg.c @@ -0,0 +1,90 @@ +/*===============================================================*\ +| Project: RTEMS remote gdb over serial line | ++-----------------------------------------------------------------+ +| File: serdbg.c | ++-----------------------------------------------------------------+ +| Copyright (c) 2002 IMD | +| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | +| <Thomas.Doerfler@imd-systems.de> | +| all rights reserved | ++-----------------------------------------------------------------+ +| this file contains intialization and utility functions to add | +| a gdb remote debug stub to an RTEMS system | +| | ++-----------------------------------------------------------------+ +| date history ID | +| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | +| 04.04.02 creation doe | +\*===============================================================*/ +/* + * $Id$ + */ +#include <rtems.h> +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <serdbg.h> + + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +int serdbg_init_dbg +( +/*-------------------------------------------------------------------------*\ +| Purpose: | +| initialize remote gdb session over serial line | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ + void +) +/*-------------------------------------------------------------------------*\ +| Return Value: | +| rtems_status_code | +\*=========================================================================*/ +{ + static boolean is_initialized = FALSE; + + rtems_status_code rc = RTEMS_SUCCESSFUL; + extern void set_debug_traps(void); + extern void breakpoint(void); + + if (is_initialized) { + return RTEMS_SUCCESSFUL; + } + is_initialized = TRUE; + /* + * try to open serial device + */ + if (rc == RTEMS_SUCCESSFUL) { + if ((serdbg_conf.open_io != NULL) && + (0 > serdbg_conf.open_io(serdbg_conf.devname,serdbg_conf.baudrate))) { + fprintf(stderr, + "remote_gdb_init: cannot open device %s " + "for gdb connection:%s\n",serdbg_conf.devname,strerror(errno)); + rc = RTEMS_IO_ERROR; + } + } + /* + * initialize gdb stub + */ + if (rc == RTEMS_SUCCESSFUL) { + set_debug_traps(); + } + /* + * now activate gdb stub + */ + if ((rc == RTEMS_SUCCESSFUL) && + !serdbg_conf.skip_init_bkpt) { + breakpoint(); + } + + /* + * return to original function + * this may be already unter gdb control + */ + return rc; +} + |