OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [mi/] [mi-cmd-break.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* MI Command Set - breakpoint and watchpoint commands.
2
   Copyright (C) 2000, Free Software Foundation, Inc.
3
   Contributed by Cygnus Solutions (a Red Hat company).
4
 
5
   This file is part of GDB.
6
 
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 2 of the License, or
10
   (at your option) any later version.
11
 
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
 
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 59 Temple Place - Suite 330,
20
   Boston, MA 02111-1307, USA.  */
21
 
22
#include "defs.h"
23
#include "mi-cmds.h"
24
#include "ui-out.h"
25
#include "mi-out.h"
26
#include "breakpoint.h"
27
#include "gdb_string.h"
28
#include "mi-getopt.h"
29
#include "gdb-events.h"
30
 
31
/* Convenience macro for allocting typesafe memory. */
32
 
33
#undef XMALLOC
34
#define XMALLOC(TYPE) (TYPE*) xmalloc (sizeof (TYPE))
35
 
36
enum
37
  {
38
    FROM_TTY = 0
39
  };
40
 
41
/* Output a single breakpoint. */
42
 
43
static void
44
breakpoint_notify (int b)
45
{
46
  gdb_breakpoint_query (b);
47
}
48
 
49
 
50
struct gdb_events breakpoint_hooks =
51
{
52
  breakpoint_notify,
53
  breakpoint_notify,
54
  breakpoint_notify,
55
};
56
 
57
 
58
enum bp_type
59
  {
60
    REG_BP,
61
    HW_BP,
62
    REGEXP_BP
63
  };
64
 
65
/* Insert a breakpoint. The type of breakpoint is specified by the
66
   first argument: -break-insert <location> --> insert a regular
67
   breakpoint.  -break-insert -t <location> --> insert a temporary
68
   breakpoint.  -break-insert -h <location> --> insert an hardware
69
   breakpoint.  -break-insert -t -h <location> --> insert a temporary
70
   hw bp.
71
   -break-insert -r <regexp> --> insert a bp at functions matching
72
   <regexp> */
73
 
74
enum mi_cmd_result
75
mi_cmd_break_insert (char *command, char **argv, int argc)
76
{
77
  char *address = NULL;
78
  enum bp_type type = REG_BP;
79
  int temp_p = 0;
80
  int thread = -1;
81
  int ignore_count = 0;
82
  char *condition = NULL;
83
  enum gdb_rc rc;
84
  struct gdb_events *old_hooks;
85
  enum opt
86
    {
87
      HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT,
88
      IGNORE_COUNT_OPT, THREAD_OPT
89
    };
90
  static struct mi_opt opts[] =
91
  {
92
    {"h", HARDWARE_OPT, 0},
93
    {"t", TEMP_OPT, 0},
94
    {"c", CONDITION_OPT, 1},
95
    {"i", IGNORE_COUNT_OPT, 1},
96
    {"p", THREAD_OPT, 1},
97
 
98
  };
99
 
100
  /* Parse arguments. It could be -r or -h or -t, <location> or ``--''
101
     to denote the end of the option list. */
102
  int optind = 0;
103
  char *optarg;
104
  while (1)
105
    {
106
      int opt = mi_getopt ("mi_cmd_break_insert", argc, argv, opts, &optind, &optarg);
107
      if (opt < 0)
108
        break;
109
      switch ((enum opt) opt)
110
        {
111
        case TEMP_OPT:
112
          temp_p = 1;
113
          break;
114
        case HARDWARE_OPT:
115
          type = HW_BP;
116
          break;
117
#if 0
118
        case REGEXP_OPT:
119
          type = REGEXP_BP;
120
          break;
121
#endif
122
        case CONDITION_OPT:
123
          condition = optarg;
124
          break;
125
        case IGNORE_COUNT_OPT:
126
          ignore_count = atol (optarg);
127
          break;
128
        case THREAD_OPT:
129
          thread = atol (optarg);
130
          break;
131
        }
132
    }
133
 
134
  if (optind >= argc)
135
    error ("mi_cmd_break_insert: Missing <location>");
136
  if (optind < argc - 1)
137
    error ("mi_cmd_break_insert: Garbage following <location>");
138
  address = argv[optind];
139
 
140
  /* Now we have what we need, let's insert the breakpoint! */
141
  old_hooks = set_gdb_event_hooks (&breakpoint_hooks);
142
  switch (type)
143
    {
144
    case REG_BP:
145
      rc = gdb_breakpoint (address, condition,
146
 
147
                           thread, ignore_count);
148
      break;
149
    case HW_BP:
150
      rc = gdb_breakpoint (address, condition,
151
                           1 /*hardwareflag */ , temp_p,
152
                           thread, ignore_count);
153
      break;
154
#if 0
155
    case REGEXP_BP:
156
      if (temp_p)
157
        error ("mi_cmd_break_insert: Unsupported tempoary regexp breakpoint");
158
      else
159
        rbreak_command_wrapper (address, FROM_TTY);
160
      return MI_CMD_DONE;
161
      break;
162
#endif
163
    default:
164
      internal_error ("mi_cmd_break_insert: Bad switch.");
165
    }
166
  set_gdb_event_hooks (old_hooks);
167
 
168
  if (rc == GDB_RC_FAIL)
169
    return MI_CMD_CAUGHT_ERROR;
170
  else
171
    return MI_CMD_DONE;
172
}
173
 
174
enum wp_type
175
{
176
  REG_WP,
177
  READ_WP,
178
  ACCESS_WP
179
};
180
 
181
/* Insert a watchpoint. The type of watchpoint is specified by the
182
   first argument:
183
   -break-watch <expr> --> insert a regular wp.
184
   -break-watch -r <expr> --> insert a read watchpoint.
185
   -break-watch -a <expr> --> insert an access wp. */
186
 
187
enum mi_cmd_result
188
mi_cmd_break_watch (char *command, char **argv, int argc)
189
{
190
  char *expr = NULL;
191
  enum wp_type type = REG_WP;
192
  enum opt
193
    {
194
      READ_OPT, ACCESS_OPT
195
    };
196
  static struct mi_opt opts[] =
197
  {
198
    {"r", READ_OPT, 0},
199
    {"a", ACCESS_OPT, 0},
200
 
201
  };
202
 
203
  /* Parse arguments. */
204
  int optind = 0;
205
  char *optarg;
206
  while (1)
207
    {
208
      int opt = mi_getopt ("mi_cmd_break_watch", argc, argv, opts, &optind, &optarg);
209
      if (opt < 0)
210
        break;
211
      switch ((enum opt) opt)
212
        {
213
        case READ_OPT:
214
          type = READ_WP;
215
          break;
216
        case ACCESS_OPT:
217
          type = ACCESS_WP;
218
          break;
219
        }
220
    }
221
  if (optind >= argc)
222
    error ("mi_cmd_break_watch: Missing <expression>");
223
  if (optind < argc - 1)
224
    error ("mi_cmd_break_watch: Garbage following <expression>");
225
  expr = argv[optind];
226
 
227
  /* Now we have what we need, let's insert the watchpoint! */
228
  switch (type)
229
    {
230
    case REG_WP:
231
#ifdef UI_OUT
232
      watch_command_wrapper (expr, FROM_TTY);
233
#endif
234
      break;
235
    case READ_WP:
236
#ifdef UI_OUT
237
      rwatch_command_wrapper (expr, FROM_TTY);
238
#endif
239
      break;
240
    case ACCESS_WP:
241
#ifdef UI_OUT
242
      awatch_command_wrapper (expr, FROM_TTY);
243
#endif
244
      break;
245
    default:
246
      error ("mi_cmd_break_watch: Unknown watchpoint type.");
247
    }
248
  return MI_CMD_DONE;
249
}
250
 
251
/* Local variables: */
252
/* change-log-default-name: "ChangeLog-mi" */
253
/* End: */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.