* Find the closest symbol to val, and return its name * and the difference between val and the symbol found. */
| 366 | * and the difference between val and the symbol found. |
| 367 | */ |
| 368 | c_db_sym_t |
| 369 | db_search_symbol(db_addr_t val, db_strategy_t strategy, db_expr_t *offp) |
| 370 | { |
| 371 | unsigned int diff; |
| 372 | size_t newdiff; |
| 373 | int i; |
| 374 | c_db_sym_t ret, sym; |
| 375 | |
| 376 | /* |
| 377 | * The kernel will never map the first page, so any symbols in that |
| 378 | * range cannot refer to addresses. Some third-party assembly files |
| 379 | * define internal constants which appear in their symbol table. |
| 380 | * Avoiding the lookup for those symbols avoids replacing small offsets |
| 381 | * with those symbols during disassembly. |
| 382 | */ |
| 383 | if (val < PAGE_SIZE) { |
| 384 | *offp = 0; |
| 385 | return (C_DB_SYM_NULL); |
| 386 | } |
| 387 | |
| 388 | ret = C_DB_SYM_NULL; |
| 389 | newdiff = diff = val; |
| 390 | for (i = 0; i < db_nsymtab; i++) { |
| 391 | sym = X_db_search_symbol(&db_symtabs[i], val, strategy, &newdiff); |
| 392 | if ((uintmax_t)newdiff < (uintmax_t)diff) { |
| 393 | db_last_symtab = &db_symtabs[i]; |
| 394 | diff = newdiff; |
| 395 | ret = sym; |
| 396 | } |
| 397 | } |
| 398 | *offp = diff; |
| 399 | return ret; |
| 400 | } |
| 401 | |
| 402 | /* |
| 403 | * Return name and value of a symbol |
no test coverage detected