source: rtems/cpukit/libmisc/serdbg/serdbg.c @ aed742c

4.104.114.84.95
Last change on this file since aed742c was aed742c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/16/04 at 12:06:28

Remove stray white spaces.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*===============================================================*\
2| Project: RTEMS remote gdb over serial line                      |
3+-----------------------------------------------------------------+
4| File: serdbg.c                                                  |
5+-----------------------------------------------------------------+
6|                    Copyright (c) 2002 IMD                       |
7|      Ingenieurbuero fuer Microcomputertechnik Th. Doerfler      |
8|               <Thomas.Doerfler@imd-systems.de>                  |
9|                       all rights reserved                       |
10+-----------------------------------------------------------------+
11| this file contains intialization and utility functions to add   |
12| a gdb remote debug stub to an RTEMS system                      |
13|                                                                 |
14+-----------------------------------------------------------------+
15|   date                      history                        ID   |
16| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
17| 04.04.02  creation                                         doe  |
18\*===============================================================*/
19/*
20 * $Id$
21 */
22
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <rtems.h>
28#include <stdio.h>
29#include <string.h>
30#include <fcntl.h>
31#include <errno.h>
32#include <rtems/serdbg.h>
33
34
35/*=========================================================================*\
36| Function:                                                                 |
37\*-------------------------------------------------------------------------*/
38int serdbg_init_dbg
39(
40/*-------------------------------------------------------------------------*\
41| Purpose:                                                                  |
42|   initialize remote gdb session over serial line                          |
43+---------------------------------------------------------------------------+
44| Input Parameters:                                                         |
45\*-------------------------------------------------------------------------*/
46 void
47)
48/*-------------------------------------------------------------------------*\
49| Return Value:                                                             |
50|    rtems_status_code                                                      |
51\*=========================================================================*/
52{
53  static boolean is_initialized = FALSE;
54
55  rtems_status_code rc = RTEMS_SUCCESSFUL;
56  extern void set_debug_traps(void);
57  extern void breakpoint(void);
58
59  if (is_initialized) {
60    return RTEMS_SUCCESSFUL;
61  }
62  is_initialized = TRUE;
63  /*
64   * try to open serial device
65   */
66  if (rc == RTEMS_SUCCESSFUL) {
67    if ((serdbg_conf.open_io != NULL) &&
68        (0 > serdbg_conf.open_io(serdbg_conf.devname,serdbg_conf.baudrate))) {
69      fprintf(stderr,
70              "remote_gdb_init: cannot open device %s "
71              "for gdb connection:%s\n",serdbg_conf.devname,strerror(errno));
72      rc = RTEMS_IO_ERROR;
73    }
74  }
75  /*
76   * initialize gdb stub
77   */
78  if (rc == RTEMS_SUCCESSFUL) {
79    set_debug_traps();
80  }
81  /*
82   * now activate gdb stub
83   */
84  if ((rc == RTEMS_SUCCESSFUL) &&
85      !serdbg_conf.skip_init_bkpt) {
86    breakpoint();
87  }
88
89  /*
90   * return to original function
91   * this may be already unter gdb control
92   */
93  return rc;
94}
Note: See TracBrowser for help on using the repository browser.