summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorGordon Ross <gordon.w.ross@gmail.com>2016-10-25 21:40:23 -0400
committerGordon Ross <gwr@nexenta.com>2016-10-25 22:17:42 -0400
commit0a2f8373fc0ba3bb72bcdad91a4e850615d4f12a (patch)
tree38a32bf92883a180b4b1180c8f6ebbaf3a84d129 /usr
parent0543bac1853a7ceaa62e75597e453eb7cf895599 (diff)
downloadillumos-gfx-drm-0a2f8373fc0ba3bb72bcdad91a4e850615d4f12a.tar.gz
Add an mdb example, and fixup mdb Makefiles
Diffstat (limited to 'usr')
-rw-r--r--usr/src/cmd/mdb/Makefile2
-rw-r--r--usr/src/cmd/mdb/Makefile.module2
-rw-r--r--usr/src/cmd/mdb/Makefile.tools10
-rw-r--r--usr/src/cmd/mdb/foo/Makefile19
-rw-r--r--usr/src/cmd/mdb/foo/amd64/Makefile26
-rw-r--r--usr/src/cmd/mdb/foo/foo.c96
-rw-r--r--usr/src/cmd/mdb/foo/ia32/Makefile25
-rw-r--r--usr/src/pkg/manifests/app-example-foo.mf4
8 files changed, 179 insertions, 5 deletions
diff --git a/usr/src/cmd/mdb/Makefile b/usr/src/cmd/mdb/Makefile
index cbb448a..9f21a5d 100644
--- a/usr/src/cmd/mdb/Makefile
+++ b/usr/src/cmd/mdb/Makefile
@@ -29,7 +29,7 @@ include $(SRC)/Makefile.master
.KEEP_STATE:
sparc_SUBDIRS =
-i386_SUBDIRS =
+i386_SUBDIRS = foo
SUBDIRS = $($(MACH)_SUBDIRS)
TARGET =
diff --git a/usr/src/cmd/mdb/Makefile.module b/usr/src/cmd/mdb/Makefile.module
index 01f3fd8..8020774 100644
--- a/usr/src/cmd/mdb/Makefile.module
+++ b/usr/src/cmd/mdb/Makefile.module
@@ -179,7 +179,7 @@ $(KMODFILE): kmod .WAIT $(KMODOBJS) $(MAPFILE)
$(KMDB_FPTEST_CMD)
$(CTFMERGE) -f -L VERSION -o $@ $(KMODOBJS)
$(POST_PROCESS)
- $(SETDYNFLAG) -f DF_1_NOKSYMS $@
+ $(SETDYNFLAG) $@
linktest: linktest_check .WAIT kmod .WAIT $(KMODOBJS)
$(KMDB_LINKTEST)
diff --git a/usr/src/cmd/mdb/Makefile.tools b/usr/src/cmd/mdb/Makefile.tools
index acbbf7f..e901aee 100644
--- a/usr/src/cmd/mdb/Makefile.tools
+++ b/usr/src/cmd/mdb/Makefile.tools
@@ -26,7 +26,11 @@
TOOLSDIR = $(SRC)/cmd/mdb/tools
-#SETDYNFLAG = $(TOOLSDIR)/setdynflag/$(MACH)/setdynflag
-SETDYNFLAG = true TODO
-#FINDFP = $(TOOLSDIR)/findfp/$(MACH)/findfp
+# Set the dynamic.flags1 field to: [ NOKSYMS EDITED ]
+# You can inspect it with: elfedit -e "dyn:flags1" file
+SETDYNFLAG = elfedit -e "dyn:flags1 0x280000"
+
+# FINDFP is only used on sparc anyway.
+# It's probably better to use compiler options to avoid FP instructions,
+# i.e. gcc -msoft-float -mno-sse ...
FINDFP = true TODO
diff --git a/usr/src/cmd/mdb/foo/Makefile b/usr/src/cmd/mdb/foo/Makefile
new file mode 100644
index 0000000..b1cbc27
--- /dev/null
+++ b/usr/src/cmd/mdb/foo/Makefile
@@ -0,0 +1,19 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Gordon Ross <gordon.w.ross@gmail.com>
+#
+
+include $(SRC)/Makefile.master
+SUBDIRS = ia32
+$(BUILD64)SUBDIRS += $(MACH64)
+include ../Makefile.subdirs
diff --git a/usr/src/cmd/mdb/foo/amd64/Makefile b/usr/src/cmd/mdb/foo/amd64/Makefile
new file mode 100644
index 0000000..42f7bec
--- /dev/null
+++ b/usr/src/cmd/mdb/foo/amd64/Makefile
@@ -0,0 +1,26 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Gordon Ross <gordon.w.ross@gmail.com>
+#
+
+MODULE = foo.so
+MDBTGT = kvm
+
+MODSRCS = foo.c
+
+include ../../../Makefile.cmd
+include ../../../Makefile.cmd.64
+include ../../Makefile.amd64
+include ../../Makefile.module
+
+CPPFLAGS += -I$(SRC)/uts/common
diff --git a/usr/src/cmd/mdb/foo/foo.c b/usr/src/cmd/mdb/foo/foo.c
new file mode 100644
index 0000000..2220c02
--- /dev/null
+++ b/usr/src/cmd/mdb/foo/foo.c
@@ -0,0 +1,96 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Gordon Ross <gordon.w.ross@gmail.com>
+ */
+
+/*
+ * Example mdb module: foo
+ */
+#include <sys/mdb_modapi.h>
+#include <sys/foo.h>
+
+/*
+ * One would be correct to observe that a dcmd is unnecessary for
+ * just printing a variable with mdb. This is just an example,
+ * where a more real-world case would print something larger and
+ * more complex than a foocnt_t.
+ */
+
+void
+foo_cnt_help(void)
+{
+ mdb_printf("Print device ID information of Intel graphics card.\n");
+}
+
+/* ARGSUSED */
+static int
+foo_cnt_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+{
+ GElf_Sym sym;
+ foocnt_t count;
+
+ /* Does not take an address. */
+ if (flags & DCMD_ADDRSPEC)
+ return (DCMD_USAGE);
+
+ /* Locate the foo_count variable */
+ if (mdb_lookup_by_obj("foo", "foo_count", &sym)) {
+ mdb_warn("failed to lookup `foo_count'\n");
+ return (DCMD_ERR);
+ }
+ addr = (uintptr_t)sym.st_value;
+
+ if (mdb_vread(&count, sizeof (count), addr) == -1) {
+ mdb_warn("failed to read foo_count at %p", addr);
+ return (DCMD_ERR);
+ }
+
+ mdb_printf("foo_count = %d\n", count);
+
+ return (DCMD_OK);
+}
+
+
+/*
+ * MDB module linkage information:
+ *
+ * We declare a list of structures describing our dcmds, a list of structures
+ * describing our walkers, and a function named _mdb_init to return a pointer
+ * to our module information.
+ */
+
+static const mdb_dcmd_t dcmds[] = {
+ {
+ "foo_cnt",
+ "?",
+ "get foo_count",
+ foo_cnt_dcmd,
+ foo_cnt_help
+ },
+ { NULL }
+};
+
+static const mdb_walker_t walkers[] = {
+ /* none */
+ { NULL }
+};
+
+static const mdb_modinfo_t modinfo = {
+ MDB_API_VERSION, dcmds, walkers
+};
+
+const mdb_modinfo_t *
+_mdb_init(void)
+{
+ return (&modinfo);
+}
diff --git a/usr/src/cmd/mdb/foo/ia32/Makefile b/usr/src/cmd/mdb/foo/ia32/Makefile
new file mode 100644
index 0000000..a9f1187
--- /dev/null
+++ b/usr/src/cmd/mdb/foo/ia32/Makefile
@@ -0,0 +1,25 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Gordon Ross <gordon.w.ross@gmail.com>
+#
+
+MODULE = foo.so
+MDBTGT = kvm
+
+MODSRCS = foo.c
+
+include ../../../Makefile.cmd
+include ../../Makefile.ia32
+include ../../Makefile.module
+
+CPPFLAGS += -I$(SRC)/uts/common
diff --git a/usr/src/pkg/manifests/app-example-foo.mf b/usr/src/pkg/manifests/app-example-foo.mf
index 834d36b..906c190 100644
--- a/usr/src/pkg/manifests/app-example-foo.mf
+++ b/usr/src/pkg/manifests/app-example-foo.mf
@@ -36,6 +36,8 @@ dir path=usr/share/man/man7
file path=kernel/drv/$(ARCH64)/foo
$(i386_ONLY)file path=kernel/drv/foo
file path=kernel/drv/foo.conf
+file path=kernel/kmdb/$(ARCH64)/foo
+$(i386_ONLY)file path=kernel/kmdb/foo
file path=usr/bin/foo mode=0555
file path=usr/include/libfoo/foo.h
file path=usr/lib/$(ARCH64)/libfoo.so.1
@@ -43,6 +45,8 @@ file path=usr/lib/$(ARCH64)/llib-lfoo.ln
file path=usr/lib/libfoo.so.1
file path=usr/lib/llib-lfoo
file path=usr/lib/llib-lfoo.ln
+file path=usr/lib/mdb/kvm/amd64/fo.so
+file path=usr/lib/mdb/kvm/foo.so
file path=usr/share/man/man1/foo.1
file path=usr/share/man/man3x/foo.3x
file path=usr/share/man/man7/foo.7