/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <libproc.h>
#include <Pcontrol.h>
#include <stddef.h>
#include <mdb/mdb_modapi.h>
/*
* addr::pr_symtab [-a | n]
*
* -a Sort symbols by address
* -n Sort symbols by name
*
* Given a sym_tbl_t, dump its contents in tabular form. When given '-a' or
* '-n', we use the sorted tables 'sym_byaddr' or 'sym_byname', respectively.
*/
static int
{
#ifdef _LP64
#else
#endif
return (DCMD_USAGE);
mdb_warn("only one of '-a' or '-n' can be specified\n");
return (DCMD_USAGE);
}
if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);
return (DCMD_ERR);
}
mdb_warn("no symbols present\n");
return (DCMD_ERR);
}
/*
* As described in the libproc header Pcontrol.h, a sym_tbl_t
* contains a primary and an optional auxiliary symbol table.
* We treat the combination as a single table, with the auxiliary
* values coming before the primary ones.
*
* Read the primary and auxiliary Elf_Data structs.
*/
mdb_warn("failed to read primary Elf_Data at %p",
return (DCMD_ERR);
}
if ((symtab.sym_symn_aux > 0) &&
mdb_warn("failed to read auxiliary Elf_Data at %p",
return (DCMD_ERR);
}
return (DCMD_ERR);
}
} else {
}
"SIZE", "NAME");
for (i = 0; i < count; i++) {
else
idx = i;
/* If index is in range of primary symtab, look it up there */
} else { /* Look it up in the auxiliary symtab */
}
mdb_warn("failed to read symbol at %p",
if (symlist)
return (DCMD_ERR);
}
mdb_warn("failed to read symbol name at %p",
name[0] = '\0';
}
name);
}
if (symlist)
return (DCMD_OK);
}
/*
* addr::pr_addr2map search
*
* Given a ps_prochandle_t, convert the given address to the corresponding
* map_info_t. Functionally equivalent to Paddr2mptr().
*/
static int
{
return (DCMD_USAGE);
else
return (DCMD_ERR);
}
lo = 0;
sizeof (map_info_t));
return (DCMD_OK);
}
else
}
return (DCMD_ERR);
}
/*
* ::walk pr_file_info
*
* Given a ps_prochandle_t, walk all its file_info_t structures.
*/
typedef struct {
int fiw_count;
static int
{
mdb_warn("pr_file_info doesn't support global walks\n");
return (WALK_ERR);
}
return (WALK_ERR);
}
return (WALK_NEXT);
}
static int
{
file_info_t f;
int status;
return (WALK_DONE);
return (WALK_ERR);
}
return (status);
}
static void
{
}
/*
* ::walk pr_map_info
*
* Given a ps_prochandle_t, walk all its map_info_t structures.
*/
typedef struct {
int miw_count;
int miw_current;
static int
{
mdb_warn("pr_map_info doesn't support global walks\n");
return (WALK_ERR);
}
return (WALK_ERR);
}
miw->miw_current = 0;
return (WALK_NEXT);
}
static int
{
map_info_t m;
int status;
return (WALK_DONE);
return (WALK_DONE);
}
miw->miw_current++;
return (status);
}
static void
{
}
{ "pr_addr2map", ":addr", "convert an adress into a map_info_t",
pr_addr2map },
{ "pr_symtab", ":[-a | -n]", "print the contents of a sym_tbl_t",
pr_symtab },
{ NULL }
};
{ "pr_file_info", "given a ps_prochandle, walk its file_info "
{ "pr_map_info", "given a ps_prochandle, walk its map_info structures",
{ NULL }
};
};
const mdb_modinfo_t *
_mdb_init(void)
{
return (&modinfo);
}