Changeset View
Changeset View
Standalone View
Standalone View
devel/gdb/files/kgdb/fbsd-kld.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | struct kld_info { | ||||
CORE_ADDR module_path_addr; | CORE_ADDR module_path_addr; | ||||
CORE_ADDR linker_files_addr; | CORE_ADDR linker_files_addr; | ||||
CORE_ADDR kernel_file_addr; | CORE_ADDR kernel_file_addr; | ||||
}; | }; | ||||
struct target_so_ops kld_so_ops; | struct target_so_ops kld_so_ops; | ||||
/* Per-program-space data key. */ | /* Per-program-space data key. */ | ||||
static const struct program_space_data *kld_pspace_data; | static const registry<program_space>::key<kld_info> kld_pspace_data; | ||||
static void | |||||
kld_pspace_data_cleanup (struct program_space *pspace, void *arg) | |||||
{ | |||||
struct kld_info *info = (struct kld_info *)arg; | |||||
xfree (info); | |||||
} | |||||
/* Get the current kld data. If none is found yet, add it now. This | /* Get the current kld data. If none is found yet, add it now. This | ||||
function always returns a valid object. */ | function always returns a valid object. */ | ||||
static struct kld_info * | static struct kld_info * | ||||
get_kld_info (void) | get_kld_info (void) | ||||
{ | { | ||||
struct kld_info *info; | struct kld_info *info; | ||||
info = (struct kld_info *) | info = kld_pspace_data.get (current_program_space); | ||||
program_space_data (current_program_space, kld_pspace_data); | if (info == nullptr) | ||||
if (info != NULL) | info = kld_pspace_data.emplace (current_program_space); | ||||
return info; | |||||
info = XCNEW (struct kld_info); | |||||
set_program_space_data (current_program_space, kld_pspace_data, info); | |||||
return info; | return info; | ||||
} | } | ||||
static int | static int | ||||
kld_ok (const char *path) | kld_ok (const char *path) | ||||
{ | { | ||||
struct stat sb; | struct stat sb; | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | printf_unfiltered("\t%s_addr = %s\n", s.name.c_str(), | ||||
paddress(target_gdbarch(), s.addr)); | paddress(target_gdbarch(), s.addr)); | ||||
if (from_tty && (!query("%s", ""))) | if (from_tty && (!query("%s", ""))) | ||||
error("Not confirmed."); | error("Not confirmed."); | ||||
symfile_add_flags add_flags = 0; | symfile_add_flags add_flags = 0; | ||||
if (from_tty) | if (from_tty) | ||||
add_flags |= SYMFILE_VERBOSE; | add_flags |= SYMFILE_VERBOSE; | ||||
symbol_file_add_from_bfd(bfd.get(), path, add_flags, &sap, | symbol_file_add_from_bfd(bfd, path, add_flags, &sap, | ||||
OBJF_USERLOADED, NULL); | OBJF_USERLOADED, NULL); | ||||
} | } | ||||
static void | static void | ||||
kgdb_add_kld_cmd (const char *arg, int from_tty) | kgdb_add_kld_cmd (const char *arg, int from_tty) | ||||
{ | { | ||||
CORE_ADDR base_addr; | CORE_ADDR base_addr; | ||||
▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | _initialize_kld_target () | ||||
kld_so_ops.in_dynsym_resolve_code = kld_in_dynsym_resolve_code; | kld_so_ops.in_dynsym_resolve_code = kld_in_dynsym_resolve_code; | ||||
kld_so_ops.bfd_open = solib_bfd_open; | kld_so_ops.bfd_open = solib_bfd_open; | ||||
kld_so_ops.find_and_open_solib = kld_find_and_open_solib; | kld_so_ops.find_and_open_solib = kld_find_and_open_solib; | ||||
c = add_com("add-kld", class_files, kgdb_add_kld_cmd, | c = add_com("add-kld", class_files, kgdb_add_kld_cmd, | ||||
"Usage: add-kld FILE\n\ | "Usage: add-kld FILE\n\ | ||||
Load the symbols from the kernel loadable module FILE."); | Load the symbols from the kernel loadable module FILE."); | ||||
set_cmd_completer(c, filename_completer); | set_cmd_completer(c, filename_completer); | ||||
kld_pspace_data = register_program_space_data_with_cleanup (NULL, | |||||
kld_pspace_data_cleanup); | |||||
} | } |