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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [gdb/] [mi/] [mi-cmds.c] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
/* MI Command Set for GDB, the GNU debugger.
2
 
3
   Copyright (C) 2000, 2001, 2003, 2007, 2008 Free Software Foundation, Inc.
4
 
5
   Contributed by Cygnus Solutions (a Red Hat company).
6
 
7
   This file is part of GDB.
8
 
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3 of the License, or
12
   (at your option) any later version.
13
 
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
 
19
   You should have received a copy of the GNU General Public License
20
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
 
22
#include "defs.h"
23
#include "top.h"
24
#include "mi-cmds.h"
25
#include "gdb_string.h"
26
 
27
extern void _initialize_mi_cmds (void);
28
struct mi_cmd;
29
static struct mi_cmd **lookup_table (const char *command);
30
static void build_table (struct mi_cmd *commands);
31
 
32
 
33
struct mi_cmd mi_cmds[] =
34
{
35
  { "break-after", { "ignore", 1 }, NULL, NULL },
36
  { "break-catch", { NULL, 0 }, NULL, NULL },
37
  { "break-commands", { NULL, 0 }, NULL, NULL },
38
  { "break-condition", { "cond", 1 }, NULL, NULL },
39
  { "break-delete", { "delete breakpoint", 1 }, NULL, NULL },
40
  { "break-disable", { "disable breakpoint", 1 }, NULL, NULL },
41
  { "break-enable", { "enable breakpoint", 1 }, NULL, NULL },
42
  { "break-info", { "info break", 1 }, NULL, NULL },
43
  { "break-insert", { NULL, 0 }, 0, mi_cmd_break_insert},
44
  { "break-list", { "info break", }, NULL, NULL },
45
  { "break-watch", { NULL, 0 }, 0, mi_cmd_break_watch},
46
  { "data-disassemble", { NULL, 0 }, 0, mi_cmd_disassemble},
47
  { "data-evaluate-expression", { NULL, 0 }, 0, mi_cmd_data_evaluate_expression},
48
  { "data-list-changed-registers", { NULL, 0 }, 0, mi_cmd_data_list_changed_registers},
49
  { "data-list-register-names", { NULL, 0 }, 0, mi_cmd_data_list_register_names},
50
  { "data-list-register-values", { NULL, 0 }, 0, mi_cmd_data_list_register_values},
51
  { "data-read-memory", { NULL, 0 }, 0, mi_cmd_data_read_memory},
52
  { "data-write-memory", { NULL, 0 }, 0, mi_cmd_data_write_memory},
53
  { "data-write-register-values", { NULL, 0 }, 0, mi_cmd_data_write_register_values},
54
  { "enable-timings", { NULL, 0 }, 0, mi_cmd_enable_timings},
55
  { "environment-cd", { NULL, 0 }, 0, mi_cmd_env_cd},
56
  { "environment-directory", { NULL, 0 }, 0, mi_cmd_env_dir},
57
  { "environment-path", { NULL, 0 }, 0, mi_cmd_env_path},
58
  { "environment-pwd", { NULL, 0 }, 0, mi_cmd_env_pwd},
59
  { "exec-abort", { NULL, 0 }, NULL, NULL },
60
  { "exec-arguments", { "set args", 1 }, NULL, NULL },
61
  { "exec-continue", { NULL, 0 }, mi_cmd_exec_continue},
62
  { "exec-finish", { NULL, 0 }, mi_cmd_exec_finish},
63
  { "exec-interrupt", { NULL, 0 }, mi_cmd_exec_interrupt},
64
  { "exec-next", { NULL, 0 }, mi_cmd_exec_next},
65
  { "exec-next-instruction", { NULL, 0 }, mi_cmd_exec_next_instruction},
66
  { "exec-return", { NULL, 0 }, mi_cmd_exec_return},
67
  { "exec-run", { NULL, 0 }, mi_cmd_exec_run},
68
  { "exec-show-arguments", { NULL, 0 }, NULL, NULL },
69
  { "exec-signal", { NULL, 0 }, NULL, NULL },
70
  { "exec-step", { NULL, 0 }, mi_cmd_exec_step},
71
  { "exec-step-instruction", { NULL, 0 }, mi_cmd_exec_step_instruction},
72
  { "exec-until", { NULL, 0 }, mi_cmd_exec_until},
73
  { "file-clear", { NULL, 0 }, NULL, NULL },
74
  { "file-exec-and-symbols", { "file", 1 }, NULL, NULL },
75
  { "file-exec-file", { "exec-file", 1 }, NULL, NULL },
76
  { "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
77
  { "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
78
  { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files },
79
  { "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
80
  { "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
81
  { "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
82
  { "gdb-complete", { NULL, 0 }, NULL, NULL },
83
  { "gdb-exit", { NULL, 0 }, 0, mi_cmd_gdb_exit},
84
  { "gdb-set", { "set", 1 }, NULL, NULL },
85
  { "gdb-show", { "show", 1 }, NULL, NULL },
86
  { "gdb-source", { NULL, 0 }, NULL, NULL },
87
  { "gdb-version", { "show version", 0 }, 0 },
88
  { "inferior-tty-set", { NULL, 0 }, NULL, mi_cmd_inferior_tty_set},
89
  { "inferior-tty-show", { NULL, 0 }, NULL, mi_cmd_inferior_tty_show},
90
  { "interpreter-exec", { NULL, 0 }, 0, mi_cmd_interpreter_exec},
91
  { "list-features", { NULL, 0 }, 0, mi_cmd_list_features},
92
  { "overlay-auto", { NULL, 0 }, NULL, NULL },
93
  { "overlay-list-mapping-state", { NULL, 0 }, NULL, NULL },
94
  { "overlay-list-overlays", { NULL, 0 }, NULL, NULL },
95
  { "overlay-map", { NULL, 0 }, NULL, NULL },
96
  { "overlay-off", { NULL, 0 }, NULL, NULL },
97
  { "overlay-on", { NULL, 0 }, NULL, NULL },
98
  { "overlay-unmap", { NULL, 0 }, NULL, NULL },
99
  { "signal-handle", { NULL, 0 }, NULL, NULL },
100
  { "signal-list-handle-actions", { NULL, 0 }, NULL, NULL },
101
  { "signal-list-signal-types", { NULL, 0 }, NULL, NULL },
102
  { "stack-info-depth", { NULL, 0 }, 0, mi_cmd_stack_info_depth},
103
  { "stack-info-frame", { NULL, 0 }, 0, mi_cmd_stack_info_frame},
104
  { "stack-list-arguments", { NULL, 0 }, 0, mi_cmd_stack_list_args},
105
  { "stack-list-exception-handlers", { NULL, 0 }, NULL, NULL },
106
  { "stack-list-frames", { NULL, 0 }, 0, mi_cmd_stack_list_frames},
107
  { "stack-list-locals", { NULL, 0 }, 0, mi_cmd_stack_list_locals},
108
  { "stack-select-frame", { NULL, 0 }, 0, mi_cmd_stack_select_frame},
109
  { "symbol-info-address", { NULL, 0 }, NULL, NULL },
110
  { "symbol-info-file", { NULL, 0 }, NULL, NULL },
111
  { "symbol-info-function", { NULL, 0 }, NULL, NULL },
112
  { "symbol-info-line", { NULL, 0 }, NULL, NULL },
113
  { "symbol-info-symbol", { NULL, 0 }, NULL, NULL },
114
  { "symbol-list-functions", { NULL, 0 }, NULL, NULL },
115
  { "symbol-list-lines", { NULL, 0 }, 0, mi_cmd_symbol_list_lines},
116
  { "symbol-list-types", { NULL, 0 }, NULL, NULL },
117
  { "symbol-list-variables", { NULL, 0 }, NULL, NULL },
118
  { "symbol-locate", { NULL, 0 }, NULL, NULL },
119
  { "symbol-type", { NULL, 0 }, NULL, NULL },
120
  { "target-attach", { NULL, 0 }, NULL, NULL },
121
  { "target-compare-sections", { NULL, 0 }, NULL, NULL },
122
  { "target-detach", { "detach", 0 }, 0 },
123
  { "target-disconnect", { "disconnect", 0 }, 0 },
124
  { "target-download", { NULL, 0 }, mi_cmd_target_download},
125
  { "target-exec-status", { NULL, 0 }, NULL, NULL },
126
  { "target-file-delete", { NULL, 0 }, NULL, mi_cmd_target_file_delete },
127
  { "target-file-get", { NULL, 0 }, NULL, mi_cmd_target_file_get },
128
  { "target-file-put", { NULL, 0 }, NULL, mi_cmd_target_file_put },
129
  { "target-list-available-targets", { NULL, 0 }, NULL, NULL },
130
  { "target-list-current-targets", { NULL, 0 }, NULL, NULL },
131
  { "target-list-parameters", { NULL, 0 }, NULL, NULL },
132
  { "target-select", { NULL, 0 }, mi_cmd_target_select},
133
  { "thread-info", { NULL, 0 }, NULL, NULL },
134
  { "thread-list-all-threads", { NULL, 0 }, NULL, NULL },
135
  { "thread-list-ids", { NULL, 0 }, 0, mi_cmd_thread_list_ids},
136
  { "thread-select", { NULL, 0 }, 0, mi_cmd_thread_select},
137
  { "trace-actions", { NULL, 0 }, NULL, NULL },
138
  { "trace-delete", { NULL, 0 }, NULL, NULL },
139
  { "trace-disable", { NULL, 0 }, NULL, NULL },
140
  { "trace-dump", { NULL, 0 }, NULL, NULL },
141
  { "trace-enable", { NULL, 0 }, NULL, NULL },
142
  { "trace-exists", { NULL, 0 }, NULL, NULL },
143
  { "trace-find", { NULL, 0 }, NULL, NULL },
144
  { "trace-frame-number", { NULL, 0 }, NULL, NULL },
145
  { "trace-info", { NULL, 0 }, NULL, NULL },
146
  { "trace-insert", { NULL, 0 }, NULL, NULL },
147
  { "trace-list", { NULL, 0 }, NULL, NULL },
148
  { "trace-pass-count", { NULL, 0 }, NULL, NULL },
149
  { "trace-save", { NULL, 0 }, NULL, NULL },
150
  { "trace-start", { NULL, 0 }, NULL, NULL },
151
  { "trace-stop", { NULL, 0 }, NULL, NULL },
152
  { "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign},
153
  { "var-create", { NULL, 0 }, 0, mi_cmd_var_create},
154
  { "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete},
155
  { "var-evaluate-expression", { NULL, 0 }, 0, mi_cmd_var_evaluate_expression},
156
  { "var-info-path-expression", { NULL, 0 }, 0,
157
    mi_cmd_var_info_path_expression},
158
  { "var-info-expression", { NULL, 0 }, 0, mi_cmd_var_info_expression},
159
  { "var-info-num-children", { NULL, 0 }, 0, mi_cmd_var_info_num_children},
160
  { "var-info-type", { NULL, 0 }, 0, mi_cmd_var_info_type},
161
  { "var-list-children", { NULL, 0 }, 0, mi_cmd_var_list_children},
162
  { "var-set-format", { NULL, 0 }, 0, mi_cmd_var_set_format},
163
  { "var-set-frozen", { NULL, 0 }, 0, mi_cmd_var_set_frozen},
164
  { "var-show-attributes", { NULL, 0 }, 0, mi_cmd_var_show_attributes},
165
  { "var-show-format", { NULL, 0 }, 0, mi_cmd_var_show_format},
166
  { "var-update", { NULL, 0 }, 0, mi_cmd_var_update},
167
  { NULL, }
168
};
169
 
170
/* Pointer to the mi command table (built at run time) */
171
 
