10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright (c) 2012 by Delphix. All rights reserved.
29 * Copyright (c) 2013 Joyent, Inc. All rights reserved.
30 */
31
32 #include <sys/elf.h>
33 #include <sys/elf_SPARC.h>
34
35 #include <libproc.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <fcntl.h>
39 #include <errno.h>
40 #include <alloca.h>
41 #include <libctf.h>
42 #include <ctype.h>
43
44 #include <mdb/mdb_string.h>
45 #include <mdb/mdb_argvec.h>
46 #include <mdb/mdb_nv.h>
47 #include <mdb/mdb_fmt.h>
48 #include <mdb/mdb_target.h>
49 #include <mdb/mdb_err.h>
1546 /*ARGSUSED*/
1547 static int
1548 showrev_addversion(void *vers_nv, const mdb_map_t *ignored, const char *object)
1549 {
1550 ctf_file_t *ctfp;
1551 const char *version = NULL;
1552 char *objname;
1553
1554 objname = mdb_alloc(strlen(object) + 1, UM_SLEEP | UM_GC);
1555 (void) strcpy(objname, object);
1556
1557 if ((ctfp = mdb_tgt_name_to_ctf(mdb.m_target, objname)) != NULL)
1558 version = ctf_label_topmost(ctfp);
1559
1560 /*
1561 * Not all objects have CTF and label data, so set version to "Unknown".
1562 */
1563 if (version == NULL)
1564 version = "Unknown";
1565
1566 /*
1567 * The hash table implementation in OVERLOAD mode limits the version
1568 * name to 31 characters because we cannot specify an external name.
1569 * The full version name is available via the ::objects dcmd if needed.
1570 */
1571 (void) mdb_nv_insert(vers_nv, version, NULL, (uintptr_t)objname,
1572 MDB_NV_OVERLOAD);
1573
1574 return (0);
1575 }
1576
1577 static int
1578 showrev_ispatch(const char *s)
1579 {
1580 if (s == NULL)
1581 return (0);
1582
1583 if (*s == 'T')
1584 s++; /* skip T for T-patch */
1585
1586 for (; *s != '\0'; s++) {
1587 if ((*s < '0' || *s > '9') && *s != '-')
1588 return (0);
1589 }
1590
|
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright (c) 2012 by Delphix. All rights reserved.
29 * Copyright (c) 2013 Joyent, Inc. All rights reserved.
30 * Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
31 */
32
33 #include <sys/elf.h>
34 #include <sys/elf_SPARC.h>
35
36 #include <libproc.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <fcntl.h>
40 #include <errno.h>
41 #include <alloca.h>
42 #include <libctf.h>
43 #include <ctype.h>
44
45 #include <mdb/mdb_string.h>
46 #include <mdb/mdb_argvec.h>
47 #include <mdb/mdb_nv.h>
48 #include <mdb/mdb_fmt.h>
49 #include <mdb/mdb_target.h>
50 #include <mdb/mdb_err.h>
1547 /*ARGSUSED*/
1548 static int
1549 showrev_addversion(void *vers_nv, const mdb_map_t *ignored, const char *object)
1550 {
1551 ctf_file_t *ctfp;
1552 const char *version = NULL;
1553 char *objname;
1554
1555 objname = mdb_alloc(strlen(object) + 1, UM_SLEEP | UM_GC);
1556 (void) strcpy(objname, object);
1557
1558 if ((ctfp = mdb_tgt_name_to_ctf(mdb.m_target, objname)) != NULL)
1559 version = ctf_label_topmost(ctfp);
1560
1561 /*
1562 * Not all objects have CTF and label data, so set version to "Unknown".
1563 */
1564 if (version == NULL)
1565 version = "Unknown";
1566
1567 (void) mdb_nv_insert(vers_nv, version, NULL, (uintptr_t)objname,
1568 MDB_NV_OVERLOAD);
1569
1570 return (0);
1571 }
1572
1573 static int
1574 showrev_ispatch(const char *s)
1575 {
1576 if (s == NULL)
1577 return (0);
1578
1579 if (*s == 'T')
1580 s++; /* skip T for T-patch */
1581
1582 for (; *s != '\0'; s++) {
1583 if ((*s < '0' || *s > '9') && *s != '-')
1584 return (0);
1585 }
1586
|