Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: gdb/mi/mi-cmds.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/mi/mi-cmds.h ('k') | gdb/mi/mi-common.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* MI Command Set for GDB, the GNU debugger. 1 /* MI Command Set for GDB, the GNU debugger.
2
3 Copyright (C) 2000-2001, 2003, 2007-2012 Free Software Foundation, 2 Copyright (C) 2000-2001, 2003, 2007-2012 Free Software Foundation,
4 Inc. 3 Inc.
5 4
6 Contributed by Cygnus Solutions (a Red Hat company). 5 Contributed by Cygnus Solutions (a Red Hat company).
7 6
8 This file is part of GDB. 7 This file is part of GDB.
9 8
10 This program is free software; you can redistribute it and/or modify 9 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 10 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 11 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version. 12 (at your option) any later version.
14 13
15 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details. 17 GNU General Public License for more details.
19 18
20 You should have received a copy of the GNU General Public License 19 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/>. */ 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 21
23 #include "defs.h" 22 #include "defs.h"
24 #include "top.h" 23 #include "top.h"
25 #include "mi-cmds.h" 24 #include "mi-cmds.h"
26 #include "gdb_string.h" 25 #include "gdb_string.h"
27 26
28 extern void _initialize_mi_cmds (void); 27 extern void _initialize_mi_cmds (void);
28
29 struct mi_cmd; 29 struct mi_cmd;
30 static struct mi_cmd **lookup_table (const char *command); 30 static struct mi_cmd **lookup_table (const char *command);
31 static void build_table (struct mi_cmd *commands); 31 static void build_table (struct mi_cmd *commands);
32 32
33
34 struct mi_cmd mi_cmds[] = 33 struct mi_cmd mi_cmds[] =
35 { 34 {
36 { "ada-task-info", { NULL, 0 }, mi_cmd_ada_task_info }, 35 { "ada-task-info", { NULL, 0 }, mi_cmd_ada_task_info },
37 { "add-inferior", { NULL, 0 }, mi_cmd_add_inferior }, 36 { "add-inferior", { NULL, 0 }, mi_cmd_add_inferior },
38 { "break-after", { "ignore", 1 }, NULL }, 37 { "break-after", { "ignore", 1 }, NULL },
39 { "break-condition", { "cond", 1 }, NULL }, 38 { "break-condition", { "cond", 1 }, NULL },
40 { "break-commands", { NULL, 0 }, mi_cmd_break_commands }, 39 { "break-commands", { NULL, 0 }, mi_cmd_break_commands },
41 { "break-delete", { "delete breakpoint", 1 }, NULL }, 40 { "break-delete", { "delete breakpoint", 1 }, NULL },
42 { "break-disable", { "disable breakpoint", 1 }, NULL }, 41 { "break-disable", { "disable breakpoint", 1 }, NULL },
43 { "break-enable", { "enable breakpoint", 1 }, NULL }, 42 { "break-enable", { "enable breakpoint", 1 }, NULL },
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 mi_cmd_file_list_exec_source_file}, 82 mi_cmd_file_list_exec_source_file},
84 { "file-list-exec-source-files", { NULL, 0 }, 83 { "file-list-exec-source-files", { NULL, 0 },
85 mi_cmd_file_list_exec_source_files }, 84 mi_cmd_file_list_exec_source_files },
86 { "file-symbol-file", { "symbol-file", 1 }, NULL }, 85 { "file-symbol-file", { "symbol-file", 1 }, NULL },
87 { "gdb-exit", { NULL, 0 }, mi_cmd_gdb_exit}, 86 { "gdb-exit", { NULL, 0 }, mi_cmd_gdb_exit},
88 { "gdb-set", { "set", 1 }, NULL }, 87 { "gdb-set", { "set", 1 }, NULL },
89 { "gdb-show", { "show", 1 }, NULL }, 88 { "gdb-show", { "show", 1 }, NULL },
90 { "gdb-version", { "show version", 0 }, 0 }, 89 { "gdb-version", { "show version", 0 }, 0 },
91 { "inferior-tty-set", { NULL, 0 }, mi_cmd_inferior_tty_set}, 90 { "inferior-tty-set", { NULL, 0 }, mi_cmd_inferior_tty_set},
92 { "inferior-tty-show", { NULL, 0 }, mi_cmd_inferior_tty_show}, 91 { "inferior-tty-show", { NULL, 0 }, mi_cmd_inferior_tty_show},
92 { "info-os", { NULL, 0 }, mi_cmd_info_os},
93 { "interpreter-exec", { NULL, 0 }, mi_cmd_interpreter_exec}, 93 { "interpreter-exec", { NULL, 0 }, mi_cmd_interpreter_exec},
94 { "list-features", { NULL, 0 }, mi_cmd_list_features}, 94 { "list-features", { NULL, 0 }, mi_cmd_list_features},
95 { "list-target-features", { NULL, 0 }, mi_cmd_list_target_features}, 95 { "list-target-features", { NULL, 0 }, mi_cmd_list_target_features},
96 { "list-thread-groups", { NULL, 0 }, mi_cmd_list_thread_groups }, 96 { "list-thread-groups", { NULL, 0 }, mi_cmd_list_thread_groups },
97 { "remove-inferior", { NULL, 0 }, mi_cmd_remove_inferior }, 97 { "remove-inferior", { NULL, 0 }, mi_cmd_remove_inferior },
98 { "stack-info-depth", { NULL, 0 }, mi_cmd_stack_info_depth}, 98 { "stack-info-depth", { NULL, 0 }, mi_cmd_stack_info_depth},
99 { "stack-info-frame", { NULL, 0 }, mi_cmd_stack_info_frame}, 99 { "stack-info-frame", { NULL, 0 }, mi_cmd_stack_info_frame},
100 { "stack-list-arguments", { NULL, 0 }, mi_cmd_stack_list_args}, 100 { "stack-list-arguments", { NULL, 0 }, mi_cmd_stack_list_args},
101 { "stack-list-frames", { NULL, 0 }, mi_cmd_stack_list_frames}, 101 { "stack-list-frames", { NULL, 0 }, mi_cmd_stack_list_frames},
102 { "stack-list-locals", { NULL, 0 }, mi_cmd_stack_list_locals}, 102 { "stack-list-locals", { NULL, 0 }, mi_cmd_stack_list_locals},
(...skipping 30 matching lines...) Expand all
133 { "var-set-format", { NULL, 0 }, mi_cmd_var_set_format}, 133 { "var-set-format", { NULL, 0 }, mi_cmd_var_set_format},
134 { "var-set-frozen", { NULL, 0 }, mi_cmd_var_set_frozen}, 134 { "var-set-frozen", { NULL, 0 }, mi_cmd_var_set_frozen},
135 { "var-set-update-range", { NULL, 0 }, mi_cmd_var_set_update_range }, 135 { "var-set-update-range", { NULL, 0 }, mi_cmd_var_set_update_range },
136 { "var-set-visualizer", { NULL, 0 }, mi_cmd_var_set_visualizer}, 136 { "var-set-visualizer", { NULL, 0 }, mi_cmd_var_set_visualizer},
137 { "var-show-attributes", { NULL, 0 }, mi_cmd_var_show_attributes}, 137 { "var-show-attributes", { NULL, 0 }, mi_cmd_var_show_attributes},
138 { "var-show-format", { NULL, 0 }, mi_cmd_var_show_format}, 138 { "var-show-format", { NULL, 0 }, mi_cmd_var_show_format},
139 { "var-update", { NULL, 0 }, mi_cmd_var_update}, 139 { "var-update", { NULL, 0 }, mi_cmd_var_update},
140 { NULL, } 140 { NULL, }
141 }; 141 };
142 142
143 /* Pointer to the mi command table (built at run time) */ 143 /* Pointer to the mi command table (built at run time). */
144 144
145 static struct mi_cmd **mi_table; 145 static struct mi_cmd **mi_table;
146 146
147 /* A prime large enough to accomodate the entire command table */ 147 /* A prime large enough to accomodate the entire command table. */
148 enum 148 enum
149 { 149 {
150 MI_TABLE_SIZE = 227 150 MI_TABLE_SIZE = 227
151 }; 151 };
152 152
153 /* Exported function used to obtain info from the table */ 153 /* Exported function used to obtain info from the table. */
154 struct mi_cmd * 154 struct mi_cmd *
155 mi_lookup (const char *command) 155 mi_lookup (const char *command)
156 { 156 {
157 return *lookup_table (command); 157 return *lookup_table (command);
158 } 158 }
159 159
160 /* stat collecting */ 160 /* Used for collecting hash hit/miss statistics. */
161
161 struct mi_cmd_stats 162 struct mi_cmd_stats
162 { 163 {
163 int hit; 164 int hit;
164 int miss; 165 int miss;
165 int rehash; 166 int rehash;
166 }; 167 };
167 struct mi_cmd_stats stats; 168 struct mi_cmd_stats stats;
168 169
169 /* our lookup function */ 170 /* Look up a command. */
171
170 static struct mi_cmd ** 172 static struct mi_cmd **
171 lookup_table (const char *command) 173 lookup_table (const char *command)
172 { 174 {
173 const char *chp; 175 const char *chp;
174 unsigned int index = 0; 176 unsigned int index = 0;
175 177
176 /* compute our hash */ 178 /* Compute our hash. */
177 for (chp = command; *chp; chp++) 179 for (chp = command; *chp; chp++)
178 { 180 {
179 /* some what arbitrary */ 181 /* We use a somewhat arbitrary formula. */
180 index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE; 182 index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE;
181 } 183 }
182 /* look it up */ 184
183 while (1) 185 while (1)
184 { 186 {
185 struct mi_cmd **entry = &mi_table[index]; 187 struct mi_cmd **entry = &mi_table[index];
186 if ((*entry) == 0) 188 if ((*entry) == 0)
187 { 189 {
188 /* not found, return pointer to next free. */ 190 /* not found, return pointer to next free. */
189 stats.miss++; 191 stats.miss++;
190 return entry; 192 return entry;
191 } 193 }
192 if (strcmp (command, (*entry)->name) == 0) 194 if (strcmp (command, (*entry)->name) == 0)
(...skipping 18 matching lines...) Expand all
211 memset (mi_table, 0, sizeof_table); 213 memset (mi_table, 0, sizeof_table);
212 for (command = commands; command->name != 0; command++) 214 for (command = commands; command->name != 0; command++)
213 { 215 {
214 struct mi_cmd **entry = lookup_table (command->name); 216 struct mi_cmd **entry = lookup_table (command->name);
215 217
216 if (*entry) 218 if (*entry)
217 internal_error (__FILE__, __LINE__, 219 internal_error (__FILE__, __LINE__,
218 _("command `%s' appears to be duplicated"), 220 _("command `%s' appears to be duplicated"),
219 command->name); 221 command->name);
220 *entry = command; 222 *entry = command;
223 /* FIXME lose these prints */
221 if (0) 224 if (0)
222 { 225 {
223 fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n", 226 fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n",
224 command->name, stats.rehash - nr_rehash); 227 command->name, stats.rehash - nr_rehash);
225 } 228 }
226 nr_entries++; 229 nr_entries++;
227 nr_rehash = stats.rehash; 230 nr_rehash = stats.rehash;
228 } 231 }
229 if (0) 232 if (0)
230 { 233 {
231 fprintf_filtered (gdb_stdlog, "Average %3.1f\n", 234 fprintf_filtered (gdb_stdlog, "Average %3.1f\n",
232 (double) nr_rehash / (double) nr_entries); 235 (double) nr_rehash / (double) nr_entries);
233 } 236 }
234 } 237 }
235 238
236 void 239 void
237 _initialize_mi_cmds (void) 240 _initialize_mi_cmds (void)
238 { 241 {
239 build_table (mi_cmds); 242 build_table (mi_cmds);
240 memset (&stats, 0, sizeof (stats)); 243 memset (&stats, 0, sizeof (stats));
241 } 244 }
OLDNEW
« no previous file with comments | « gdb/mi/mi-cmds.h ('k') | gdb/mi/mi-common.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698