MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_lookup

Function db_lookup

freebsd/ddb/db_sym.c:286–331  ·  view source on GitHub ↗

* Lookup a symbol. * If the symbol has a qualifier (e.g., ux:vm_map), * then only the specified symbol table will be searched; * otherwise, all symbol tables will be searched. */

Source from the content-addressed store, hash-verified

284 * otherwise, all symbol tables will be searched.
285 */
286static c_db_sym_t
287db_lookup(const char *symstr)
288{
289 c_db_sym_t sp;
290 int i;
291 int symtab_start = 0;
292 int symtab_end = db_nsymtab;
293 const char *cp;
294
295 /*
296 * Look for, remove, and remember any symbol table specifier.
297 */
298 for (cp = symstr; *cp; cp++) {
299 if (*cp == ':') {
300 for (i = 0; i < db_nsymtab; i++) {
301 int n = strlen(db_symtabs[i].name);
302
303 if (
304 n == (cp - symstr) &&
305 strncmp(symstr, db_symtabs[i].name, n) == 0
306 ) {
307 symtab_start = i;
308 symtab_end = i + 1;
309 break;
310 }
311 }
312 if (i == db_nsymtab) {
313 db_error("invalid symbol table name");
314 }
315 symstr = cp+1;
316 }
317 }
318
319 /*
320 * Look in the specified set of symbol tables.
321 * Return on first match.
322 */
323 for (i = symtab_start; i < symtab_end; i++) {
324 sp = X_db_lookup(&db_symtabs[i], symstr);
325 if (sp) {
326 db_last_symtab = &db_symtabs[i];
327 return sp;
328 }
329 }
330 return 0;
331}
332
333/*
334 * If true, check across symbol tables for multiple occurrences

Callers 3

db_value_of_nameFunction · 0.85
db_value_of_name_pcpuFunction · 0.85
db_value_of_name_vnetFunction · 0.85

Calls 3

strncmpFunction · 0.85
db_errorFunction · 0.85
X_db_lookupFunction · 0.85

Tested by

no test coverage detected