/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/kobj_impl.h>
#include <unistd.h>
#include <strings.h>
#include <dlfcn.h>
#include <link.h>
#include <kmdb/kmdb_module.h>
#include <kmdb/kmdb_wr_impl.h>
#include <kmdb/kmdb_kdi.h>
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_debug.h>
#include <mdb/mdb_string.h>
#include <mdb/mdb_frame.h>
static void kmdb_module_request_unload(kmdb_modctl_t *, const char *, int);
static void
{
}
/*
* completed successfully, kmdb_module_loaded is called.
*/
int
{
mdb_var_t *v;
goto module_load_err;
kmc = MDB_NV_COOKIE(v);
wformat = "module %s is already being loaded\n";
else
wformat = "module %s is being unloaded\n";
goto module_load_err;
}
NULL) {
wformat = "module %s can't be registered for load\n";
goto module_load_err;
}
if (!(mode & MDB_MOD_DEFER) &&
return (0);
if (!(mode & MDB_MOD_SILENT))
return (0);
if (!(mode & MDB_MOD_SILENT))
return (-1);
}
int
{
mdb_var_t *v;
/*
* We're somewhat limited in the diagnostics that we can
* provide in the event of a failed load. In most load-failure
* cases, the driver can only send up a generic errno. We use
* EMDB_ENOMOD to signal generic errors, and supply our own
* message. This twists the meaning of EMDB_NOMOD somewhat, but
* it's better than defining a new one.
*/
mdb_warn("%s does not appear to be a kmdb dmod\n",
modname);
} else {
}
if (v != NULL)
return (0);
}
mdb_warn("dmod %s did not load properly\n");
goto module_loaded_err;
}
} else {
kmc = MDB_NV_COOKIE(v);
}
goto module_loaded_err;
return (1);
return (0);
}
void
{
}
void
{
}
void
{
}
static void
{
if (!(mode & MDB_MOD_DEFER) &&
return;
if (!(mode & MDB_MOD_SILENT))
}
/*ARGSUSED*/
int
{
const char *basename;
mdb_var_t *v;
/*
* We may have been called with the name from the module itself
* if the caller is iterating through the module list, so we need
* to make a copy of the name. If we don't, we can't use it after
* the call to unload_common(), which frees the module.
*/
/*
* Make sure the module is in the proper state for unloading. Modules
* may only be unloaded if they have properly completed loading.
*/
kmc = MDB_NV_COOKIE(v);
case KMDB_MC_STATE_LOADING:
return (set_errno(EMDB_NOMOD));
case KMDB_MC_STATE_UNLOADING:
return (set_errno(EMDB_NOMOD));
default:
}
return (set_errno(EMDB_KMODNOUNLOAD));
}
if (mdb_module_unload_common(name) < 0) {
if (!(mode & MDB_MOD_SILENT)) {
name);
}
return (-1); /* errno is set for us */
}
/*
* Any modules legitimately not listed in dmodctl (builtins, for
* example) will be handled by mdb_module_unload_common. If any of
* them get here, we've got a problem.
*/
if (v == NULL) {
return (set_errno(EMDB_NOMOD));
}
return (0);
}
int
{
mdb_var_t *v;
mdb_warn("unload for unrequested module %s\n",
dur->dur_modname);
return (0);
}
return (0);
}
kmc_free(MDB_NV_COOKIE(v));
return (1);
}
void
{
}
/*
* Called by the kmdb_kvm target upon debugger reentry, this routine checks
* to see if the loaded dmods have changed. Of particular interest is the
* exportation of dmod symbol tables, which will happen during the boot
* process for dmods that were loaded prior to kernel startup. If this
* has occurred, we'll need to reconstruct our view of the symbol tables for
* the affected dmods, since the old symbol tables lived in bootmem
* and have been moved during the kobj_export_module().
*
* Also, any ctf_file_t we might have opened is now invalid, since it
* has internal pointers to the old data as well.
*/
void
kmdb_module_sync(void)
{
mdb_var_t *v;
continue;
!kmc->kmc_exported) {
/*
* The exporting process moves the symtab from boot
* scratch memory to vmem.
*/
}
}
}
}