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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [mi/] [mi-cmds.c] - Blame information for rev 309

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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