7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
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 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2012 by Delphix. All rights reserved.
28 * Copyright (c) 2012 Joyent, Inc. All rights reserved.
29 */
30
31 #include <mdb/mdb_modapi.h>
32 #include <mdb/mdb_target.h>
33 #include <mdb/mdb_argvec.h>
34 #include <mdb/mdb_string.h>
35 #include <mdb/mdb_stdlib.h>
36 #include <mdb/mdb_err.h>
37 #include <mdb/mdb_debug.h>
38 #include <mdb/mdb_fmt.h>
39 #include <mdb/mdb_ctf.h>
40 #include <mdb/mdb_ctf_impl.h>
41 #include <mdb/mdb.h>
42 #include <mdb/mdb_tab.h>
43
44 #include <sys/isa_defs.h>
45 #include <sys/param.h>
46 #include <sys/sysmacros.h>
47 #include <netinet/in.h>
690 if (mdb_vcb_find(v, mdb.m_frame) == NULL)
691 mdb_vcb_insert(mdb_vcb_create(v), mdb.m_frame);
692
693 return (0);
694 }
695
696 /*ARGSUSED*/
697 int
698 cmd_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
699 {
700 int offset;
701 uintptr_t a, tmp;
702 int ret;
703
704 if (!(flags & DCMD_ADDRSPEC) || argc == 0)
705 return (DCMD_USAGE);
706
707 if (argv->a_type != MDB_TYPE_STRING) {
708 /*
709 * We are being given a raw offset in lieu of a type and
710 * member; confirm the arguments.
711 */
712 if (argv->a_type != MDB_TYPE_IMMEDIATE)
713 return (DCMD_USAGE);
714
715 offset = argv->a_un.a_val;
716
717 argv++;
718 argc--;
719
720 if (offset % sizeof (uintptr_t)) {
721 mdb_warn("offset must fall on a word boundary\n");
722 return (DCMD_ABORT);
723 }
724 } else {
725 const char *member;
726 char buf[MDB_SYM_NAMLEN];
727 int ret;
728
729 ret = args_to_typename(&argc, &argv, buf, sizeof (buf));
730 if (ret != 0)
731 return (ret);
732
733 argv++;
734 argc--;
735
736 member = argv->a_un.a_str;
737 offset = mdb_ctf_offsetof_by_name(buf, member);
738 if (offset == -1)
739 return (DCMD_ABORT);
740
741 argv++;
742 argc--;
743
744 if (offset % (sizeof (uintptr_t)) != 0) {
745 mdb_warn("%s is not a word-aligned member\n", member);
746 return (DCMD_ABORT);
747 }
748 }
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
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 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2013 by Delphix. All rights reserved.
28 * Copyright (c) 2012 Joyent, Inc. All rights reserved.
29 */
30
31 #include <mdb/mdb_modapi.h>
32 #include <mdb/mdb_target.h>
33 #include <mdb/mdb_argvec.h>
34 #include <mdb/mdb_string.h>
35 #include <mdb/mdb_stdlib.h>
36 #include <mdb/mdb_err.h>
37 #include <mdb/mdb_debug.h>
38 #include <mdb/mdb_fmt.h>
39 #include <mdb/mdb_ctf.h>
40 #include <mdb/mdb_ctf_impl.h>
41 #include <mdb/mdb.h>
42 #include <mdb/mdb_tab.h>
43
44 #include <sys/isa_defs.h>
45 #include <sys/param.h>
46 #include <sys/sysmacros.h>
47 #include <netinet/in.h>
690 if (mdb_vcb_find(v, mdb.m_frame) == NULL)
691 mdb_vcb_insert(mdb_vcb_create(v), mdb.m_frame);
692
693 return (0);
694 }
695
696 /*ARGSUSED*/
697 int
698 cmd_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
699 {
700 int offset;
701 uintptr_t a, tmp;
702 int ret;
703
704 if (!(flags & DCMD_ADDRSPEC) || argc == 0)
705 return (DCMD_USAGE);
706
707 if (argv->a_type != MDB_TYPE_STRING) {
708 /*
709 * We are being given a raw offset in lieu of a type and
710 * member; confirm the number of arguments and argument
711 * type.
712 */
713 if (argc != 1 || argv->a_type != MDB_TYPE_IMMEDIATE)
714 return (DCMD_USAGE);
715
716 offset = argv->a_un.a_val;
717
718 argv++;
719 argc--;
720
721 if (offset % sizeof (uintptr_t)) {
722 mdb_warn("offset must fall on a word boundary\n");
723 return (DCMD_ABORT);
724 }
725 } else {
726 const char *member;
727 char buf[MDB_SYM_NAMLEN];
728 int ret;
729
730 /*
731 * Check that we were provided 2 arguments: a type name
732 * and a member of that type.
733 */
734 if (argc != 2)
735 return (DCMD_USAGE);
736
737 ret = args_to_typename(&argc, &argv, buf, sizeof (buf));
738 if (ret != 0)
739 return (ret);
740
741 argv++;
742 argc--;
743
744 member = argv->a_un.a_str;
745 offset = mdb_ctf_offsetof_by_name(buf, member);
746 if (offset == -1)
747 return (DCMD_ABORT);
748
749 argv++;
750 argc--;
751
752 if (offset % (sizeof (uintptr_t)) != 0) {
753 mdb_warn("%s is not a word-aligned member\n", member);
754 return (DCMD_ABORT);
755 }
756 }
|