forked from Imagelibrary/rtems
* capture/capture-cli.c: Add config-header support. * capture/capture.c: Add config-header support. * cpuuse/cpuuse.c: Add config-header support. * devnull/devnull.c: Add config-header support. * dummy/dummy.c: Add config-header support. * dumpbuf/dumpbuf.c: Add config-header support. * monitor/mon-command.c: Add config-header support. * monitor/mon-config.c: Add config-header support. * monitor/mon-dname.c: Add config-header support. * monitor/mon-driver.c: Add config-header support. * monitor/mon-extension.c: Add config-header support. * monitor/mon-itask.c: Add config-header support. * monitor/mon-manager.c: Add config-header support. * monitor/mon-monitor.c: Add config-header support. * monitor/mon-mpci.c: Add config-header support. * monitor/mon-object.c: Add config-header support. * monitor/mon-prmisc.c: Add config-header support. * monitor/mon-queue.c: Add config-header support. * monitor/mon-server.c: Add config-header support. * monitor/mon-symbols.c: Add config-header support. * monitor/mon-task.c: Add config-header support. * mw-fb/mw_fb.c: Add config-header support. * mw-fb/mw_uid.c: Add config-header support. * rtmonuse/rtmonuse.c: Add config-header support. * serdbg/serdbg.c: Add config-header support. * serdbg/serdbgio.c: Add config-header support. * serdbg/termios_printk.c: Add config-header support. * shell/cmds.c: Add config-header support. * stackchk/check.c: Add config-header support. * untar/untar.c: Add config-header support.
96 lines
3.3 KiB
C
96 lines
3.3 KiB
C
/*===============================================================*\
|
|
| 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$
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#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;
|
|
}
|
|
|