summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2013-02-28 07:21:34 +0000
committerRobert Mustacchi <rm@joyent.com>2013-08-01 10:18:30 -0700
commit8f68126c6dc4f2178929233f0c7ccce877e973ca (patch)
tree4a645f31e0c4341544ac342d7ae4386876a9963f /usr/src
parenta5b577712a34346841d970e0827b4920ace408af (diff)
downloadillumos-joyent-8f68126c6dc4f2178929233f0c7ccce877e973ca.tar.gz
3918 "pargs -l" dies on incomplete core dumps
3919 mdb/pmap should show unresolved map names on core dumps 3920 executable mapping in core dump misreported when file isn't found 3921 Pfindexec() finds wrong binary, wreaking havoc Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Eric Schrock <eric.schrock@delphix.com> Approved by: Dan McDonald <danmcd@nexenta.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_proc.c22
-rw-r--r--usr/src/cmd/ptools/pargs/pargs.c4
-rw-r--r--usr/src/cmd/ptools/pmap/pmap_common.c5
-rw-r--r--usr/src/lib/libproc/common/Psymtab.c16
-rw-r--r--usr/src/lib/libproc/common/Pzone.c10
5 files changed, 45 insertions, 12 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_proc.c b/usr/src/cmd/mdb/common/mdb/mdb_proc.c
index 7c419d8fcd..1b7cdc544b 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_proc.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_proc.c
@@ -23,6 +23,9 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ */
/*
* User Process Target
@@ -122,6 +125,13 @@ static int tlsbase(mdb_tgt_t *, mdb_tgt_tid_t, Lmid_t, const char *,
psaddr_t *);
/*
+ * When debugging postmortem, we don't resolve names as we may very well not
+ * be on a system on which those names resolve.
+ */
+#define PT_LIBPROC_RESOLVE(P) \
+ (!(mdb.m_flags & MDB_FL_LMRAW) && Pstate(P) != PS_DEAD)
+
+/*
* The Perror_printf() function interposes on the default, empty libproc
* definition. It will be called to report additional information on complex
* errors, such as a corrupt core file. We just pass the args to vwarn.
@@ -2805,7 +2815,7 @@ pt_lookup_by_addr(mdb_tgt_t *t, uintptr_t addr, uint_t flags,
* Once we get the closest symbol, we perform the EXACT match or
* smart-mode or absolute distance check ourself:
*/
- if ((mdb.m_flags & MDB_FL_LMRAW) == 0) {
+ if (PT_LIBPROC_RESOLVE(P)) {
rv = Pxlookup_by_addr_resolved(P, addr, buf, nbytes,
symp, &si);
} else {
@@ -2850,7 +2860,7 @@ found:
const char *prefix = pmp->pr_mapname;
Lmid_t lmid;
- if ((mdb.m_flags & MDB_FL_LMRAW) == 0) {
+ if (PT_LIBPROC_RESOLVE(P)) {
if (Pobjname_resolved(P, addr, pt->p_objname,
MDB_TGT_MAPSZ))
prefix = pt->p_objname;
@@ -2952,7 +2962,7 @@ pt_symbol_iter(mdb_tgt_t *t, const char *object, uint_t which,
which, type, pt_symbol_iter_cb, &ps);
return (0);
} else if (Prd_agent(t->t_pshandle) != NULL) {
- if ((mdb.m_flags & MDB_FL_LMRAW) == 0) {
+ if (PT_LIBPROC_RESOLVE(t->t_pshandle)) {
(void) Pobject_iter_resolved(t->t_pshandle,
pt_objsym_iter, &ps);
} else {
@@ -2991,7 +3001,7 @@ pt_prmap_to_mdbmap(mdb_tgt_t *t, const prmap_t *prp, mdb_map_t *mp)
char *rv, name[MAXPATHLEN];
Lmid_t lmid;
- if ((mdb.m_flags & MDB_FL_LMRAW) == 0) {
+ if (PT_LIBPROC_RESOLVE(P)) {
rv = Pobjname_resolved(P, prp->pr_vaddr, name, sizeof (name));
} else {
rv = Pobjname(P, prp->pr_vaddr, name, sizeof (name));
@@ -3057,7 +3067,7 @@ pt_mapping_iter(mdb_tgt_t *t, mdb_tgt_map_f *func, void *private)
pm.pmap_func = func;
pm.pmap_private = private;
- if ((mdb.m_flags & MDB_FL_LMRAW) == 0) {
+ if (PT_LIBPROC_RESOLVE(t->t_pshandle)) {
(void) Pmapping_iter_resolved(t->t_pshandle,
pt_map_apply, &pm);
} else {
@@ -3086,7 +3096,7 @@ pt_object_iter(mdb_tgt_t *t, mdb_tgt_map_f *func, void *private)
pm.pmap_func = func;
pm.pmap_private = private;
- if ((mdb.m_flags & MDB_FL_LMRAW) == 0) {
+ if (PT_LIBPROC_RESOLVE(t->t_pshandle)) {
(void) Pobject_iter_resolved(t->t_pshandle,
pt_map_apply, &pm);
} else {
diff --git a/usr/src/cmd/ptools/pargs/pargs.c b/usr/src/cmd/ptools/pargs/pargs.c
index 30c60ca3c3..8c3cbba962 100644
--- a/usr/src/cmd/ptools/pargs/pargs.c
+++ b/usr/src/cmd/ptools/pargs/pargs.c
@@ -23,7 +23,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
/*
@@ -1201,7 +1201,7 @@ print_cmdline(pargs_data_t *datap)
* an error message and bail.
*/
for (i = 0; i < datap->pd_argc; i++) {
- if (datap->pd_argv[i] == NULL ||
+ if (datap->pd_argv == NULL || datap->pd_argv[i] == NULL ||
datap->pd_argv_strs[i] == NULL) {
(void) fprintf(stderr, "%s: target has corrupted "
"argument list\n", command);
diff --git a/usr/src/cmd/ptools/pmap/pmap_common.c b/usr/src/cmd/ptools/pmap/pmap_common.c
index 7594fd30e3..fff55ffdbc 100644
--- a/usr/src/cmd/ptools/pmap/pmap_common.c
+++ b/usr/src/cmd/ptools/pmap/pmap_common.c
@@ -23,6 +23,9 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ */
#include <fcntl.h>
#include <libproc.h>
@@ -68,7 +71,7 @@ make_name(struct ps_prochandle *Pr, int lflag, uintptr_t addr,
char path[PATH_MAX];
int len;
- if (lflag) {
+ if (lflag || Pstate(Pr) == PS_DEAD) {
if (Pobjname(Pr, addr, buf, bufsz) != NULL)
return (buf);
} else {
diff --git a/usr/src/lib/libproc/common/Psymtab.c b/usr/src/lib/libproc/common/Psymtab.c
index 3176e50448..7c8166d5c3 100644
--- a/usr/src/lib/libproc/common/Psymtab.c
+++ b/usr/src/lib/libproc/common/Psymtab.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#include <assert.h>
@@ -1733,6 +1734,21 @@ Pbuild_file_symtab(struct ps_prochandle *P, file_info_t *fptr)
(void) elf_end(elf);
elf = newelf;
dprintf("switched to faked up ELF file\n");
+
+ /*
+ * Check to see if the file that we just discovered
+ * to be an imposter matches the execname that was
+ * determined by Pfindexec(). If it does, we (clearly)
+ * don't have the right binary, and we zero out
+ * execname before anyone gets hurt.
+ */
+ if (fptr->file_rname != NULL && P->execname != NULL &&
+ strcmp(fptr->file_rname, P->execname) == 0) {
+ dprintf("file/in-core image mismatch was "
+ "on P->execname; discarding\n");
+ free(P->execname);
+ P->execname = NULL;
+ }
}
}
diff --git a/usr/src/lib/libproc/common/Pzone.c b/usr/src/lib/libproc/common/Pzone.c
index c478b41624..68efea7a72 100644
--- a/usr/src/lib/libproc/common/Pzone.c
+++ b/usr/src/lib/libproc/common/Pzone.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ */
#include <assert.h>
#include <dlfcn.h>
@@ -792,9 +795,10 @@ Pfindmap(struct ps_prochandle *P, map_info_t *mptr, char *s, size_t n)
(strcmp(mptr->map_pmap.pr_mapname, "a.out") == 0) ||
((fptr != NULL) && (fptr->file_lname != NULL) &&
(strcmp(fptr->file_lname, "a.out") == 0))) {
- (void) Pexecname(P, buf, sizeof (buf));
- (void) strlcpy(s, buf, n);
- return (s);
+ if (Pexecname(P, buf, sizeof (buf)) != NULL) {
+ (void) strlcpy(s, buf, n);
+ return (s);
+ }
}
/* Try /proc first to get the real object name */