172
static struct mi_cmd **mi_table;
173
 
174
/* A prime large enough to accomodate the entire command table */
175
enum
176
  {
177
    MI_TABLE_SIZE = 227
178
  };
179
 
180
/* Exported function used to obtain info from the table */
181
struct mi_cmd *
182
mi_lookup (const char *command)
183
{
184
  return *lookup_table (command);
185
}
186
 
187
/* stat collecting */
188
struct mi_cmd_stats
189
{
190
  int hit;
191
  int miss;
192
  int rehash;
193
};
194
struct mi_cmd_stats stats;
195
 
196
/* our lookup function */
197
static struct mi_cmd **
198
lookup_table (const char *command)
199
{
200
  const char *chp;
201
  unsigned int index = 0;
202
  /* compute our hash */
203
  for (chp = command; *chp; chp++)
204
    {
205
      /* some what arbitrary */
206
      index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE;
207
    }
208
  /* look it up */
209
  while (1)
210
    {
211
      struct mi_cmd **entry = &mi_table[index];
212
      if ((*entry) == 0)
213
        {
214
          /* not found, return pointer to next free. */
215
          stats.miss++;
216
          return entry;
217
        }
218
      if (strcmp (command, (*entry)->name) == 0)
219
        {
220
          stats.hit++;
221
          return entry;         /* found */
222
        }
223
      index = (index + 1) % MI_TABLE_SIZE;
224
      stats.rehash++;
225
    }
226
}
227
 
