Bug Summary

File:src/gnu/usr.bin/binutils/gdb/mi/mi-cmds.c
Warning:line 253, column 7
Value stored to 'nr_rehash' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name mi-cmds.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/gnu/usr.bin/binutils/obj/gdb -resource-dir /usr/local/lib/clang/13.0.0 -D PIE_DEFAULT=1 -I . -I /usr/src/gnu/usr.bin/binutils/gdb -I /usr/src/gnu/usr.bin/binutils/gdb/config -D LOCALEDIR="/usr/share/locale" -D HAVE_CONFIG_H -I /usr/src/gnu/usr.bin/binutils/gdb/../include/opcode -I ../bfd -I /usr/src/gnu/usr.bin/binutils/gdb/../bfd -I /usr/src/gnu/usr.bin/binutils/gdb/../include -I ../intl -I /usr/src/gnu/usr.bin/binutils/gdb/../intl -D MI_OUT=1 -D TUI=1 -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/gnu/usr.bin/binutils/obj/gdb -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -fcommon -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c /usr/src/gnu/usr.bin/binutils/gdb/mi/mi-cmds.c
1/* MI Command Set for GDB, the GNU debugger.
2
3 Copyright 2000, 2001, 2003 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 2 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, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
23
24#include "defs.h"
25#include "top.h"
26#include "mi-cmds.h"
27#include "gdb_string.h"
28
29extern void _initialize_mi_cmds (void);
30struct mi_cmd;
31static struct mi_cmd **lookup_table (const char *command);
32static void build_table (struct mi_cmd *commands);
33
34
35struct mi_cmd mi_cmds[] =
36{
37 { "break-after", { "ignore", 1 }, NULL((void*)0), NULL((void*)0) },
38 { "break-catch", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
39 { "break-commands", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
40 { "break-condition", { "cond", 1 }, NULL((void*)0), NULL((void*)0) },
41 { "break-delete", { "delete breakpoint", 1 }, NULL((void*)0), NULL((void*)0) },
42 { "break-disable", { "disable breakpoint", 1 }, NULL((void*)0), NULL((void*)0) },
43 { "break-enable", { "enable breakpoint", 1 }, NULL((void*)0), NULL((void*)0) },
44 { "break-info", { "info break", 1 }, NULL((void*)0), NULL((void*)0) },
45 { "break-insert", { NULL((void*)0), 0 }, 0, mi_cmd_break_insert},
46 { "break-list", { "info break", }, NULL((void*)0), NULL((void*)0) },
47 { "break-watch", { NULL((void*)0), 0 }, 0, mi_cmd_break_watch},
48 { "data-disassemble", { NULL((void*)0), 0 }, 0, mi_cmd_disassemble},
49 { "data-evaluate-expression", { NULL((void*)0), 0 }, 0, mi_cmd_data_evaluate_expression},
50 { "data-list-changed-registers", { NULL((void*)0), 0 }, 0, mi_cmd_data_list_changed_registers},
51 { "data-list-register-names", { NULL((void*)0), 0 }, 0, mi_cmd_data_list_register_names},
52 { "data-list-register-values", { NULL((void*)0), 0 }, 0, mi_cmd_data_list_register_values},
53 { "data-read-memory", { NULL((void*)0), 0 }, 0, mi_cmd_data_read_memory},
54 { "data-write-memory", { NULL((void*)0), 0 }, 0, mi_cmd_data_write_memory},
55 { "data-write-register-values", { NULL((void*)0), 0 }, 0, mi_cmd_data_write_register_values},
56 { "display-delete", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
57 { "display-disable", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
58 { "display-enable", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
59 { "display-insert", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
60 { "display-list", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
61 { "environment-cd", { NULL((void*)0), 0 }, 0, mi_cmd_env_cd},
62 { "environment-directory", { NULL((void*)0), 0 }, 0, mi_cmd_env_dir},
63 { "environment-path", { NULL((void*)0), 0 }, 0, mi_cmd_env_path},
64 { "environment-pwd", { NULL((void*)0), 0 }, 0, mi_cmd_env_pwd},
65 { "exec-abort", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
66 { "exec-arguments", { "set args", 1 }, NULL((void*)0), NULL((void*)0) },
67 { "exec-continue", { NULL((void*)0), 0 }, mi_cmd_exec_continue},
68 { "exec-finish", { NULL((void*)0), 0 }, mi_cmd_exec_finish},
69 { "exec-interrupt", { NULL((void*)0), 0 }, mi_cmd_exec_interrupt},
70 { "exec-next", { NULL((void*)0), 0 }, mi_cmd_exec_next},
71 { "exec-next-instruction", { NULL((void*)0), 0 }, mi_cmd_exec_next_instruction},
72 { "exec-return", { NULL((void*)0), 0 }, mi_cmd_exec_return},
73 { "exec-run", { NULL((void*)0), 0 }, mi_cmd_exec_run},
74 { "exec-show-arguments", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
75 { "exec-signal", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
76 { "exec-step", { NULL((void*)0), 0 }, mi_cmd_exec_step},
77 { "exec-step-instruction", { NULL((void*)0), 0 }, mi_cmd_exec_step_instruction},
78 { "exec-until", { NULL((void*)0), 0 }, mi_cmd_exec_until},
79 { "file-clear", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
80 { "file-exec-and-symbols", { "file", 1 }, NULL((void*)0), NULL((void*)0) },
81 { "file-exec-file", { "exec-file", 1 }, NULL((void*)0), NULL((void*)0) },
82 { "file-list-exec-sections", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
83 { "file-list-exec-source-file", { NULL((void*)0), 0 }, 0, mi_cmd_file_list_exec_source_file},
84 { "file-list-exec-source-files", { NULL((void*)0), 0 }, NULL((void*)0), mi_cmd_file_list_exec_source_files },
85 { "file-list-shared-libraries", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
86 { "file-list-symbol-files", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
87 { "file-symbol-file", { "symbol-file", 1 }, NULL((void*)0), NULL((void*)0) },
88 { "gdb-complete", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
89 { "gdb-exit", { NULL((void*)0), 0 }, 0, mi_cmd_gdb_exit},
90 { "gdb-set", { "set", 1 }, NULL((void*)0), NULL((void*)0) },
91 { "gdb-show", { "show", 1 }, NULL((void*)0), NULL((void*)0) },
92 { "gdb-source", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
93 { "gdb-version", { "show version", 0 }, 0 },
94 { "interpreter-exec", { NULL((void*)0), 0 }, 0, mi_cmd_interpreter_exec},
95 { "kod-info", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
96 { "kod-list", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
97 { "kod-list-object-types", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
98 { "kod-show", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
99 { "overlay-auto", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
100 { "overlay-list-mapping-state", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
101 { "overlay-list-overlays", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
102 { "overlay-map", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
103 { "overlay-off", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
104 { "overlay-on", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
105 { "overlay-unmap", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
106 { "signal-handle", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
107 { "signal-list-handle-actions", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
108 { "signal-list-signal-types", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
109 { "stack-info-depth", { NULL((void*)0), 0 }, 0, mi_cmd_stack_info_depth},
110 { "stack-info-frame", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
111 { "stack-list-arguments", { NULL((void*)0), 0 }, 0, mi_cmd_stack_list_args},
112 { "stack-list-exception-handlers", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
113 { "stack-list-frames", { NULL((void*)0), 0 }, 0, mi_cmd_stack_list_frames},
114 { "stack-list-locals", { NULL((void*)0), 0 }, 0, mi_cmd_stack_list_locals},
115 { "stack-select-frame", { NULL((void*)0), 0 }, 0, mi_cmd_stack_select_frame},
116 { "symbol-info-address", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
117 { "symbol-info-file", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
118 { "symbol-info-function", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
119 { "symbol-info-line", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
120 { "symbol-info-symbol", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
121 { "symbol-list-functions", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
122 { "symbol-list-lines", { NULL((void*)0), 0 }, 0, mi_cmd_symbol_list_lines},
123 { "symbol-list-types", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
124 { "symbol-list-variables", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
125 { "symbol-locate", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
126 { "symbol-type", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
127 { "target-attach", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
128 { "target-compare-sections", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
129 { "target-detach", { "detach", 0 }, 0 },
130 { "target-disconnect", { "disconnect", 0 }, 0 },
131 { "target-download", { NULL((void*)0), 0 }, mi_cmd_target_download},
132 { "target-exec-status", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
133 { "target-list-available-targets", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
134 { "target-list-current-targets", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
135 { "target-list-parameters", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
136 { "target-select", { NULL((void*)0), 0 }, mi_cmd_target_select},
137 { "thread-info", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
138 { "thread-list-all-threads", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
139 { "thread-list-ids", { NULL((void*)0), 0 }, 0, mi_cmd_thread_list_ids},
140 { "thread-select", { NULL((void*)0), 0 }, 0, mi_cmd_thread_select},
141 { "trace-actions", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
142 { "trace-delete", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
143 { "trace-disable", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
144 { "trace-dump", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
145 { "trace-enable", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
146 { "trace-exists", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
147 { "trace-find", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
148 { "trace-frame-number", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
149 { "trace-info", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
150 { "trace-insert", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
151 { "trace-list", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
152 { "trace-pass-count", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
153 { "trace-save", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
154 { "trace-start", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
155 { "trace-stop", { NULL((void*)0), 0 }, NULL((void*)0), NULL((void*)0) },
156 { "var-assign", { NULL((void*)0), 0 }, 0, mi_cmd_var_assign},
157 { "var-create", { NULL((void*)0), 0 }, 0, mi_cmd_var_create},
158 { "var-delete", { NULL((void*)0), 0 }, 0, mi_cmd_var_delete},
159 { "var-evaluate-expression", { NULL((void*)0), 0 }, 0, mi_cmd_var_evaluate_expression},
160 { "var-info-expression", { NULL((void*)0), 0 }, 0, mi_cmd_var_info_expression},
161 { "var-info-num-children", { NULL((void*)0), 0 }, 0, mi_cmd_var_info_num_children},
162 { "var-info-type", { NULL((void*)0), 0 }, 0, mi_cmd_var_info_type},
163 { "var-list-children", { NULL((void*)0), 0 }, 0, mi_cmd_var_list_children},
164 { "var-set-format", { NULL((void*)0), 0 }, 0, mi_cmd_var_set_format},
165 { "var-show-attributes", { NULL((void*)0), 0 }, 0, mi_cmd_var_show_attributes},
166 { "var-show-format", { NULL((void*)0), 0 }, 0, mi_cmd_var_show_format},
167 { "var-update", { NULL((void*)0), 0 }, 0, mi_cmd_var_update},
168 { NULL((void*)0), }
169};
170
171/* Pointer to the mi command table (built at run time) */
172
173static struct mi_cmd **mi_table;
174
175/* A prime large enough to accomodate the entire command table */
176enum
177 {
178 MI_TABLE_SIZE = 227
179 };
180
181/* Exported function used to obtain info from the table */
182struct mi_cmd *
183mi_lookup (const char *command)
184{
185 return *lookup_table (command);
186}
187
188/* stat collecting */
189struct mi_cmd_stats
190{
191 int hit;
192 int miss;
193 int rehash;
194};
195struct mi_cmd_stats stats;
196
197/* our lookup function */
198static struct mi_cmd **
199lookup_table (const char *command)
200{
201 const char *chp;
202 unsigned int index = 0;
203 /* compute our hash */
204 for (chp = command; *chp; chp++)
205 {
206 /* some what arbitrary */
207 index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE;
208 }
209 /* look it up */
210 while (1)
211 {
212 struct mi_cmd **entry = &mi_table[index];
213 if ((*entry) == 0)
214 {
215 /* not found, return pointer to next free. */
216 stats.miss++;
217 return entry;
218 }
219 if (strcmp (command, (*entry)->name) == 0)
220 {
221 stats.hit++;
222 return entry; /* found */
223 }
224 index = (index + 1) % MI_TABLE_SIZE;
225 stats.rehash++;
226 }
227}
228
229static void
230build_table (struct mi_cmd *commands)
231{
232 int nr_rehash = 0;
233 int nr_entries = 0;
234 struct mi_cmd *command;
235 int sizeof_table = sizeof (struct mi_cmd **) * MI_TABLE_SIZE;
236
237 mi_table = xmalloc (sizeof_table);
238 memset (mi_table, 0, sizeof_table);
239 for (command = commands; command->name != 0; command++)
240 {
241 struct mi_cmd **entry = lookup_table (command->name);
242 if (*entry)
243 internal_error (__FILE__"/usr/src/gnu/usr.bin/binutils/gdb/mi/mi-cmds.c", __LINE__243,
244 "command `%s' appears to be duplicated",
245 command->name);
246 *entry = command;
247 if (0)
248 {
249 fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n",
250 command->name, stats.rehash - nr_rehash);
251 }
252 nr_entries++;
253 nr_rehash = stats.rehash;
Value stored to 'nr_rehash' is never read
254 }
255 if (0)
256 {
257 fprintf_filtered (gdb_stdlog, "Average %3.1f\n",
258 (double) nr_rehash / (double) nr_entries);
259 }
260}
261
262void
263_initialize_mi_cmds (void)
264{
265 build_table (mi_cmds);
266 memset (&stats, 0, sizeof (stats));
267}