228
static void
229
build_table (struct mi_cmd *commands)
230
{
231
  int nr_rehash = 0;
232
  int nr_entries = 0;
233
  struct mi_cmd *command;
234
  int sizeof_table = sizeof (struct mi_cmd **) * MI_TABLE_SIZE;
235
 
236
  mi_table = xmalloc (sizeof_table);
237
  memset (mi_table, 0, sizeof_table);
238
  for (command = commands; command->name != 0; command++)
239
    {
240
      struct mi_cmd **entry = lookup_table (command->name);
241
      if (*entry)
242
        internal_error (__FILE__, __LINE__,
243
                        _("command `%s' appears to be duplicated"),
244
                        command->name);
245
      *entry = command;
246
      if (0)
247
        {
248
          fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n",
249
                              command->name, stats.rehash - nr_rehash);
250
        }
251
      nr_entries++;
252
      nr_rehash = stats.rehash;
253
    }
254
  if (0)
255
    {
256
      fprintf_filtered (gdb_stdlog, "Average %3.1f\n",
257
                        (double) nr_rehash / (double) nr_entries);
258
    }
259
}
260
 
261
void
262
_initialize_mi_cmds (void)
263
{
264
  build_table (mi_cmds);
265
  memset (&stats, 0, sizeof (stats));
266
}

powered by: WebSVN 2.1.0

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