changeset 12939:a27c46eb192b

6972234 sgs demo's could use some cleanup
author Rod Evans <Rod.Evans@Sun.COM>
date Tue, 27 Jul 2010 22:49:34 -0700
parents 599476a18982
children d7aaf321bd55
files usr/src/cmd/sgs/Makefile.com usr/src/cmd/sgs/Makefile.targ usr/src/cmd/sgs/Makefile.var usr/src/cmd/sgs/elfdump/Makefile.com usr/src/cmd/sgs/ld/Makefile.com usr/src/cmd/sgs/libconv/Makefile.com usr/src/cmd/sgs/libelf/Makefile.com usr/src/cmd/sgs/libelf/Makefile.targ usr/src/cmd/sgs/libelf/Makefile.targ.64 usr/src/cmd/sgs/libelf/demo/00README usr/src/cmd/sgs/libelf/demo/Makefile usr/src/cmd/sgs/libelf/demo/README usr/src/cmd/sgs/libelf/demo/acom.c usr/src/cmd/sgs/libelf/demo/dcom.c usr/src/cmd/sgs/libelf/demo/dispsyms.c usr/src/cmd/sgs/libelf/demo/pcom.c usr/src/cmd/sgs/libelf/demo/tpcom.c usr/src/cmd/sgs/liblddbg/Makefile.com usr/src/cmd/sgs/liblddbg/amd64/Makefile usr/src/cmd/sgs/liblddbg/sparcv9/Makefile usr/src/cmd/sgs/librtld_db/Makefile usr/src/cmd/sgs/librtld_db/Makefile.com usr/src/cmd/sgs/librtld_db/Makefile.targ usr/src/cmd/sgs/librtld_db/demo/00README usr/src/cmd/sgs/librtld_db/demo/Makefile usr/src/cmd/sgs/librtld_db/demo/Makefile.com usr/src/cmd/sgs/librtld_db/demo/Makefile.targ usr/src/cmd/sgs/librtld_db/demo/amd64/Makefile usr/src/cmd/sgs/librtld_db/demo/amd64/rdb_mach.h usr/src/cmd/sgs/librtld_db/demo/amd64/regs.c usr/src/cmd/sgs/librtld_db/demo/common/bpt.c usr/src/cmd/sgs/librtld_db/demo/common/callstack.c usr/src/cmd/sgs/librtld_db/demo/common/dis.c usr/src/cmd/sgs/librtld_db/demo/common/disasm.c usr/src/cmd/sgs/librtld_db/demo/common/disasm.h usr/src/cmd/sgs/librtld_db/demo/common/globals.c usr/src/cmd/sgs/librtld_db/demo/common/gram.y usr/src/cmd/sgs/librtld_db/demo/common/help.c usr/src/cmd/sgs/librtld_db/demo/common/lex.l usr/src/cmd/sgs/librtld_db/demo/common/main.c usr/src/cmd/sgs/librtld_db/demo/common/maps.c usr/src/cmd/sgs/librtld_db/demo/common/ps.c usr/src/cmd/sgs/librtld_db/demo/common/rdb.h usr/src/cmd/sgs/librtld_db/demo/common/rdb.man usr/src/cmd/sgs/librtld_db/demo/common/syms.c usr/src/cmd/sgs/librtld_db/demo/common/utils.c usr/src/cmd/sgs/librtld_db/demo/i386/Makefile usr/src/cmd/sgs/librtld_db/demo/i386/m_utils.c usr/src/cmd/sgs/librtld_db/demo/i386/rdb_mach.h usr/src/cmd/sgs/librtld_db/demo/i386/regs.c usr/src/cmd/sgs/librtld_db/demo/sparc/Makefile usr/src/cmd/sgs/librtld_db/demo/sparc/m_utils.c usr/src/cmd/sgs/librtld_db/demo/sparc/rdb_mach.h usr/src/cmd/sgs/librtld_db/demo/sparc/regs.c usr/src/cmd/sgs/librtld_db/demo/sparcv9/Makefile usr/src/cmd/sgs/librtld_db/demo/sparcv9/m_utils.c usr/src/cmd/sgs/librtld_db/demo/sparcv9/rdb_mach.h usr/src/cmd/sgs/librtld_db/demo/sparcv9/regs.c usr/src/cmd/sgs/librtld_db/demo/tests/breaks usr/src/cmd/sgs/librtld_db/demo/tests/loadmaps usr/src/cmd/sgs/librtld_db/demo/tests/object_padding_maps usr/src/cmd/sgs/librtld_db/demo/tests/plt_skip usr/src/cmd/sgs/librtld_db/demo/tests/simp.c usr/src/cmd/sgs/librtld_db/demo/tests/steps usr/src/cmd/sgs/librtld_db/demo/tests/sub.c usr/src/cmd/sgs/librtld_db/demo/tests/test-sparc-regs usr/src/cmd/sgs/librtld_db/rdb_demo/00README usr/src/cmd/sgs/librtld_db/rdb_demo/Makefile usr/src/cmd/sgs/librtld_db/rdb_demo/Makefile.com usr/src/cmd/sgs/librtld_db/rdb_demo/Makefile.targ usr/src/cmd/sgs/librtld_db/rdb_demo/TODO usr/src/cmd/sgs/librtld_db/rdb_demo/amd64/Makefile usr/src/cmd/sgs/librtld_db/rdb_demo/amd64/rdb_mach.h usr/src/cmd/sgs/librtld_db/rdb_demo/amd64/regs.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/bpt.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/callstack.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/dis.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/disasm.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/disasm.h usr/src/cmd/sgs/librtld_db/rdb_demo/common/globals.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/gram.y usr/src/cmd/sgs/librtld_db/rdb_demo/common/help.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/lex.l usr/src/cmd/sgs/librtld_db/rdb_demo/common/main.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/maps.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/ps.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/rdb.h usr/src/cmd/sgs/librtld_db/rdb_demo/common/rdb.man usr/src/cmd/sgs/librtld_db/rdb_demo/common/syms.c usr/src/cmd/sgs/librtld_db/rdb_demo/common/utils.c usr/src/cmd/sgs/librtld_db/rdb_demo/i386/Makefile usr/src/cmd/sgs/librtld_db/rdb_demo/i386/m_utils.c usr/src/cmd/sgs/librtld_db/rdb_demo/i386/rdb_mach.h usr/src/cmd/sgs/librtld_db/rdb_demo/i386/regs.c usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/Makefile usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/m_utils.c usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/rdb_mach.h usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/regs.c usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/Makefile usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/m_utils.c usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/rdb_mach.h usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/regs.c usr/src/cmd/sgs/librtld_db/rdb_demo/tests/breaks usr/src/cmd/sgs/librtld_db/rdb_demo/tests/loadmaps usr/src/cmd/sgs/librtld_db/rdb_demo/tests/object_padding_maps usr/src/cmd/sgs/librtld_db/rdb_demo/tests/plt_skip usr/src/cmd/sgs/librtld_db/rdb_demo/tests/simp.c usr/src/cmd/sgs/librtld_db/rdb_demo/tests/steps usr/src/cmd/sgs/librtld_db/rdb_demo/tests/sub.c usr/src/cmd/sgs/librtld_db/rdb_demo/tests/test-sparc-regs usr/src/cmd/sgs/link_audit/common/00README usr/src/cmd/sgs/link_audit/common/Makefile.demo usr/src/cmd/sgs/link_audit/common/bindings.c usr/src/cmd/sgs/link_audit/common/bindings.h usr/src/cmd/sgs/link_audit/common/dumpbind.c usr/src/cmd/sgs/link_audit/common/env.c usr/src/cmd/sgs/link_audit/common/env.h usr/src/cmd/sgs/link_audit/common/hash.c usr/src/cmd/sgs/link_audit/common/hash.h usr/src/cmd/sgs/link_audit/common/mach.h usr/src/cmd/sgs/link_audit/common/perfcnt.c usr/src/cmd/sgs/link_audit/common/perfcnt.ksh usr/src/cmd/sgs/link_audit/common/sotruss.ksh usr/src/cmd/sgs/link_audit/common/symbindrep.c usr/src/cmd/sgs/link_audit/common/symbindrep.ksh usr/src/cmd/sgs/link_audit/common/truss.c usr/src/cmd/sgs/link_audit/common/who.c usr/src/cmd/sgs/link_audit/common/who.h usr/src/cmd/sgs/link_audit/common/whocalls.ksh usr/src/cmd/sgs/link_audit/man/dumpbind.man usr/src/cmd/sgs/link_audit/man/perfcnt.man usr/src/cmd/sgs/link_audit/man/symbindrep.man usr/src/cmd/sgs/packages/Makefile usr/src/cmd/sgs/packages/common/SUNWonld-README usr/src/cmd/sgs/packages/common/pkginfo.tmpl usr/src/cmd/sgs/packages/common/prototype_com usr/src/cmd/sgs/rtld/Makefile usr/src/cmd/sgs/rtld/Makefile.com usr/src/cmd/sgs/rtld/common/a.out.c usr/src/cmd/sgs/rtld/i386/Makefile usr/src/cmd/sgs/rtld/mdbmod/Makefile.com usr/src/cmd/sgs/rtld/sparc/Makefile usr/src/cmd/sgs/rtld/sparcv9/Makefile usr/src/pkg/manifests/source-demo-system.mf
diffstat 144 files changed, 5743 insertions(+), 6199 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/sgs/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -20,8 +20,7 @@
 #
 
 #
-# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 .KEEP_STATE:
@@ -59,7 +58,7 @@
 # Reassign CPPFLAGS so that local search paths are used before any parent
 # $ROOT paths.
 CPPFLAGS =	-I. -I../common -I../../include -I../../include/$(MACH) \
-		$(VAR_CPPFLAGS) $(CPPFLAGS.master) -I$(ELFCAP)
+		$(CPPFLAGS.master) -I$(ELFCAP)
 
 # PICS64 is unique to our environment
 $(PICS64) :=	sparc_CFLAGS += -xregs=no%appl -K pic
--- a/usr/src/cmd/sgs/Makefile.targ	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/Makefile.targ	Tue Jul 27 22:49:34 2010 -0700
@@ -20,10 +20,7 @@
 #
 
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 # Standard install rules
@@ -222,20 +219,16 @@
 $(ROOTLIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
 	$(INS.file) ../common/$(LINTLIBSRC)
 
-$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKS): \
-	$(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
-$(VAR_POUND_1)	$(INS.liblink)
+$(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
+	$(INS.liblink)
 
-$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKS): \
-	$(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
-$(VAR_POUND_1)	$(INS.liblink64)
+$(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
+	$(INS.liblink64)
 
-$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): \
-	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS)
-$(VAR_POUND_1)	$(INS.liblinkccc)
+$(ROOTFS_LIBDIR)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)$(VERS)
+	$(INS.liblinkccc)
 
-$(VAR_POUND_1)$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): \
-	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS)
-$(VAR_POUND_1)	$(INS.liblinkccc64)
+$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC): $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)$(VERS)
+	$(INS.liblinkccc64)
 
 FRC:
--- a/usr/src/cmd/sgs/Makefile.var	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/Makefile.var	Tue Jul 27 22:49:34 2010 -0700
@@ -20,8 +20,7 @@
 #
 
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 # The link-editor related source files and Makefile files have at times been
@@ -50,16 +49,12 @@
 #
 # Common Macro definitions
 #
-VAR_CPPFLAGS=
 VAR_LINTFLAGS64=	-m64
 
 VAR_PLAT_sparc=		sparc
 VAR_PLAT_i386=		intel/ia32
 VAR_PLAT_amd64=		intel/amd64
 
-VAR_POUND_1=
-VAR_POUND_2=		$(POUND_SIGN)
-
 #
 # VAR_AVLDIR - directory to find avl.c in.
 #
@@ -105,7 +100,6 @@
 #
 # ld
 #
-VAR_LD_NATIVE_LLDLIBS=
 VAR_LD_LLDFLAGS=	'-R$$ORIGIN/../../lib'
 VAR_LD_LLDFLAGS64 =	'-R$$ORIGIN/../../../lib/$(MACH64)'
 
@@ -127,21 +121,9 @@
 VAR_LDDSTUB_INTERP=	-I'$$ORIGIN/ld.so.1'
 
 #
-# libconv
-#
-VAR_LIBCONV_CPPFLAGS=
-
-#
-# libelf
-#
-VAR_LIBELF_LDLIBS=
-VAR_LIBELF_ROOTDEMODIR_DIRMODE=	755
-
-#
 # libld
 #
-VAR_LIBLD_CPPFLAGS=		$(VAR_COM_CPPFLAGS) \
-				$(VAR_AVLINCDIR)
+VAR_LIBLD_CPPFLAGS=		$(VAR_AVLINCDIR)
 VAR_LIBLD_64_ROOTFS_LIBDIR=	$(ROOT)/lib/$(MACH64)
 
 #
@@ -152,23 +134,10 @@
 #
 # liblddbg
 #
-VAR_LIBLDDBG_V9_ROOTFS_LIBDIR=	$(ROOT)/lib/$(MACH64)
-VAR_LIBLDDBG_CPPFLAGS=-DDEMANGLE
-
-#
-# librtld_db
-#
-VAR_LIBRTLD_DB_RDB_DEMO_LINTFLAGS64=	$(VAR_LINTFLAGS64)
+VAR_LIBLDDBG_64_ROOTFS_LIBDIR=	$(ROOT)/lib/$(MACH64)
 
 #
 # rtld
 #
 VAR_RTLD_CPICLIB=	-L ../../../../lib/libc/$(MACH)
 VAR_RTLD_CPICLIB64=	-L ../../../../lib/libc/$(MACH64)
-VAR_RTLD_SONAME=	/lib/ld.so.1
-VAR_RTLD_V9_SONAME=	/lib/sparcv9/ld.so.1
-
-VAR_RTLD_ETCDYNLIB=
-VAR_RTLD_CPPFEATUREMACROS=
-VAR_RTLD_CPPFLAGS=	$(VAR_AVLINCDIR)
-VAR_RTLD_EXTRASUBDIRS=	mdbmod
--- a/usr/src/cmd/sgs/elfdump/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/elfdump/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -20,8 +20,7 @@
 #
 
 #
-# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 PROG=		elfdump
@@ -51,7 +50,7 @@
 		-I$(SRCBASE)/lib/libc/inc -I$(SRCBASE)/uts/$(ARCH)/sys \
 		$(CPPFLAGS.master) -I$(ELFCAP)
 LLDFLAGS =	$(VAR_ELFDUMP_LLDFLAGS)
-LLDFLAGS64 =	$(VAR_LD_LLDFLAGS64)
+LLDFLAGS64 =	$(VAR_ELFDUMP_LLDFLAGS64)
 LDFLAGS +=	$(VERSREF) $(CC_USE_PROTO) $(MAPOPT) $(LLDFLAGS)
 LDLIBS +=	$(ELFLIBDIR) -lelf $(LDDBGLIBDIR) $(LDDBG_LIB) \
 		    $(CONVLIBDIR) $(CONV_LIB)
--- a/usr/src/cmd/sgs/ld/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/ld/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -20,8 +20,7 @@
 #
 
 #
-# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 PROG =		ld
@@ -49,7 +48,7 @@
 
 native :=	LDFLAGS = -R$(SGSPROTO) $(ZNOVERSION)
 native :=	LDLIBS = -L$(SGSPROTO) $(LD_LIB) -lelf $(CONVLIBDIR) \
-		    $(CONV_LIB) $(VAR_LD_NATIVE_LLDLIBS)
+		    $(CONV_LIB)
 
 BLTDEFS=	msg.h
 BLTDATA=	msg.c
--- a/usr/src/cmd/sgs/libconv/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libconv/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -95,7 +95,7 @@
 PICS=		$(OBJECTS:%=pics/%)
 
 CPPFLAGS +=	-I$(SRCBASE)/lib/libc/inc -I$(ELFCAP) \
-		-I$(SRC)/common/sgsrtcid $(VAR_LIBCONV_CPPFLAGS)
+		-I$(SRC)/common/sgsrtcid
 
 ARFLAGS=	cr
 
--- a/usr/src/cmd/sgs/libelf/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -50,7 +50,7 @@
 
 include $(SRC)/lib/Makefile.lib
 
-DEMOFILES=	Makefile	README		acom.c		dcom.c \
+DEMOFILES=	Makefile	00README	acom.c		dcom.c \
 		pcom.c		tpcom.c		dispsyms.c
 DEMOFILESRCDIR=	../demo
 ROOTDEMODIRBASE=$(ROOT)/usr/demo/ELF
@@ -65,7 +65,7 @@
 CLOBBERFILES +=
 
 DYNFLAGS +=	$(VERSREF)
-LDLIBS +=	$(CONVLIBDIR) $(CONV_LIB) $(VAR_LIBELF_LDLIBS) -lc
+LDLIBS +=	$(CONVLIBDIR) $(CONV_LIB) -lc
 
 LINTFLAGS +=	-u -erroff=E_BAD_PTR_CAST_ALIGN
 LINTFLAGS64 +=	-u -erroff=E_CAST_INT_TO_SMALL_INT
--- a/usr/src/cmd/sgs/libelf/Makefile.targ	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/Makefile.targ	Tue Jul 27 22:49:34 2010 -0700
@@ -19,12 +19,9 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
-$(VAR_POUND_2)LIBS +=	$(LIBRARY)
-
 objs/%.o \
 pics/%.o:	%.c
 		$(COMPILE.c) -o $@ $<
@@ -52,13 +49,11 @@
 		.WAIT $(ROOTDEMODIRS) .WAIT $(ROOTDEMOFILES) \
 		$(ROOTFS_LIBDIR)/$(LINTLIBSRC)
 
-$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
-$(VAR_POUND_1)	$(INS.file) ../common/$(LINTLIBSRC)
+$(ROOTFS_LIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
+		$(VAR_POUND_1)  $(INS.file) ../common/$(LINTLIBSRC)
 
 lint:		$(LINTLIB) $(LINTOUT32) $(LINTOUT64) $(SGSLINTOUT)
 
-$(VAR_POUND_2)lint :=		LIBTHREADFLAG=-lthread
-
 .PARALLEL:	$(LINTOUT32) $(LINTOUT64)
 
 delete:
--- a/usr/src/cmd/sgs/libelf/Makefile.targ.64	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/Makefile.targ.64	Tue Jul 27 22:49:34 2010 -0700
@@ -19,10 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 objs/%.o \
@@ -52,8 +49,6 @@
 
 lint:		$(LINTLIB) $(LINTOUT32) $(LINTOUT64) $(SGSLINTOUT)
 
-$(VAR_POUND_2)lint :=		LIBTHREADFLAG=-lthread
-
 .PARALLEL:	$(LINTOUT32) $(LINTOUT64)
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/libelf/demo/00README	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,68 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+This directory contains sample programs that demonstrate how to use libelf.
+Manual pages for libelf routines are located in section 3e: Library Functions.
+
+Each of these sample programs displays, or manipulates information from a ELF
+file.  Each program uses libelf differently.  To learn more about ELF files
+and their format refer to the "Linker & Libraries Guide", which is part of the
+"Software Developer Collection", and the "System V Application Binary
+Interface".
+
+The following source files are provided:
+
+pcom.c		print comment: prints the .comment section of an ELF file.
+		Demonstrates how to examine a file opened with
+		elf_begin(ELF_C_READ)
+
+acom.c		append comment: appends to, or creates a .comment section
+		within an ELF file.  Demonstrates the updating of a file with
+		elf_begin(ELF_C_RDWR)
+
+dcom.c		delete comment: deletes a .comment section from an ELF file.
+		Demonstrates the creation of a ELF file with
+		elf_begin(ELF_C_WRITE)
+
+tpcom.c		threaded print comment:  a threaded version of pcom.c.
+		Demonstrates that libelf is MT-Safe and can be used by a
+		threaded program.
+
+dispsyms.c	print symbols:  scans a ELF file for any symbol tables
+		(SHT_SYMTAB, SHT_DYNSYM, or SHT_SUNW_LDYNSYM) and
+		displays the symbol tables contents.
+
+Makefile	make file to build the above programs.
+
+
+Building the demos
+------------------
+
+To build the programs:
+
+  % make all
+
+To test the programs:
+
+  % make test
--- a/usr/src/cmd/sgs/libelf/demo/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/demo/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -20,14 +19,11 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
 
 PROGS=		pcom acom dcom tpcom dispsyms
 LDLIBS=		-lelf
-$(VAR_POUND_2)tpcom :=	LDLIBS += -lthread
 
 OBJS=	$(PROGS:%=%.o)
 
--- a/usr/src/cmd/sgs/libelf/demo/README	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-#
-# 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
-# or http://www.opensolaris.org/os/licensing.
-# 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"
-
-This directory contains sample programs that demonstrate how to
-use the libelf library.  Manual pages for libelf routines are
-located in section 3e: Library Functions.
-
-Each of these sample programs displays or manipulates information
-from a ELF file in some way.  Each programs also uses libelf
-differently.  To learn more about ELF files and their format you
-should refer to the "Linker & Libraries section" of the Solaris
-AnswerBook and to the "System V Application Binary Interface"
-printed by Unix Press.
-
-The following is an overview of the source files provided:
-
-pcom.c		print comment: prints the .comment section of ELF
-		files ELF members of archives. Demonstrates how to
-		examine a file opened with elf_begin(ELF_C_READ)
-
-acom.c		append comment: appends to or creates a .comment
-		section for ELF files.  Demonstrates the updating
-		of a file with elf_begin(ELF_C_RDWR)
-
-dcom.c		delete comment: deletes a .comment section from an
-		ELF file.  Demonstrates the creation of a ELF
-		file with elf_begin(ELF_C_WRITE)
-
-tpcom.c		threaded print comment:  a threaded version of pcom.c.
-		Demonstrates that libelf is MT-Hot and can be used
-		in a threaded program.
-
-dispsyms.c	print symbols:  scans a ELF file for any symbol tables
-		(SHT_SYMTAB, SHT_DYNSYM, or SHT_SUNW_LDYNSYM) and
-		displays the symbol tables contents.
-
-Makefile	make file to build the above programs.
-
-
-
-Building the demos
-------------------
-
-Before attempting to build the demos be sure that you have installed a
-Solaris Developer Cluster and a C compiler (purchased separatly) onto
-your system.
-
-To build the programs, do the following:
-
-	% make all
-
-To test the programs, do the following:
-
-	% make test
--- a/usr/src/cmd/sgs/libelf/demo/acom.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/demo/acom.c	Tue Jul 27 22:49:34 2010 -0700
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -46,7 +45,7 @@
 static void
 update_comment(Elf *elf, const char *file, const char *comment)
 {
-	Elf_Scn		*scn = 0;
+	Elf_Scn		*scn = NULL;
 	GElf_Shdr	shdr;
 	Elf_Data	*data;
 	size_t		shstrndx;
@@ -57,13 +56,13 @@
 		return;
 	}
 
-	while ((scn = elf_nextscn(elf, scn)) != 0) {
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
 		/*
 		 * Do a string compare to examine each section header
 		 * to see if it is a ".comment" section.  If it is then
 		 * this is the section we want to process.
 		 */
-		if (gelf_getshdr(scn, &shdr) == 0) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
@@ -73,7 +72,7 @@
 			break;
 	}
 
-	if (scn == 0) {
+	if (scn == NULL) {
 		int	ndx;
 
 		(void) printf("%s has no .comment section.  "
@@ -81,18 +80,18 @@
 		/*
 		 * First add the ".comment" string to the string table
 		 */
-		if ((scn = elf_getscn(elf, shstrndx)) == 0) {
+		if ((scn = elf_getscn(elf, shstrndx)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getscn() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
 		}
-		if ((data = elf_getdata(scn, 0)) == 0) {
+		if ((data = elf_getdata(scn, NULL)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getdata() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
 		}
 		ndx = data->d_off + data->d_size;
-		if ((data = elf_newdata(scn)) == 0) {
+		if ((data = elf_newdata(scn)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_newdata() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
@@ -106,12 +105,12 @@
 		 * Initialize the fields in the Section Header that
 		 * libelf will not fill in.
 		 */
-		if ((scn = elf_newscn(elf)) == 0) {
+		if ((scn = elf_newscn(elf)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_newscn() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
 		}
-		if (gelf_getshdr(scn, &shdr) == 0) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
@@ -127,7 +126,7 @@
 		 * Flush the changes to the underlying elf32 or elf64
 		 * section header.
 		 */
-		gelf_update_shdr(scn, &shdr);
+		(void) gelf_update_shdr(scn, &shdr);
 	}
 
 	if (shdr.sh_addr != 0) {
@@ -136,7 +135,7 @@
 		return;
 	}
 
-	if ((data = elf_newdata(scn)) == 0) {
+	if ((data = elf_newdata(scn)) == NULL) {
 		(void) fprintf(stderr, "%s: elf_getdata() failed: %s\n",
 		    file, elf_errmsg(0));
 		return;
@@ -150,7 +149,6 @@
 		    elf_errmsg(0));
 }
 
-
 int
 main(int argc, char **argv)
 {
--- a/usr/src/cmd/sgs/libelf/demo/dcom.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/demo/dcom.c	Tue Jul 27 22:49:34 2010 -0700
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 
@@ -42,8 +41,6 @@
  * fields required.  This program is *only* an example of how
  * to do this and not a complete program in itself.
  */
-
-
 #include <stdio.h>
 #include <libelf.h>
 #include <gelf.h>
@@ -84,28 +81,19 @@
 	return (tempnam(buffer, 0));
 }
 
-
-
 static void
 delete_comment(Elf *elf, int fd, const char *file)
 {
-	GElf_Ehdr	ehdr;
-	Elf_Scn		*scn = 0;
+	Elf_Scn		*scn = NULL;
 	char		*tfile;
 	Elf		*telf;
-	int		tfd;
-	GElf_Ehdr	tehdr;
-	GElf_Phdr	phdr;
-	GElf_Phdr	tphdr;
-	size_t		shstrndx;
-	size_t		shnum;
-	size_t		phnum;
-	int		*shndx;
-	int		ndx = 1;
-	int		off = 0;
+	GElf_Ehdr	ehdr, tehdr;
+	GElf_Phdr	phdr, tphdr;
+	size_t		shstrndx, shnum, phnum;
+	int		tfd, *shndx, ndx = 1, off = 0;
 	struct stat	sbuf;
 
-	if (gelf_getehdr(elf, &ehdr) == 0) {
+	if (gelf_getehdr(elf, &ehdr) == NULL) {
 		(void) fprintf(stderr, "%s: elf_getehdr() failed: %s\n",
 		    file, elf_errmsg(0));
 		return;
@@ -135,7 +123,7 @@
 	 */
 	shndx = calloc(shnum, sizeof (int));
 
-	while ((scn = elf_nextscn(elf, scn)) != 0) {
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
 		GElf_Shdr	shdr;
 
 		/*
@@ -143,7 +131,7 @@
 		 * to see if it is a ".comment" section.  If it is then
 		 * this is the section we want to process.
 		 */
-		if (gelf_getshdr(scn, &shdr) == 0) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
@@ -184,33 +172,31 @@
 	/*
 	 * Create a new ELF to duplicate the ELF file into.
 	 */
-	if ((telf = elf_begin(tfd, ELF_C_WRITE, 0)) == 0) {
+	if ((telf = elf_begin(tfd, ELF_C_WRITE, 0)) == NULL) {
 		(void) fprintf(stderr, "elf_begin(ELF_C_WRITE) failed: %s\n",
 		    elf_errmsg(0));
 		return;
 	}
 
-	if (gelf_newehdr(telf, gelf_getclass(elf)) == 0) {
+	if (gelf_newehdr(telf, gelf_getclass(elf)) == NULL) {
 		(void) fprintf(stderr, "%s: elf_newehdr() failed: %s\n",
 		    file, elf_errmsg(0));
 		free(shndx);
 		return;
 	}
-	if (gelf_getehdr(telf, &tehdr) == 0) {
+	if (gelf_getehdr(telf, &tehdr) == NULL) {
 		(void) fprintf(stderr, "%s: elf_getehdr() failed: %s\n",
 		    file, elf_errmsg(0));
 		free(shndx);
 		return;
 	}
 
-	scn = 0;
+	scn = NULL;
 	ndx = 1;
-	while ((scn = elf_nextscn(elf, scn)) != 0) {
-		Elf_Scn *	tscn;
-		Elf_Data *	data;
-		Elf_Data *	tdata;
-		GElf_Shdr	shdr;
-		GElf_Shdr	tshdr;
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
+		Elf_Scn		*tscn;
+		Elf_Data	*data, *tdata;
+		GElf_Shdr	shdr, tshdr;
 
 		if (shndx[ndx] == -1) {
 			ndx++;
@@ -221,19 +207,19 @@
 		 * Duplicate all but the .comment section in the
 		 * new file.
 		 */
-		if (gelf_getshdr(scn, &shdr) == 0) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
 			return;
 		}
-		if ((tscn = elf_newscn(telf)) == 0) {
+		if ((tscn = elf_newscn(telf)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_newscn() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
 			return;
 		}
-		if (gelf_getshdr(tscn, &tshdr) == 0) {
+		if (gelf_getshdr(tscn, &tshdr) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
@@ -259,15 +245,15 @@
 		 * Flush the changes to the underlying elf32 or elf64
 		 * section header.
 		 */
-		gelf_update_shdr(tscn, &tshdr);
+		(void) gelf_update_shdr(tscn, &tshdr);
 
-		if ((data = elf_getdata(scn, 0)) == 0) {
+		if ((data = elf_getdata(scn, 0)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getdata() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
 			return;
 		}
-		if ((tdata = elf_newdata(tscn)) == 0) {
+		if ((tdata = elf_newdata(tscn)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_newdata() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
@@ -283,17 +269,18 @@
 	else {
 		Elf_Scn		*_scn;
 		GElf_Shdr	shdr0;
+
 		/*
 		 * 'ELF Extended Sections' are enabled - we must
 		 * store the shstrndx in Shdr[0].sh_link
 		 */
-		if ((_scn = elf_getscn(telf, 0)) == 0) {
+		if ((_scn = elf_getscn(telf, 0)) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getscn() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
 			return;
 		}
-		if (gelf_getshdr(_scn, &shdr0) == 0) {
+		if (gelf_getshdr(_scn, &shdr0) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			free(shndx);
@@ -301,9 +288,9 @@
 		}
 		tehdr.e_shstrndx = SHN_XINDEX;
 		shdr0.sh_link = shndx[shstrndx];
-		gelf_update_shdr(_scn, &shdr0);
+		(void) gelf_update_shdr(_scn, &shdr0);
 	}
-	gelf_update_ehdr(telf, &tehdr);
+	(void) gelf_update_ehdr(telf, &tehdr);
 
 	free(shndx);
 
@@ -311,21 +298,21 @@
 	 * Duplicate all program headers contained in the ELF file.
 	 */
 	if (phnum != 0) {
-		if (gelf_newphdr(telf, phnum) == 0) {
+		if (gelf_newphdr(telf, phnum) == NULL) {
 			(void) fprintf(stderr, "%s: elf_newphdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
 		}
 		for (ndx = 0; ndx < (int)phnum; ndx++) {
-			if (gelf_getphdr(elf, ndx, &phdr) == 0 ||
-			    gelf_getphdr(telf, ndx, &tphdr) == 0) {
+			if (gelf_getphdr(elf, ndx, &phdr) == NULL ||
+			    gelf_getphdr(telf, ndx, &tphdr) == NULL) {
 				(void) fprintf(stderr,
 				    "%s: elf_getphdr() failed: %s\n",
 				    file, elf_errmsg(0));
 				return;
 			}
 			tphdr = phdr;
-			gelf_update_phdr(telf, ndx, &tphdr);
+			(void) gelf_update_phdr(telf, ndx, &tphdr);
 		}
 	}
 
@@ -359,7 +346,6 @@
 	(void) rename(tfile, file);
 }
 
-
 int
 main(int argc, char ** argv)
 {
--- a/usr/src/cmd/sgs/libelf/demo/dispsyms.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/demo/dispsyms.c	Tue Jul 27 22:49:34 2010 -0700
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -37,8 +36,6 @@
  *	  decode a corresponding SHT_SYMTAB_SHNDX
  *	  section if required.
  */
-
-
 #include <stdio.h>
 #include <libelf.h>
 #include <gelf.h>
@@ -72,13 +69,13 @@
 static void
 print_symtab(Elf *elf, const char *file)
 {
-	Elf_Scn		*scn;
+	Elf_Scn		*scn = NULL;
 	GElf_Shdr	shdr;
 	GElf_Ehdr	ehdr;
 	size_t		shstrndx;
 
 
-	if (gelf_getehdr(elf, &ehdr) == 0) {
+	if (gelf_getehdr(elf, &ehdr) == NULL) {
 		(void) fprintf(stderr, "%s: elf_getehdr() failed: %s\n",
 		    file, elf_errmsg(0));
 		return;
@@ -90,15 +87,11 @@
 		return;
 	}
 
-	scn = 0;
-	while ((scn = elf_nextscn(elf, scn)) != 0) {
-		uint_t		symcnt;
-		uint_t		ndx;
-		uint_t		nosymshndx;
-		Elf_Data	*symdata;
-		Elf_Data	*shndxdata;
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
+		uint_t		symcnt, ndx, nosymshndx;
+		Elf_Data	*symdata, *shndxdata;
 
-		if (gelf_getshdr(scn, &shdr) == 0) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
 			(void) fprintf(stderr,
 			    "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
@@ -113,7 +106,7 @@
 		 * Get the data associated with the Symbol
 		 * section.
 		 */
-		if ((symdata = elf_getdata(scn, 0)) == 0) {
+		if ((symdata = elf_getdata(scn, NULL)) == NULL) {
 			(void) fprintf(stderr,
 			    "%s: elf_getdata() failed: %s\n",
 			    file, elf_errmsg(0));
@@ -138,15 +131,11 @@
 		for (ndx = 0; ndx < symcnt; ndx++) {
 			GElf_Sym	sym;
 			Elf32_Word	shndx;
-			uint_t		type;
-			uint_t		bind;
-			uint_t		specshndx;
+			uint_t		type, bind, specshndx;
 			char		bindbuf[INTSTRLEN];
 			char		typebuf[INTSTRLEN];
 			char		shndxbuf[INTSTRLEN];
-			const char	*bindstr;
-			const char	*typestr;
-			const char	*shndxstr;
+			const char	*bindstr, *typestr, *shndxstr;
 
 			/*
 			 * Get a symbol entry
@@ -159,26 +148,26 @@
 				return;
 			}
 			/*
-			 * Check to see if this symbol's st_shndx
-			 * is using the 'Extended SHNDX table' for
-			 * a SYMTAB.
+			 * Check to see if this symbol's st_shndx is using
+			 * the 'Extended SHNDX table' for a SYMTAB.
 			 *
-			 * If it is - and we havn't searched before,
-			 * go find the associated SHT_SYMTAB_SHNDX
-			 * section.
+			 * If it is - and we haven't searched before, go
+			 * find the associated SHT_SYMTAB_SHNDX section.
 			 */
 			if ((sym.st_shndx == SHN_XINDEX) &&
 			    (shndxdata == 0) && (nosymshndx == 0)) {
-				Elf_Scn		*_scn;
+				Elf_Scn		*_scn = NULL;
 				GElf_Shdr	_shdr;
 				GElf_Word	symscnndx;
-				_scn = 0;
+
 				specshndx = 0;
 				symscnndx = elf_ndxscn(scn);
 
-				while ((_scn = elf_nextscn(elf, _scn)) != 0) {
-					if (gelf_getshdr(_scn, &_shdr) == 0)
+				while ((_scn =
+				    elf_nextscn(elf, _scn)) != NULL) {
+					if (gelf_getshdr(_scn, &_shdr) == NULL)
 						break;
+
 					/*
 					 * We've found the Symtab SHNDX table
 					 * if it's of type SHT_SYMTAB_SHNDX
@@ -188,11 +177,10 @@
 					 */
 					if ((_shdr.sh_type ==
 					    SHT_SYMTAB_SHNDX) &&
-					    (_shdr.sh_link == symscnndx)) {
-						if ((shndxdata =
-						    elf_getdata(_scn, 0)) != 0)
-							break;
-					}
+					    (_shdr.sh_link == symscnndx) &&
+					    ((shndxdata = elf_getdata(_scn,
+					    NULL)) != NULL))
+						break;
 				}
 				/*
 				 * Get a symbol entry
@@ -304,10 +292,10 @@
 		 * in turn be examined with libelf.
 		 *
 		 * The below loop will iterate over each member of the
-		 * archive and recursivly call process_elf() for processing.
+		 * archive and recursively call process_elf().
 		 */
 		cmd = ELF_C_READ;
-		while ((_elf = elf_begin(fd, cmd, elf)) != 0) {
+		while ((_elf = elf_begin(fd, cmd, elf)) != NULL) {
 			Elf_Arhdr	*arhdr;
 			char		buffer[1024];
 
@@ -321,7 +309,7 @@
 			    file, arhdr->ar_name);
 
 			/*
-			 * recursivly process the ELF members.
+			 * Recursively process the ELF members.
 			 */
 			process_elf(_elf, buffer, fd, 1);
 			cmd = elf_next(_elf);
@@ -337,13 +325,11 @@
 	}
 }
 
-
 int
 main(int argc, char **argv)
 {
 	int	i;
 
-
 	if (argc < 2) {
 		(void) printf("usage: %s elf_file ...\n", argv[0]);
 		return (1);
--- a/usr/src/cmd/sgs/libelf/demo/pcom.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/demo/pcom.c	Tue Jul 27 22:49:34 2010 -0700
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -47,7 +46,7 @@
 static void
 print_comment(Elf *elf, const char *file)
 {
-	Elf_Scn		*scn = 0;
+	Elf_Scn		*scn = NULL;
 	GElf_Shdr	shdr;
 	Elf_Data	*data;
 	size_t		shstrndx;
@@ -61,13 +60,13 @@
 		return;
 	}
 
-	while ((scn = elf_nextscn(elf, scn)) != 0) {
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
 		/*
 		 * Do a string compare to examine each section header
 		 * to see if it is a ".comment" section.  If it is then
 		 * this is the section we want to process.
 		 */
-		if (gelf_getshdr(scn, &shdr) == 0) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
@@ -81,12 +80,13 @@
 			 * Get the data associated with the .comment
 			 * section.
 			 */
-			if ((data = elf_getdata(scn, 0)) == 0) {
+			if ((data = elf_getdata(scn, NULL)) == NULL) {
 				(void) fprintf(stderr,
 				    "%s: elf_getdata() failed: %s\n",
 				    file, elf_errmsg(0));
 				return;
 			}
+
 			/*
 			 * Data in a .comment section is a list of 'null'
 			 * terminated strings.  The following will print
@@ -104,7 +104,6 @@
 
 }
 
-
 static void
 process_elf(Elf *elf, char *file, int fd, int member)
 {
@@ -125,10 +124,10 @@
 		 * in turn be examined with libelf.
 		 *
 		 * The below loop will iterate over each member of the
-		 * archive and recursivly call process_elf() for processing.
+		 * archive and recursively call process_elf().
 		 */
 		cmd = ELF_C_READ;
-		while ((_elf = elf_begin(fd, cmd, elf)) != 0) {
+		while ((_elf = elf_begin(fd, cmd, elf)) != NULL) {
 			Elf_Arhdr	*arhdr;
 			char		buffer[1024];
 
@@ -141,7 +140,7 @@
 			(void) sprintf(buffer, "%s(%s)", file, arhdr->ar_name);
 
 			/*
-			 * recursivly process the ELF members.
+			 * Recursively process the ELF members.
 			 */
 			process_elf(_elf, buffer, fd, 1);
 			cmd = elf_next(_elf);
@@ -162,7 +161,6 @@
 {
 	int	i;
 
-
 	if (argc < 2) {
 		(void) printf("usage: %s elf_file ...\n", argv[0]);
 		return (1);
--- a/usr/src/cmd/sgs/libelf/demo/tpcom.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/libelf/demo/tpcom.c	Tue Jul 27 22:49:34 2010 -0700
@@ -19,8 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -35,7 +34,6 @@
  * of elf_begin(ELF_C_READ).
  */
 
-
 #include <stdio.h>
 #include <libelf.h>
 #include <gelf.h>
@@ -68,24 +66,24 @@
 static void
 print_comment(Elf *elf, const char *file)
 {
-	Elf_Scn *	scn = 0;
+	Elf_Scn		*scn = NULL;
 	GElf_Shdr	shdr;
-	Elf_Data *	data;
+	Elf_Data	*data;
 	size_t		shstrndx;
 
-
 	if (elf_getshdrstrndx(elf, &shstrndx) == -1) {
 		(void) fprintf(stderr, "%s: elf_getshdrstrndx() failed: %s\n",
 		    file, elf_errmsg(0));
 		return;
 	}
-	while ((scn = elf_nextscn(elf, scn)) != 0) {
+
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
 		/*
 		 * Do a string compare to examine each section header
 		 * to see if it is a ".comment" section.  If it is then
 		 * this is the section we want to process.
 		 */
-		if (gelf_getshdr(scn, &shdr) == 0) {
+		if (gelf_getshdr(scn, &shdr) == NULL) {
 			(void) fprintf(stderr, "%s: elf_getshdr() failed: %s\n",
 			    file, elf_errmsg(0));
 			return;
@@ -96,18 +94,18 @@
 			int	i;
 			char	*ptr;
 
-			mutex_lock(&printlock);
+			(void) mutex_lock(&printlock);
 			(void) printf("%s .comment:\n", file);
 
 			/*
 			 * Get the data associated with the .comment
 			 * section.
 			 */
-			if ((data = elf_getdata(scn, 0)) == 0) {
+			if ((data = elf_getdata(scn, NULL)) == NULL) {
 				(void) fprintf(stderr,
 				    "%s: elf_getdata() failed: %s\n",
 				    file, elf_errmsg(0));
-				mutex_unlock(&printlock);
+				(void) mutex_unlock(&printlock);
 				return;
 			}
 			/*
@@ -122,18 +120,17 @@
 					i += strlen(&ptr[i]);
 				}
 			(void) putchar('\n');
-			mutex_unlock(&printlock);
+			(void) mutex_unlock(&printlock);
 		}
 	}
 
 }
 
-
 static void
-process_elf(pe_args * pep)
+process_elf(pe_args *pep)
 {
 	Elf_Cmd	cmd;
-	Elf *	_elf;
+	Elf	*_elf;
 
 	switch (elf_kind(pep->pe_elf)) {
 	case ELF_K_ELF:
@@ -142,12 +139,12 @@
 	case ELF_K_AR:
 		cmd = ELF_C_READ;
 		while ((_elf = elf_begin(pep->pe_fd, cmd,
-		    pep->pe_elf)) != 0) {
-			Elf_Arhdr *	arhdr;
-			pe_args *	_pep;
+		    pep->pe_elf)) != NULL) {
+			Elf_Arhdr	*arhdr;
+			pe_args		*_pep;
 			int		rc;
 
-			if ((arhdr = elf_getarhdr(_elf)) == 0) {
+			if ((arhdr = elf_getarhdr(_elf)) == NULL) {
 				(void) fprintf(stderr,
 				    "%s: elf_getarhdr() failed: %s\n",
 				    pep->pe_file, elf_errmsg(0));
@@ -161,6 +158,7 @@
 			    "%s(%s)", pep->pe_file, arhdr->ar_name);
 			_pep->pe_fd = pep->pe_fd;
 			_pep->pe_member = 1;
+
 			if ((rc = thr_create(NULL, 0,
 			    (void *(*)(void *))process_elf,
 			    (void *)_pep, THR_DETACHED, 0)) != 0) {
@@ -171,11 +169,11 @@
 		break;
 	default:
 		if (!pep->pe_member) {
-			mutex_lock(&printlock);
+			(void) mutex_lock(&printlock);
 			(void) fprintf(stderr,
 			    "%s: unexpected elf_kind(): 0x%x\n",
 			    pep->pe_file, elf_kind(pep->pe_elf));
-			mutex_unlock(&printlock);
+			(void) mutex_unlock(&printlock);
 		}
 	}
 
@@ -191,7 +189,6 @@
 {
 	int	i;
 
-
 	if (argc < 2) {
 		(void) printf("usage: %s elf_file ...\n", argv[0]);
 		return (1);
@@ -235,10 +232,10 @@
 		 * for each file.
 		 */
 		if ((elf = elf_begin(fd, ELF_C_READ, 0)) == NULL) {
-			mutex_lock(&printlock);
+			(void) mutex_lock(&printlock);
 			(void) fprintf(stderr, "elf_begin() failed: %s\n",
 			    elf_errmsg(0));
-			mutex_unlock(&printlock);
+			(void) mutex_unlock(&printlock);
 			(void) close(fd);
 			continue;
 		}
@@ -249,10 +246,10 @@
 		pep->pe_member = 0;
 		if ((rc = thr_create(NULL, 0, (void *(*)(void *))process_elf,
 		    (void *)pep, THR_DETACHED, 0)) != 0) {
-			mutex_lock(&printlock);
+			(void) mutex_lock(&printlock);
 			(void) fprintf(stderr,
 			    "thr_create() failed with code: %d\n", rc);
-			mutex_unlock(&printlock);
+			(void) mutex_unlock(&printlock);
 			return (1);
 		}
 	}
--- a/usr/src/cmd/sgs/liblddbg/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/liblddbg/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -20,8 +20,7 @@
 #
 
 #
-# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 LIBRARY =	liblddbg.a
@@ -59,7 +58,7 @@
 LINTFLAGS +=	-u -D_REENTRANT
 LINTFLAGS64 +=	-u -D_REENTRANT
 
-CPPFLAGS +=	-I$(SRCBASE)/lib/libc/inc $(VAR_LIBLDDBG_CPPFLAGS)
+CPPFLAGS +=	-I$(SRCBASE)/lib/libc/inc
 DYNFLAGS +=	$(VERSREF) $(CC_USE_PROTO) '-R$$ORIGIN'
 LDLIBS +=	$(CONVLIBDIR) $(CONV_LIB) -lc
 
--- a/usr/src/cmd/sgs/liblddbg/amd64/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/liblddbg/amd64/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -20,16 +20,13 @@
 #
 
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 include		../Makefile.com
 
 ROOTFS_LIBDIR64 = \
-		$(VAR_LIBLDDBG_V9_ROOTFS_LIBDIR)
+		$(VAR_LIBLDDBG_64_ROOTFS_LIBDIR)
 ROOTFS_DYNLIB64 = \
 		$(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
 
--- a/usr/src/cmd/sgs/liblddbg/sparcv9/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/liblddbg/sparcv9/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -20,16 +20,13 @@
 #
 
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 include		../Makefile.com
 
 ROOTFS_LIBDIR64 = \
-		$(VAR_LIBLDDBG_V9_ROOTFS_LIBDIR)
+		$(VAR_LIBLDDBG_64_ROOTFS_LIBDIR)
 ROOTFS_DYNLIB64 = \
 		$(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
 
--- a/usr/src/cmd/sgs/librtld_db/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/librtld_db/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -20,10 +19,7 @@
 # CDDL HEADER END
 #
 #
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 2001 by Sun Microsystems, Inc.
-# All rights reserved.
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
 
-EXTRASUBDIRS=	rdb_demo
+EXTRASUBDIRS =	demo
 include		$(SRC)/cmd/sgs/Makefile.sub
--- a/usr/src/cmd/sgs/librtld_db/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/librtld_db/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -19,10 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 LIBRARY=	librtld_db.a
@@ -76,6 +73,3 @@
 
 pics/rd_elf.o :=	CERRWARN += -erroff=E_END_OF_LOOP_CODE_NOT_REACHED
 pics/rd_elf64.o :=	CERRWARN += -erroff=E_END_OF_LOOP_CODE_NOT_REACHED
-
-$(VAR_POUND_1)$(ROOTFS_LIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
-	$(VAR_POUND_1)$(INS.file) ../common/$(LINTLIBSRC)
--- a/usr/src/cmd/sgs/librtld_db/Makefile.targ	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/librtld_db/Makefile.targ	Tue Jul 27 22:49:34 2010 -0700
@@ -19,10 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 pics/%.o:	../common/%.c
@@ -39,6 +36,9 @@
 		$(COMPILE.c) -D_ELF64 $(PICFLAGS) -o $@ $<
 		$(POST_PROCESS_O)
 
+$(ROOTFS_LIBDIR)/$(LINTLIBSRC): ../common/$(LINTLIBSRC)
+		$(INS.file) ../common/$(LINTLIBSRC)
+
 delete:
 		-$(RM) $(DYNLIB)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/00README	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,61 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+This directory contains source code to the rdb debugger.  This debugger
+is distributed as an example client of the librtld_db.so.1 interface.
+As well as offering examples of the proper calling sequence for the
+librtld_db.so.1 interface rdb also offers a sample implementation of the
+proc_services (/usr/include/proc_service.h) that rdb is dependent upon.
+
+The following is an overview of the directory structure and highlight
+of some of the important files contained within:
+
+rdb.man		- man page for the rdb debugger
+Makefile.com
+Makefile.targ	- common Makefiles included by ${MACH)/Makefile
+common/*	- common source code used for all architectures
+amd64/		- build directory contains architecture specific source files
+i386/		 	"	"	"	"
+sparc/			"	"	"	"
+sparcv9/		"	"	"	"
+amd64/Makefile	- makefiles to build rdb for each architecture
+i386/Makefile		"	"	"	"
+sparc/Makefil		"	"	"	"
+sparcv9/Makefil		"	"	"	"
+test/*		- sample command files which can be used to test rdb
+
+
+Building rdb
+------------
+
+To build rdb:
+
+ % cd {amd64,i386,sparc,sparcv9}	- depending on which architecture
+					  you are building for
+ % make all
+
+To test the demo:
+
+ % make test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,133 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+
+include		$(SRC)/Makefile.master
+
+MACHDEMOFILES= \
+		i386/regs.c \
+		i386/m_utils.c \
+		i386/rdb_mach.h \
+		i386/Makefile \
+		amd64/regs.c \
+		amd64/rdb_mach.h \
+		amd64/Makefile \
+		sparc/regs.c \
+		sparc/m_utils.c \
+		sparc/rdb_mach.h \
+		sparc/Makefile \
+		sparcv9/regs.c \
+		sparcv9/m_utils.c \
+		sparcv9/rdb_mach.h \
+		sparcv9/Makefile
+
+DEMOFILES= \
+		00README \
+		Makefile.com \
+		Makefile.targ \
+		common/bpt.c \
+		common/dis.c \
+		common/disasm.c \
+		common/disasm.h \
+		common/main.c \
+		common/ps.c \
+		common/gram.y \
+		common/lex.l \
+		common/globals.c \
+		common/help.c \
+		common/utils.c \
+		common/maps.c \
+		common/syms.c \
+		common/callstack.c \
+		common/rdb.h \
+		common/rdb.man \
+		tests/breaks \
+		tests/loadmaps \
+		tests/object_padding_maps \
+		tests/plt_skip \
+		tests/steps \
+		tests/test-sparc-regs \
+		tests/simp.c \
+		tests/sub.c \
+		$(MACHDEMOFILES)
+
+ROOTDEMODIRBASE=	$(ROOT)/usr/demo/librtld_db
+
+ROOTDEMODIRS=	$(ROOTDEMODIRBASE) \
+		$(ROOTDEMODIRBASE)/common \
+		$(ROOTDEMODIRBASE)/tests \
+		$(ROOTDEMODIRBASE)/i386 \
+		$(ROOTDEMODIRBASE)/amd64 \
+		$(ROOTDEMODIRBASE)/sparc \
+		$(ROOTDEMODIRBASE)/sparcv9
+
+ROOTDEMOFILES=	$(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
+
+$(ROOTDEMODIRS) :=	DIRMODE =	755
+
+SED=		sed -e "/DEMO DELETE START/,/DEMO DELETE END/d"
+
+CLEANFILES=	*.demo */*.demo
+
+.KEEP_STATE:
+.PARALLEL:	$(ROOTDEMOFILES)
+
+all catalog chkmsg lint:
+
+install:	$(ROOTDEMODIRS) .WAIT $(ROOTDEMOFILES)
+
+clean clobber: FRC
+		$(RM) $(CLEANFILES)
+
+$(ROOTDEMODIRS):
+		$(INS.dir)
+
+$(ROOTDEMODIRBASE)/Makefile.%: Makefile.%.demo
+		$(INS.rename)
+
+$(ROOTDEMODIRBASE)/%/Makefile: %/Makefile.demo
+		$(INS.rename)
+
+Makefile.%.demo: Makefile.%
+		$(SED) < $< > $@
+
+%/Makefile.demo: %/Makefile
+		$(SED) < $< > $@
+
+$(ROOTDEMODIRBASE)/%: %
+		$(INS.file)
+
+$(ROOTDEMODIRBASE)/common/%:	common/%
+		$(INS.file)
+
+$(ROOTDEMODIRBASE)/tests/%:	tests/%
+		$(INS.file)
+
+$(ROOTDEMODIRBASE)/sparc/%:	sparc/%
+		$(INS.file)
+
+$(ROOTDEMODIRBASE)/sparcv9/%:	sparcv9/%
+		$(INS.file)
+
+$(ROOTDEMODIRBASE)/i386/%:	i386/%
+		$(INS.file)
+
+FRC:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,82 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+
+PROG=		rdb
+
+# DEMO DELETE START
+include 	../../../../Makefile.cmd
+# DEMO DELETE END
+
+MACH:sh=	uname -p
+
+CFLAGS +=	$(DEMOCFLAGS)
+
+COMSRC=		bpt.c dis.c main.c ps.c gram.c lex.c globals.c help.c \
+		utils.c maps.c syms.c callstack.c disasm.c
+M_SRC=		regs.c m_utils.c
+
+BLTSRC=		gram.c lex.c
+BLTHDR=		gram.h
+
+# DEMO DELETE START
+ONLDLIBDIR=	/opt/SUNWonld/lib
+
+# DEMO DELETE END
+OBJDIR=		objs
+OBJS =		$(COMSRC:%.c=$(OBJDIR)/%.o) $(M_SRC:%.c=$(OBJDIR)/%.o)
+
+SRCS =		$(COMSRC:%=../common/%) $(M_SRC)
+
+MV =		mv
+
+.PARALLEL:	$(OBJS)
+
+CPPFLAGS=	-I../common -I. $(CPPFLAGS.master)
+LDLIBS +=	-lrtld_db -lelf -ll -ly
+
+CLEANFILES +=	$(BLTSRC) $(BLTHDR) simp libsub.so.1
+
+# DEMO DELETE START
+# The following lint error suppression definitions are to remove lex errors
+# we have no control over.
+LINTERRS =	-erroff=E_NAME_DEF_NOT_USED2 \
+		-erroff=E_FUNC_RET_ALWAYS_IGNOR2 \
+		-erroff=E_FUNC_RET_MAYBE_IGNORED2 \
+		-erroff=E_BLOCK_DECL_UNUSED \
+		-erroff=E_EQUALITY_NOT_ASSIGNMENT
+LINTFLAGS +=	$(LDLIBS) -L../../$(MACH) $(LINTERRS)
+LINTFLAGS64 +=	$(LDLIBS) -L../../$(MACH) $(LINTERRS)
+CLEANFILES +=	$(LINTOUT)
+# DEMO DELETE END
+
+test-sparc=	test-sparc-regs
+test-i386=	
+TESTS=		test-maps test-breaks test-steps test-plt_skip \
+		    test-object-padding $(test-$(MACH))
+
+# DEMO DELETE START
+ROOTONLDBIN=		$(ROOT)/opt/SUNWonld/bin
+ROOTONLDBINPROG=	$(PROG:%=$(ROOTONLDBIN)/%)
+ROOTONLDBINPROG64=	$(PROG:%=$(ROOTONLDBIN)/$(MACH64)/%)
+
+FILEMODE=	0755
+# DEMO DELETE END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/Makefile.targ	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,101 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+
+$(OBJDIR)/%.o:	%.c
+		$(COMPILE.c) $< -o $@
+		$(POST_PROCESS_O)
+
+$(OBJDIR)/%.o:	../common/%.c
+		$(COMPILE.c) $< -o $@
+		$(POST_PROCESS_O)
+
+# DEMO DELETE START
+$(ROOTONLDBIN)/%: %
+		$(INS.file)
+
+$(ROOTONLDBIN)/$(MACH64)/%: %
+		$(INS.file)
+# DEMO DELETE END
+
+$(OBJDIR)/main.o: gram.h
+
+gram.c + gram.h: ../common/gram.y
+		$(YACC) -d ../common/gram.y
+		$(MV) y.tab.c gram.c
+		$(MV) y.tab.h gram.h
+
+lex.c: ../common/lex.l
+		$(LEX) ../common/lex.l
+		$(MV) lex.yy.c lex.c
+
+$(PROG):	$(OBJS)
+		$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
+# DEMO DELETE START
+		$(POST_PROCESS)
+# DEMO DELETE END
+
+
+simp: ../tests/simp.c libsub.so.1
+		$(LINK.c) $(LDFLAG) -o $@ ../tests/simp.c -R. ./libsub.so.1
+
+libsub.so.1: ../tests/sub.c
+		$(LINK.c) $(LDFLAG) -o $@ -G -Kpic -hlibsub.so.1 ../tests/sub.c
+
+#
+# RDB sample runs & tests
+#
+test-maps: simp FRC
+		./rdb -f ../tests/loadmaps ./simp
+
+test-breaks: simp FRC
+		./rdb -f ../tests/breaks ./simp
+
+test-steps: simp FRC
+		./rdb -f ../tests/steps ./simp
+
+test-plt_skip: simp FRC
+		./rdb -f ../tests/plt_skip ./simp
+
+test-sparc-regs: simp FRC
+		./rdb -f ../tests/test-sparc-regs simp
+
+test-object-padding: simp FRC
+		./rdb -f ../tests/object_padding_maps simp
+
+$(OBJDIR):
+		-@mkdir -p $(OBJDIR)
+
+clean: FRC
+		$(RM) $(OBJS) $(CLEANFILES)
+
+clobber: clean FRC
+		$(RM) $(PROG)
+
+FRC:
+
+# DEMO DELETE START
+
+$(LINTOUT):	$(SRCS)
+		$(LINT.c) $(SRCS) > lint.out 2>&1
+
+include		$(SRC)/cmd/sgs/Makefile.targ
+# DEMO DELETE END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/amd64/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,63 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include		../Makefile.com
+
+CPPFLAGS +=	-D_SYSCALL32
+
+# DEMO DELETE START
+CCVERBOSE=
+
+LDFLAGS=	-L ../../$(MACH64) \
+		-L ../../../libelf/$(MACH64)
+
+# DEMO DELETE END
+
+# Change -m64 to -xarch=generic64 for use with older Sun compilers.
+DEMOCFLAGS=	-m64
+
+.KEEP_STATE:
+
+all:		$(OBJDIR) .WAIT $(PROG)
+
+test:		$(TESTS)
+
+# DEMO DELETE START
+DEMOCFLAGS=
+
+install:	all $(ROOTONLDBINPROG64)
+
+lint:		$(LINTOUT)
+# DEMO DELETE END
+
+include		../Makefile.targ
+
+$(OBJDIR)/%.o:	../i386/%.c
+		$(COMPILE.c) $< -o $@
+		$(POST_PROCESS_O)
+
+# DEMO DELETE START
+include		../../../../../Makefile.master.64
+# DEMO DELETE END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/amd64/rdb_mach.h	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,53 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#ifndef _RDB_MACH_H
+#define	_RDB_MACH_H
+
+#include <sys/regset.h>
+#include <sys/psw.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define	ERRBIT	PS_C
+#define	R_PS	REG_RFL
+
+/*
+ * Breakpoint instruction
+ */
+typedef	unsigned char	bptinstr_t;
+#define	BPINSTR		0xcc		/* int	3 */
+
+/*
+ * PLT section type
+ */
+#define	PLTSECTT	SHT_PROGBITS
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* _RDB_MACH_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/amd64/regs.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,73 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/reg.h>
+#include <sys/machelf.h>
+
+#include "rdb.h"
+
+static void
+disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
+    char *r2, int ind2)
+{
+	char	str1[MAXPATHLEN], str2[MAXPATHLEN];
+
+	(void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
+	    FLG_PAP_NOHEXNAME));
+
+	(void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
+	    FLG_PAP_NOHEXNAME));
+
+	(void) printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n", r1,
+	    EC_WORD(prst->pr_lwp.pr_reg[ind1]), str1, r2,
+	    EC_WORD(prst->pr_lwp.pr_reg[ind2]), str2);
+}
+
+retc_t
+display_all_regs(struct ps_prochandle *ph)
+{
+	pstatus_t	pstatus;
+
+	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+	    0) == -1) {
+		perror("dar: reading status");
+		return (RET_FAILED);
+	}
+	(void) printf("registers:\n");
+	disp_reg_line(ph, &pstatus, "gs", REG_GS, "fs", REG_FS);
+	disp_reg_line(ph, &pstatus, "es", REG_ES, "ds", REG_DS);
+	disp_reg_line(ph, &pstatus, "rdi", REG_RDI, "rsi", REG_RSI);
+	disp_reg_line(ph, &pstatus, "rbp", REG_RBP, "rsp", REG_RSP);
+	disp_reg_line(ph, &pstatus, "rbx", REG_RBX, "rdx", REG_RDX);
+	disp_reg_line(ph, &pstatus, "rcx", REG_RCX, "rax", REG_RAX);
+	disp_reg_line(ph, &pstatus, "trapno", REG_TRAPNO, "err", REG_ERR);
+	disp_reg_line(ph, &pstatus, "rip", REG_RIP, "cs", REG_CS);
+	disp_reg_line(ph, &pstatus, "rfl", REG_RFL, "uesp", REG_RSP);
+	return (RET_OK);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/bpt.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,536 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/uio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/fault.h>
+#include <sys/syscall.h>
+#include <procfs.h>
+#include <sys/auxv.h>
+#include <libelf.h>
+#include <sys/param.h>
+#include <sys/machelf.h>
+#include <stdarg.h>
+
+#include "rdb.h"
+
+static const char *fault_strings[] = {
+	"<null string>",
+	"illegal instruction",
+	"privileged instruction",
+	"breakpoint instruction",
+	"trace trap (single-step)",
+	"Memory access (e.g., alignment)",
+	"Memory bounds (invalid address)",
+	"Integer overflow",
+	"Integer zero divide"
+	"Floating-point exception",
+	"Irrecoverable stack faul",
+	"Recoverable page fault (no associated sig)"
+};
+
+#define	MAXFAULT	FLTPAGE
+
+retc_t
+set_breakpoint(struct ps_prochandle *ph, ulong_t addr, unsigned flags)
+{
+	bptlist_t	*new, *cur, *prev;
+
+	for (cur = ph->pp_breakpoints, prev = NULL;
+	    (cur && (cur->bl_addr < addr));
+	    prev = cur, cur = cur->bl_next)
+		;
+	if (cur && (cur->bl_addr == addr)) {
+		/*
+		 * already have break point set here.
+		 */
+		cur->bl_flags |= flags;
+		return (RET_OK);
+	}
+
+	new = malloc(sizeof (bptlist_t));
+	new->bl_addr = addr;
+	new->bl_flags = flags;
+	if (prev == NULL) {
+		/*
+		 * insert at head
+		 */
+		new->bl_next = ph->pp_breakpoints;
+		ph->pp_breakpoints = new;
+		return (RET_OK);
+	}
+
+	prev->bl_next = new;
+	new->bl_next = cur;
+	return (RET_OK);
+}
+
+static bptlist_t *
+find_bp(struct ps_prochandle *ph, ulong_t addr)
+{
+	bptlist_t	*cur;
+
+	for (cur = ph->pp_breakpoints;
+	    (cur && (cur->bl_addr != addr));
+	    cur = cur->bl_next)
+		;
+
+	if ((cur == NULL) || (cur->bl_addr != addr))
+		return ((bptlist_t *)-1);
+	return (cur);
+}
+
+static retc_t
+delete_bp(struct ps_prochandle *ph, ulong_t addr)
+{
+	bptlist_t	*cur, *prev;
+
+	for (cur = ph->pp_breakpoints, prev = NULL;
+	    (cur && (cur->bl_addr < addr));
+	    prev = cur, cur = cur->bl_next)
+		;
+	if ((cur == NULL) || (cur->bl_addr != addr))
+		return (RET_FAILED);
+
+	if (prev == NULL)
+		ph->pp_breakpoints = cur->bl_next;
+	else
+		prev->bl_next = cur->bl_next;
+
+	free(cur);
+	return (RET_OK);
+}
+
+void
+list_breakpoints(struct ps_prochandle *ph)
+{
+	bptlist_t	*cur;
+
+	if (ph->pp_breakpoints == NULL) {
+		(void) printf("no active breakpoints.\n");
+		return;
+	}
+
+	(void) printf("active breakpoints:\n");
+	for (cur = ph->pp_breakpoints; cur; cur = cur->bl_next) {
+		(void) printf("\t0x%08lx:0x%04x - %s\n", cur->bl_addr,
+		    cur->bl_flags, print_address_ps(ph, cur->bl_addr,
+		    FLG_PAP_SONAME));
+	}
+}
+
+static void
+set_breaks(struct ps_prochandle *ph)
+{
+	bptlist_t	*cur;
+	bptinstr_t	bpt_instr = BPINSTR;
+
+	for (cur = ph->pp_breakpoints; cur; cur = cur->bl_next) {
+		bptinstr_t	old_inst = 0;
+
+		if (ps_pread(ph, cur->bl_addr, (char *)&old_inst,
+		    sizeof (bptinstr_t)) != PS_OK)
+			perr("sb: error setting breakpoint");
+
+		cur->bl_instr = old_inst;
+
+		if (ps_pwrite(ph, cur->bl_addr, (char *)&bpt_instr,
+		    sizeof (bptinstr_t)) != PS_OK)
+			perr("sb1: error setting breakpoint\n");
+	}
+
+}
+
+static void
+clear_breaks(struct ps_prochandle *ph)
+{
+	bptlist_t	*cur;
+
+	/*
+	 * Restore all the original instructions
+	 */
+	for (cur = ph->pp_breakpoints; cur; cur = cur->bl_next)
+		if (ps_pwrite(ph, cur->bl_addr, (char *)&(cur->bl_instr),
+		    sizeof (bptinstr_t)) != PS_OK)
+			perr("cb: error clearing breakpoint");
+}
+
+retc_t
+delete_all_breakpoints(struct ps_prochandle *ph)
+{
+	bptlist_t	*cur, *prev;
+
+	if (ph->pp_breakpoints == NULL)
+		return (RET_OK);
+
+	for (prev = NULL, cur = ph->pp_breakpoints;
+	    cur; prev = cur, cur = cur->bl_next)
+		if (prev)
+			free(prev);
+	if (prev)
+		free(prev);
+
+	ph->pp_breakpoints = NULL;
+	return (RET_OK);
+}
+
+retc_t
+delete_breakpoint(struct ps_prochandle *ph, ulong_t addr, unsigned flags)
+{
+	bptlist_t	*bpt;
+
+	if (((bpt = find_bp(ph, addr)) == (bptlist_t *)-1) ||
+	    ((bpt->bl_flags & flags) == 0))
+		return (RET_FAILED);
+
+	bpt->bl_flags &= ~flags;
+	if (bpt->bl_flags)
+		return (RET_OK);
+
+	return (delete_bp(ph, addr));
+}
+
+static void
+handle_sp_break(struct ps_prochandle *ph)
+{
+	rd_event_msg_t	emt;
+
+	if (rd_event_getmsg(ph->pp_rap, &emt) != RD_OK) {
+		(void) fprintf(stderr, "hsb: failed rd_event_getmsg()\n");
+		return;
+	}
+
+	if (emt.type == RD_DLACTIVITY) {
+		if (emt.u.state == RD_CONSISTENT)
+			ph->pp_flags |= FLG_PP_LMAPS;
+		else
+			ph->pp_flags &= ~FLG_PP_LMAPS;
+		if ((rdb_flags & RDB_FL_EVENTS) == 0)
+			return;
+
+		(void) printf("dlactivity: state changed to: ");
+		switch (emt.u.state) {
+		case RD_CONSISTENT:
+			(void) printf("RD_CONSISTENT\n");
+			break;
+		case RD_ADD:
+			(void) printf("RD_ADD\n");
+			break;
+		case RD_DELETE:
+			(void) printf("RD_DELETE\n");
+			break;
+		default:
+			(void) printf("unknown: 0x%x\n", emt.u.state);
+		}
+		return;
+	}
+
+	if ((rdb_flags & RDB_FL_EVENTS) == 0)
+		return;
+
+	if (emt.type == RD_PREINIT) {
+		(void) printf("preinit reached\n");
+		return;
+	}
+
+	if (emt.type == RD_POSTINIT)
+		(void) printf("postinit reached\n");
+}
+
+unsigned
+continue_to_break(struct ps_prochandle *ph)
+{
+	bptlist_t	*bpt;
+	pstatus_t	pstatus;
+	struct iovec	piov[5];
+	long		oper1, oper2, oper3, pflags = 0;
+	fltset_t	faults;
+
+	/*
+	 * We step by the first instruction incase their was
+	 * a break-point there.
+	 */
+	(void) step_n(ph, 1, FLG_SN_NONE);
+
+	premptyset(&faults);
+	praddset(&faults, FLTBPT);
+	praddset(&faults, FLTILL);
+	praddset(&faults, FLTPRIV);
+	praddset(&faults, FLTACCESS);
+	praddset(&faults, FLTBOUNDS);
+	praddset(&faults, FLTIZDIV);
+	praddset(&faults, FLTSTACK);
+	praddset(&faults, FLTTRACE);
+
+
+	/* LINTED CONSTANT */
+	while (1) {
+		set_breaks(ph);
+		oper1 = PCSFAULT;
+		piov[0].iov_base = (caddr_t)(&oper1);
+		piov[0].iov_len = sizeof (oper1);
+
+		piov[1].iov_base = (caddr_t)(&faults);
+		piov[1].iov_len = sizeof (faults);
+
+		oper2 = PCRUN;
+		piov[2].iov_base = (caddr_t)(&oper2);
+		piov[2].iov_len = sizeof (oper2);
+		pflags = PRCFAULT;
+		piov[3].iov_base = (caddr_t)(&pflags);
+		piov[3].iov_len = sizeof (pflags);
+
+		oper3 = PCWSTOP;
+		piov[4].iov_base = (caddr_t)(&oper3);
+		piov[4].iov_len = sizeof (oper3);
+
+		if (writev(ph->pp_ctlfd, piov, 5) == -1) {
+			if (errno == ENOENT) {
+				ph->pp_flags &= ~FLG_PP_PACT;
+
+				(void) ps_close(ph);
+				(void) printf("process terminated.\n");
+				return (0);
+			}
+			perr("ctb: PCWSTOP");
+		}
+
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
+			perr("ctb: reading status");
+
+
+		if ((pstatus.pr_lwp.pr_why != PR_FAULTED) ||
+		    (pstatus.pr_lwp.pr_what != FLTBPT)) {
+			const char	*fltmsg;
+
+			if ((pstatus.pr_lwp.pr_what <= MAXFAULT) &&
+			    (pstatus.pr_lwp.pr_why == PR_FAULTED))
+				fltmsg = fault_strings[pstatus.pr_lwp.pr_what];
+			else
+				fltmsg = "<unknown error>";
+
+			(void) fprintf(stderr, "ctb: bad stop - stopped "
+			    "on why: 0x%x what: %s(0x%x)\n",
+			    pstatus.pr_lwp.pr_why, fltmsg,
+			    pstatus.pr_lwp.pr_what);
+			return (0);
+		}
+
+		oper1 = PCCFAULT;
+		if (writev(ph->pp_ctlfd, piov, 1) == -1)
+			perr("ctb: PCCFAULT");
+
+		if ((bpt = find_bp(ph, pstatus.pr_lwp.pr_reg[R_PC])) ==
+		    (bptlist_t *)-1) {
+			(void) fprintf(stderr,
+			    "stopped at unregistered breakpoint! "
+			    "addr: 0x%x\n",
+			    EC_WORD(pstatus.pr_lwp.pr_reg[R_PC]));
+			break;
+		}
+		clear_breaks(ph);
+
+		/*
+		 * If this was a BP at which we should stop
+		 */
+		if (bpt->bl_flags & MASK_BP_STOP)
+			break;
+
+		(void) step_n(ph, 1, FLG_SN_NONE);
+	}
+
+	if (bpt->bl_flags & FLG_BP_USERDEF)
+		(void) printf("break point reached at addr: 0x%x\n",
+		    EC_WORD(pstatus.pr_lwp.pr_reg[R_PC]));
+
+	if (bpt->bl_flags & MASK_BP_SPECIAL)
+		handle_sp_break(ph);
+
+	if (ph->pp_flags & FLG_PP_LMAPS) {
+		if (get_linkmaps(ph) != PS_OK)
+			(void) fprintf(stderr, "problem loading linkmaps\n");
+	}
+
+	return (bpt->bl_flags);
+}
+
+ulong_t
+is_plt(struct ps_prochandle *ph, ulong_t pc)
+{
+	map_info_t	*mip;
+	ulong_t		pltbase;
+
+	if ((mip = addr_to_map(ph, pc)) == (map_info_t *)0)
+		return ((ulong_t)0);
+
+	pltbase = mip->mi_pltbase;
+	if ((mip->mi_flags & FLG_MI_EXEC) == 0)
+		pltbase += mip->mi_addr;
+
+	if ((pc >= pltbase) && (pc <= (pltbase + mip->mi_pltsize)))
+		return (pltbase);
+
+	return ((ulong_t)0);
+}
+
+retc_t
+step_n(struct ps_prochandle *ph, size_t count, sn_flags_e flgs)
+{
+	pstatus_t	pstatus;
+	fltset_t	faults;
+	int		i;
+	long		oper;
+	long		flags;
+	struct iovec	piov[2];
+
+	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
+		perr("stn: reading status");
+
+	piov[0].iov_base = (caddr_t)(&oper);
+	piov[0].iov_len = sizeof (oper);
+
+	premptyset(&faults);
+	praddset(&faults, FLTTRACE);
+
+	flags = PRSTEP | PRCFAULT;
+
+	for (i = 0; i < count; i++) {
+		bptlist_t	*bpt;
+		uintptr_t	pc, pltbase;
+
+		pc = pstatus.pr_lwp.pr_reg[R_PC];
+
+		if ((bpt = find_bp(ph, pc)) != (bptlist_t *)-1) {
+			if (bpt->bl_flags & MASK_BP_SPECIAL)
+				handle_sp_break(ph);
+		}
+
+		if (flgs & FLG_SN_VERBOSE)
+			disasm(ph, 1);
+
+		oper = PCSFAULT;
+		piov[1].iov_base = (caddr_t)(&faults);
+		piov[1].iov_len = sizeof (faults);
+
+		if (writev(ph->pp_ctlfd, piov, 2) == -1)
+			perr("stn: PCSFAULT");
+
+		oper = PCRUN;
+		piov[1].iov_base = (caddr_t)(&flags);
+		piov[1].iov_len = sizeof (flags);
+		if (writev(ph->pp_ctlfd, piov, 2) == -1)
+			perr("stn: PCRUN(PRSETP)");
+
+		oper = PCWSTOP;
+		if (writev(ph->pp_ctlfd, piov, 1) == -1)
+			perr("stn: PCWSTOP stepping");
+
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
+			perr("stn1: reading status");
+		pc = pstatus.pr_lwp.pr_reg[R_PC];
+
+
+		if ((pstatus.pr_lwp.pr_why != PR_FAULTED) ||
+		    (pstatus.pr_lwp.pr_what != FLTTRACE)) {
+			(void) fprintf(stderr, "sn: bad stop - stopped on "
+			    "why: 0x%x what: 0x%x\n", pstatus.pr_lwp.pr_why,
+			    pstatus.pr_lwp.pr_what);
+			return (RET_FAILED);
+		}
+
+		if ((flgs & FLG_SN_PLTSKIP) &&
+		    ((pltbase = is_plt(ph, pc)) != (ulong_t)0)) {
+			rd_plt_info_t	rp;
+			if (rd_plt_resolution(ph->pp_rap, pc,
+			    pstatus.pr_lwp.pr_lwpid, pltbase, &rp) != RD_OK) {
+				(void) fprintf(stderr,
+				    "sn: rd_plt_resolution failed\n");
+				return (RET_FAILED);
+			}
+			if (rp.pi_skip_method == RD_RESOLVE_TARGET_STEP) {
+				unsigned	bpflags;
+
+				(void) set_breakpoint(ph, rp.pi_target,
+				    FLG_BP_PLTRES);
+				bpflags = continue_to_break(ph);
+
+				(void) delete_breakpoint(ph, rp.pi_target,
+				    FLG_BP_PLTRES);
+
+				if (bpflags & FLG_BP_PLTRES)
+					(void) step_n(ph, rp.pi_nstep,
+					    FLG_SN_NONE);
+			} else if (rp.pi_skip_method == RD_RESOLVE_STEP)
+				(void) step_n(ph, rp.pi_nstep, FLG_SN_NONE);
+		}
+	}
+
+	oper = PRCFAULT;
+	if (writev(ph->pp_ctlfd, piov, 1) == -1)
+		perr("stn: PRCFAULT");
+
+	if ((flgs & FLG_SN_VERBOSE) && (ph->pp_flags & FLG_PP_LMAPS)) {
+		if (get_linkmaps(ph) != PS_OK)
+			(void) fprintf(stderr, "problem loading linkmaps\n");
+	}
+
+	return (RET_OK);
+}
+
+void
+step_to_addr(struct ps_prochandle *ph, ulong_t addr)
+{
+	pstatus_t	pstat;
+	int		count = 0;
+	ulong_t		caddr;
+
+	if (read(ph->pp_statusfd, &pstat, sizeof (pstat)) == -1)
+		perr("sta: reading status");
+
+	caddr = pstat.pr_lwp.pr_reg[R_PC];
+
+	while ((caddr > addr) || ((caddr + 0xff) < addr)) {
+		(void) step_n(ph, 1, FLG_SN_NONE);
+		if (read(ph->pp_statusfd, &pstat, sizeof (pstat)) == -1)
+			perr("sta1: reading status");
+		caddr = pstat.pr_lwp.pr_reg[R_PC];
+		if ((count % 10000) == 0) {
+			(void) printf("%d: ", count);
+			disasm(ph, 1);
+		}
+
+		count++;
+	}
+
+	(void) printf("address found %d instructions in: pc: 0x%lx addr: "
+	    "0x%lx\n", count, caddr, addr);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/callstack.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,110 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/reg.h>
+#include <sys/frame.h>
+#include <sys/stack.h>
+#include <sys/machelf.h>
+#include <procfs.h>
+
+#include "rdb.h"
+
+#ifndef	STACK_BIAS
+#define	STACK_BIAS	0
+#endif
+
+static int
+get_frame(struct ps_prochandle *ph, psaddr_t fp, struct frame *frm)
+{
+#if	defined(_LP64)
+	/*
+	 * Use special structures to read a 32-bit process
+	 * from a 64-bit process.
+	 */
+	if (ph->pp_dmodel == PR_MODEL_ILP32) {
+		struct frame32	frm32;
+
+		if (ps_pread(ph, (psaddr_t)fp, (char *)&frm32,
+		    sizeof (struct frame32)) != PS_OK) {
+			(void) printf("stack trace: bad frame pointer: 0x%lx\n",
+				fp);
+			return (-1);
+		}
+
+		frm->fr_savpc = (long)frm32.fr_savpc;
+#if	defined(__sparcv9)
+		frm->fr_savfp = (struct frame *)(uintptr_t)frm32.fr_savfp;
+#elif	defined(__amd64)
+		frm->fr_savfp = (long)frm32.fr_savfp;
+#endif
+		return (0);
+	}
+#endif	/* defined(_LP64) */
+
+	if (ps_pread(ph, (psaddr_t)fp + STACK_BIAS, (char *)frm,
+	    sizeof (struct frame)) != PS_OK) {
+		(void) printf("stack trace: bad frame pointer: 0x%lx\n", fp);
+		return (-1);
+	}
+	return (0);
+}
+
+/*
+ * Relatively architecture neutral routine to display the callstack.
+ */
+void
+CallStack(struct ps_prochandle *ph)
+{
+	pstatus_t	pstatus;
+	greg_t		fp;
+	struct frame	frm;
+	char		*symstr;
+
+	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
+		perr("cs: reading status");
+
+	symstr = print_address_ps(ph, (ulong_t)pstatus.pr_lwp.pr_reg[R_PC],
+	    FLG_PAP_SONAME);
+	(void) printf(" 0x%08x:%-17s\n", EC_WORD(pstatus.pr_lwp.pr_reg[R_PC]),
+	    symstr);
+
+	fp = pstatus.pr_lwp.pr_reg[R_FP];
+
+	while (fp) {
+		if (get_frame(ph, (psaddr_t)fp, &frm) == -1)
+			return;
+		if (frm.fr_savpc) {
+			symstr = print_address_ps(ph, (ulong_t)frm.fr_savpc,
+			    FLG_PAP_SONAME);
+			(void) printf(" 0x%08x:%-17s\n", EC_WORD(frm.fr_savpc),
+			    symstr);
+		}
+		fp = (greg_t)frm.fr_savfp;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/dis.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,182 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/fault.h>
+#include <sys/syscall.h>
+#include <procfs.h>
+#include <sys/auxv.h>
+#include <libelf.h>
+#include <sys/param.h>
+#include <stdarg.h>
+
+#include "rdb.h"
+#include "disasm.h"
+
+/*
+ * I don't like this global but it's a work-around for the
+ * poor disassemble interface for now.
+ */
+static struct ps_prochandle	*cur_ph;
+
+/*
+ * This routine converts 'address' into it's closest symbol
+ * representation.
+ *
+ * The following flags are used to effect the output:
+ *
+ *	FLG_PAP_SONAME
+ *		embed the SONAME in the symbol name
+ *	FLG_PAP_NOHEXNAME
+ *		if no symbol found return a null string
+ *		If this flag is not set return a string displaying
+ *		the 'hex' value of address.
+ *	FLG_PAP_PLTDECOM
+ *		decompose the PLT symbol if possible
+ */
+char *
+print_address_ps(struct ps_prochandle *ph, ulong_t address, unsigned flags)
+{
+	static char	buf[256];
+	GElf_Sym	sym;
+	char		*str;
+	ulong_t		val;
+
+	if (addr_to_sym(ph, address, &sym, &str) == RET_OK) {
+		map_info_t	*mip;
+		ulong_t		pltbase;
+
+		if (flags & FLG_PAP_SONAME) {
+			/*
+			 * Embed SOName in symbol name
+			 */
+			if (mip = addr_to_map(ph, address)) {
+				(void) strcpy(buf, mip->mi_name);
+				(void) strcat(buf, ":");
+			} else
+				(void) sprintf(buf, "0x%08lx:", address);
+		} else
+			buf[0] = '\0';
+
+		if ((flags & FLG_PAP_PLTDECOM) &&
+		    (pltbase = is_plt(ph, address)) != 0) {
+			rd_plt_info_t	rp;
+			pstatus_t	pstatus;
+
+			if (pread(ph->pp_statusfd, &pstatus,
+			    sizeof (pstatus), 0) == -1)
+				perr("pap: reading pstatus");
+
+			if (rd_plt_resolution(ph->pp_rap, address,
+			    pstatus.pr_lwp.pr_lwpid, pltbase,
+			    &rp) == RD_OK) {
+				if (rp.pi_flags & RD_FLG_PI_PLTBOUND) {
+					GElf_Sym	_sym;
+					char		*_str;
+
+					if (addr_to_sym(ph, rp.pi_baddr,
+					    &_sym, &_str) == RET_OK) {
+						(void) snprintf(buf, 256,
+						    "%s0x%lx:plt(%s)",
+						    buf, address, _str);
+						return (buf);
+					}
+				}
+			}
+			val = sym.st_value;
+			(void) snprintf(buf, 256, "%s0x%lx:plt(unbound)+0x%lx",
+			    buf, address, address - val);
+			return (buf);
+		} else {
+
+			val = sym.st_value;
+
+			if (val < address)
+				(void) snprintf(buf, 256, "%s%s+0x%lx", buf,
+				    str, address - val);
+			else
+				(void) snprintf(buf, 256, "%s%s", buf, str);
+			return (buf);
+		}
+	} else {
+		if (flags & FLG_PAP_NOHEXNAME)
+			buf[0] = '\0';
+		else
+			(void) sprintf(buf, "0x%lx", address);
+		return (buf);
+	}
+}
+
+char *
+print_address(unsigned long address)
+{
+	return (print_address_ps(cur_ph, address,
+	    FLG_PAP_SONAME| FLG_PAP_PLTDECOM));
+}
+
+retc_t
+disasm_addr(struct ps_prochandle *ph, ulong_t addr, int num_inst)
+{
+	ulong_t 	offset, end;
+	int		vers = V8_MODE;
+
+	if (ph->pp_dmodel == PR_MODEL_LP64)
+		vers = V9_MODE | V9_SGI_MODE;
+
+	for (offset = addr, end = addr + num_inst * 4; offset < end;
+	    offset += 4) {
+		char		*instr_str;
+		unsigned int	instr;
+
+		if (ps_pread(ph, offset, (char *)&instr,
+		    sizeof (unsigned)) != PS_OK)
+			perror("da: ps_pread");
+
+		cur_ph = ph;
+		instr_str = disassemble(instr, offset, print_address, 0, 0,
+		    vers);
+
+		(void) printf("%-30s: %s\n", print_address(offset), instr_str);
+	}
+	return (RET_OK);
+}
+
+void
+disasm(struct ps_prochandle *ph, int num_inst)
+{
+	pstatus_t	pstat;
+
+	if (pread(ph->pp_statusfd, &pstat, sizeof (pstat), 0) == -1)
+		perr("disasm: PIOCSTATUS");
+
+	(void) disasm_addr(ph, (ulong_t)pstat.pr_lwp.pr_reg[R_PC], num_inst);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/disasm.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include "rdb.h"
+
+typedef char *(*FUNCPTR)();
+
+/*
+ * stub routine until I can figure out what to plug in here.
+ */
+/* ARGSUSED 1 */
+char *
+disassemble(unsigned int instr, unsigned long pc, FUNCPTR prtAddress,
+    unsigned int next, unsigned int prev, int vers)
+{
+	static char	buf[256];
+
+	(void) snprintf(buf, 256, "0x%x", instr);
+
+	return (buf);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/disasm.h	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,38 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#ifndef	_DISASM_H
+#define	_DISASM_H
+
+typedef char *(*FUNCPTR)();
+
+extern char	*disassemble(unsigned int, unsigned long, FUNCPTR,
+		    unsigned int, unsigned int, int);
+
+#define	V8_MODE		1	/* V8 */
+#define	V9_MODE		2	/* V9 */
+#define	V9_SGI_MODE	4	/* V9/SGI */
+
+#endif /* _DISASM_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/globals.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,31 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <libelf.h>
+#include "rdb.h"
+
+unsigned long		rdb_flags = 0;	/* misc flags for rdb */
+
+struct ps_prochandle	proch;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/gram.y	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,284 @@
+%{
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <libelf.h>
+#include "rdb.h"
+
+extern	void	rdb_prompt();
+
+%}
+
+%token	VALUE STEP HELP NUMBER NEWLINE SYMBOL PLUS BREAK CONT DIS GETMAPS
+%token	DELETE MAPS PLTSKIP WHERE PRINT OBJPAD QSTRING VARSTRING ECHO_OUT
+%token	EVENT LINKMAPS
+
+%union {
+	char	*str;
+	ulong_t	addr;
+	int	num;
+}
+
+%type <addr> NUMBER address 
+%type <str> SYMBOL QSTRING VARSTRING
+
+%left PLUS
+
+%%
+start: commands
+	;
+
+commands: /* empty */
+	| commands command
+	;
+command: BREAK NEWLINE
+	{
+		list_breakpoints(&proch);
+		rdb_prompt();
+	}
+	| BREAK address NEWLINE
+	{
+		if (set_breakpoint(&proch, $2, FLG_BP_USERDEF) == RET_OK)
+			(void) printf("break point set at: 0x%lx\n",
+			    (unsigned long)$2);
+		else
+			(void) printf("unable to set breakpoint.\n");
+		rdb_prompt();
+	}
+	| CONT NEWLINE
+	{
+		(void) continue_to_break(&proch);
+		rdb_prompt();
+	}
+	| DELETE address NEWLINE
+	{
+		if (delete_breakpoint(&proch, $2, FLG_BP_USERDEF) != RET_OK)
+			(void) printf("unable to delete breakpoint at %#lx\n",
+			    (unsigned long)$2);
+		else
+			(void) printf("breakpoint deleted at 0x%lx\n",
+			    (unsigned long)$2);
+
+		rdb_prompt();
+	}
+	| DIS NEWLINE
+	{
+		disasm(&proch, 10);
+		rdb_prompt();
+	}
+	| DIS address NEWLINE
+	{
+		(void) disasm_addr(&proch, (ulong_t)$2, 10);
+		rdb_prompt();
+	}
+	| DIS address NUMBER NEWLINE
+	{
+		(void) disasm_addr(&proch, (ulong_t)$2, (int)$3);
+		rdb_prompt();
+	}
+	| ECHO_OUT QSTRING NEWLINE
+	{
+		(void) puts($2);
+		free($2);
+		rdb_prompt();
+	}
+	| EVENT SYMBOL NEWLINE
+	{
+		if (strcmp($2, "on") == 0) {
+			(void) printf("rdb: event information enabled.\n");
+			rdb_flags |= RDB_FL_EVENTS;
+		} else if (strcmp($2, "off") == 0) {
+			(void) printf("rdb: event information disabled.\n");
+			rdb_flags &= ~RDB_FL_EVENTS;
+		} else {
+			(void) printf("rdb: unknown event command: %s\n", $2);
+		}
+		free($2);
+		rdb_prompt();
+	}
+	| GETMAPS NEWLINE
+	{
+		if (get_linkmaps(&proch) != RET_OK)
+			(void) printf("get_linkmaps failed\n");
+
+		rdb_prompt();
+	}
+	| LINKMAPS NEWLINE
+	{
+		if (display_linkmaps(&proch) != RET_OK)
+			(void) printf("display_linkmaps failed\n");
+		rdb_prompt();
+	}
+	| MAPS NEWLINE
+	{
+		if (display_maps(&proch) != RET_OK)
+			(void) printf("display_maps failed\n");
+		rdb_prompt();
+	}
+	| STEP NEWLINE
+	{
+		sn_flags_e	sf;
+
+		(void) printf("single step\n");
+		sf = FLG_SN_VERBOSE;
+		if (proch.pp_flags & FLG_PP_PLTSKIP)
+			sf |= FLG_SN_PLTSKIP;
+
+		(void) step_n(&proch, 1, sf);
+		rdb_prompt();
+	}
+	| STEP NUMBER NEWLINE
+	{
+		sn_flags_e	sf;
+
+		(void) printf("stepping %d\n", (int)$2);
+		sf = FLG_SN_VERBOSE;
+		if (proch.pp_flags & FLG_PP_PLTSKIP)
+			sf |= FLG_SN_PLTSKIP;
+
+		(void) step_n(&proch, $2, sf);
+		rdb_prompt();
+	}
+	| STEP NUMBER SYMBOL NEWLINE
+	{
+		sn_flags_e	sf;
+
+		sf = FLG_SN_VERBOSE;
+		if (proch.pp_flags & FLG_PP_PLTSKIP)
+			sf |= FLG_SN_PLTSKIP;
+
+		if (strcmp("silent", $3) == 0)
+			(void) step_n(&proch, $2, sf);
+		else
+			(void) printf("error: step <count> [silent]\n");
+
+		free($3);
+		rdb_prompt();
+	}
+	| HELP NEWLINE
+	{
+		rdb_help(0);
+		rdb_prompt();
+	}
+	| HELP SYMBOL NEWLINE
+	{
+		rdb_help($2);
+		free($2);
+		rdb_prompt();
+	}
+	| OBJPAD NUMBER NEWLINE
+	{
+		(void) printf("setting object padding to: %#lx\n", $2);
+		(void) set_objpad(&proch, $2);
+		rdb_prompt();
+	}
+	| PLTSKIP NEWLINE
+	{
+		if (proch.pp_flags & FLG_PP_PLTSKIP) {
+			proch.pp_flags &= ~ FLG_PP_PLTSKIP;
+			(void) printf("plt skipping disabled\n");
+		} else {
+			proch.pp_flags |= FLG_PP_PLTSKIP;
+			(void) printf("plt skipping enabled\n");
+		}
+
+		rdb_prompt();
+	}
+	| PRINT VARSTRING NEWLINE
+	{
+		print_varstring(&proch, $2);
+		free($2);
+		rdb_prompt();
+	}
+	| PRINT address NEWLINE
+	{
+		print_mem(&proch, $2, 4, "X");
+		rdb_prompt();
+	}
+	| PRINT address NUMBER NEWLINE
+	{
+		print_mem(&proch, $2, (int)$3, "X");
+		rdb_prompt();
+	}
+	| PRINT address NUMBER SYMBOL NEWLINE
+	{
+		print_mem(&proch, $2, (int)$3, $4);
+		rdb_prompt();
+	}
+	| VALUE address NEWLINE
+	{
+		(void) printf("value: %#lx\n", (unsigned long)$2);
+		rdb_prompt();
+	}
+	| WHERE NEWLINE
+	{
+		(void) printf("printing stack trace\n");
+		CallStack(&proch);
+		rdb_prompt();
+	}
+	| error NEWLINE
+	{
+		yyerrok;
+		rdb_prompt();
+	}
+	| NEWLINE
+	{
+		disasm(&proch, 1);
+		rdb_prompt();
+	}
+	;
+
+address: address PLUS address
+	{
+		$$ = $1 + $3;
+	}
+	| SYMBOL
+	{
+		GElf_Sym	sym;
+		if (str_to_sym(&proch, $1, &sym) == RET_OK)
+			$$ = (ulong_t)sym.st_value;
+		else {
+			(void) printf("unknown symbol: %s\n", $1);
+			$$ = 0;
+		}
+		free($1);
+	}
+	| NUMBER
+	{
+		$$ = $1;
+	}
+	;
+%%
+
+void
+rdb_prompt()
+{
+	if (proch.pp_flags & FLG_PP_PROMPT) {
+		(void) fputs("<rdb> ", stdout);
+		(void) fflush(stdout);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/help.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,241 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <libelf.h>
+#include <string.h>
+
+#include "rdb.h"
+
+typedef struct {
+	char	*ht_key;		/* HELP keyword for topic */
+	char	*ht_desc;		/* description of topic */
+	void	(*ht_func)();		/* detailed info on topic */
+} help_topics;
+
+static void
+break_help()
+{
+	(void) printf("Break Help:\n"
+	    "\tbreak            - list breakpoints\n"
+	    "\tbreak <address>  - set break point at <address\n");
+}
+
+static void
+delete_help()
+{
+	(void) printf("Delete Help:\n"
+	    "\tdelete <address> - delete breakpoint at <address>\n");
+}
+
+static void
+dis_help()
+{
+	(void) printf("Disassemble Help:\n"
+	    "\tdis -\t\t\tdisassemble from current PC\n"
+	    "\tdis <address> [count] -\tdisassemble from address for\n"
+	    "\t\t\t\t<count> instructions\n");
+}
+
+static void
+echo_help()
+{
+	(void) printf("Echo Help:\n"
+	    "\tEcho '<quoted string>'\n"
+	    "\t\tthe echo command can be used to display output to\n"
+	    "\t\tthe main terminal.  This is useful when running\n"
+	    "\t\tcommand scripts and wanting to display status\n"
+	    "\n"
+	    "\t\tcurrently only <quoted strings> may be displayed\n");
+}
+
+static void
+print_help()
+{
+	(void) printf("Print Help:\n"
+	    "\tprint <address> [count [format]]\n"
+	    "\t\tcount  - number of units to print (default 4)\n"
+	    "\t\tformat - how to display data:\n"
+	    "\t\t\t\tX - Hex Words (default)\n"
+	    "\t\t\t\tb - unsigned hex bytes\n"
+	    "\t\t\t\ts - string\n"
+	    "\tprint <varname>\n"
+	    "\t\thelp varname for more info\n");
+}
+
+static void
+step_help()
+{
+	(void) printf("Step Help:\n");
+	(void) printf("\tstep -		step one instruction.\n");
+	(void) printf("\tstep count [silent] -	step count instructions\n");
+	(void) printf("\t\t\t\tif silent is specified to not disassemble\n"
+	    "\t\t\t\tinstr. during stepping\n");
+}
+
+static void
+value_help()
+{
+	(void) printf("Value Help:\n"
+	    "\tvalue <symbol name> -\tdisplay the value associated with\n"
+	    "\t\t\t\tsymbol <symbol name>.\n");
+}
+
+static void
+varname_help()
+{
+	(void) printf("Variable Name Help:\n"
+	    "\tVariable names are in the form of $<name> and are used\n"
+	    "\tto access special information.  Possible varnames\n"
+	    "\tare:\n"
+	    "\t\tcommon:\n"
+	    "\t\t\t$regs - display all registers\n"
+	    "\t\tsparc:\n"
+	    "\t\t\t$ins -   display IN registers\n"
+	    "\t\t\t$globs - display GLOBAL registers\n"
+	    "\t\t\t$outs -  display OUT registers\n"
+	    "\t\t\t$locs -  display LOCAL registers\n"
+	    "\t\t\t$specs -  display SPECIAL registers\n"
+	    "\t\ti86pc:\n");
+}
+
+static const help_topics	htops[] = {
+	{
+		"break",
+		"Set and display breakpoints",
+		break_help
+	},
+	{
+		"cont",
+		"continue execution of process",
+		0
+	},
+	{
+		"delete",
+		"delete breakpoints",
+		delete_help
+	},
+	{
+		"dis",
+		"Help on the Disassemble Command",
+		dis_help
+	},
+	{
+		"echo",
+		"Help on the Echo Command",
+		echo_help
+	},
+	{
+		"event",
+		"event [on|off] to enable or disable event information",
+		0
+	},
+	{
+		"getmaps",
+		"Read Link_Map structure from run-time linker",
+		0
+	},
+	{
+		"linkmaps",
+		"Display link-map information",
+		0
+	},
+	{
+		"maps",
+		"Display memory mapping information",
+		0
+	},
+	{
+		"objpad",
+		"Set object padding for ld.so.1 mmap'ed objects",
+		0
+	},
+	{
+		"pltskip",
+		"Enables and disables stepping through PLT's",
+		0
+	},
+	{
+		"print",
+		"Display memory at <address>",
+		print_help
+	},
+	{
+		"step",
+		"Help on the Step Command",
+		step_help
+	},
+	{
+		"value",
+		"Help on the Value Command",
+		value_help
+	},
+	{
+		"varname",
+		"Help on $variable values",
+		varname_help
+	},
+	{
+		"where",
+		"Display stack trace",
+		0
+	},
+	{
+		0,
+		0,
+		0
+	}
+};
+
+void
+rdb_help(const char *topic) {
+	int	i;
+
+	if (topic) {
+		for (i = 0; htops[i].ht_key; i++) {
+			if (strcmp(htops[i].ht_key, topic) == 0) {
+				if (htops[i].ht_func)
+					htops[i].ht_func();
+				else
+					(void) printf("no additional help "
+					    "available for %s\n",
+					    htops[i].ht_key);
+				return;
+			}
+		}
+		(void) printf("Help not available for topic: %s\n", topic);
+	}
+
+	(void) printf("The following commands are available\n");
+
+	for (i = 0; htops[i].ht_key; i++) {
+		(void) printf("\t%10s\t%s", htops[i].ht_key, htops[i].ht_desc);
+		if (htops[i].ht_func)
+			(void) putchar('*');
+		(void) putchar('\n');
+	}
+	(void) printf("\n(*) more help is available by typing "
+	    "'help <topic>'\n\n");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/lex.l	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,78 @@
+%{
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "gram.h"
+#include "rdb.h"
+%}
+
+ws		[ \t]+
+nl		\n
+symbol		[_a-zA-Z][_a-zA-Z0-9]*
+varstring	\$[_a-zA-Z][_a-zA-Z0-9]*	/* $<name> */
+hexnumber	0[xX][0-9a-zA-Z]+
+decnumber	[0-9]+
+qstring		\"[^\"\n]*[\"\n]
+
+%%
+\#[^\n]*		;	/* ignore comments */
+\\\n			;	/* perform line continuation... */
+{ws}			;	/* ignore whitespace */
+{hexnumber}		{yylval.addr = hexstr_to_num(yytext); return (NUMBER);}
+{decnumber}		{yylval.addr = atoi(yytext); return (NUMBER);}
+\+			{return (PLUS);}
+^{ws}*break		{return (BREAK);}
+^{ws}*cont		{return (CONT);}
+^{ws}*echo		{return (ECHO_OUT);}
+^{ws}*event		{return (EVENT);}
+^{ws}*delete		{return (DELETE);}
+^{ws}*dis		{return (DIS);}
+^{ws}*getmaps		{return (GETMAPS);}
+^{ws}*help		{return (HELP);}
+^{ws}*linkmaps		{return (LINKMAPS);}
+^{ws}*maps		{return (MAPS);}
+^{ws}*objpad		{return (OBJPAD);}
+^{ws}*pltskip		{return (PLTSKIP);}
+^{ws}*print		{return (PRINT);}
+^{ws}*step		{return (STEP);}
+^{ws}*value		{return (VALUE);}
+^{ws}*where		{return (WHERE);}
+{symbol}		{yylval.str = strdup(yytext); return (SYMBOL);}
+{varstring}		{
+				yylval.str = strdup(yytext + 1);
+				return (VARSTRING);
+			}
+{qstring}		{
+				yylval.str = strdup(yytext + 1);
+				if (yylval.str[yyleng - 2] == '"')
+					yylval.str[yyleng - 2] = '\0';
+				return (QSTRING);
+			}
+{nl}			{return (NEWLINE);}
+%%
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/main.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,313 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/uio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/fault.h>
+#include <sys/syscall.h>
+#include <procfs.h>
+#include <sys/auxv.h>
+#include <libelf.h>
+#include <sys/param.h>
+#include <sys/machelf.h>
+#include <stdarg.h>
+
+#include <proc_service.h>
+
+#include "rdb.h"
+#include "disasm.h"
+#include "gram.h"
+
+#define	PROCSIZE	20
+
+static void
+init_proc()
+{
+	int		pfd;
+	char		procname[PROCSIZE];
+	sigset_t	sigset;
+	fltset_t	fltset;
+	sysset_t	sysset;
+	long		oper, pflags;
+	struct iovec	piov[2];
+
+	/*
+	 * open our own /proc file and set tracing flags
+	 */
+	(void) snprintf(procname, PROCSIZE, "/proc/%d/ctl", EC_SWORD(getpid()));
+	if ((pfd = open(procname, O_WRONLY)) < 0) {
+		(void) fprintf(stderr, "can't open %s\n", procname);
+		exit(1);
+	}
+
+	/*
+	 * inherit on fork, and kill-on-last-close
+	 */
+	oper = PCSET;
+	piov[0].iov_base = (caddr_t)(&oper);
+	piov[0].iov_len = sizeof (oper);
+	pflags = PR_FORK;
+	piov[1].iov_base = (caddr_t)&pflags;
+	piov[1].iov_len = sizeof (pflags);
+
+	if (writev(pfd, piov, 2) == -1)
+		perr("init_proc: PCSET");
+
+	/*
+	 * no signal tracing
+	 */
+	oper = PCSTRACE;
+	premptyset(&sigset);
+	piov[1].iov_base = (caddr_t)&sigset;
+	piov[1].iov_len = sizeof (sigset);
+	if (writev(pfd, piov, 2) == -1)
+		perr("PCSTRACE");
+
+	/*
+	 * no fault tracing
+	 */
+	oper = PCSFAULT;
+	premptyset(&fltset);
+	piov[1].iov_base = (caddr_t)&fltset;
+	piov[1].iov_len = sizeof (fltset);
+	if (writev(pfd, piov, 2) == -1)
+		perr("PCSFAULT");
+
+	/*
+	 * no syscall tracing
+	 */
+	oper = PCSENTRY;
+	premptyset(&sysset);
+	piov[1].iov_base = (caddr_t)&sysset;
+	piov[1].iov_len = sizeof (sysset);
+	if (writev(pfd, piov, 2) == -1)
+		perr("PSENTRY");
+
+	/*
+	 * except exit from exec() or execve()
+	 */
+	oper = PCSEXIT;
+	premptyset(&sysset);
+	praddset(&sysset, SYS_execve);
+	if (writev(pfd, piov, 2) == -1)
+		perr("PCSEXIT");
+
+	(void) close(pfd);
+}
+
+int
+main(int argc, char *argv[])
+{
+	int			pctlfd;
+	int			pstatusfd;
+	char			procname[PROCSIZE];
+	char			*command;
+	char			*rdb_commands = NULL;
+	pid_t			cpid;
+	pstatus_t		pstatus;
+	sysset_t		sysset;
+	int			c;
+	int			error = 0;
+	long			oper;
+	struct iovec		piov[2];
+	extern FILE		*yyin;
+
+	command = argv[0];
+
+	while ((c = getopt(argc, argv, "f:")) != EOF)
+		switch (c) {
+		case 'f':
+			rdb_commands = optarg;
+			break;
+		case '?':
+			break;
+		}
+
+	if (error || (optind == argc)) {
+		(void) printf("usage: %s [-f file] executable "
+		    "[executable arguments ...]\n", command);
+		(void) printf("\t-f	command file\n");
+		exit(1);
+	}
+
+	/*
+	 * set up for tracing the child.
+	 */
+	init_proc();
+
+	/*
+	 * create a child to fork and exec from.
+	 */
+	if ((cpid = fork()) == 0) {
+		(void) execv(argv[optind], &argv[optind]);
+		perr(argv[1]);
+	}
+
+	if (cpid == -1)	/* fork() failure */
+		perr(command);
+
+	/*
+	 * initialize libelf
+	 */
+	if (elf_version(EV_CURRENT) == EV_NONE) {
+		(void) fprintf(stderr, "elf_version() failed: %s\n",
+		    elf_errmsg(0));
+		exit(1);
+	}
+
+	/*
+	 * initialize librtld_db
+	 */
+	if (rd_init(RD_VERSION) != RD_OK) {
+		(void) fprintf(stderr, "librtld_db::rd_init() failed: version "
+		    "submitted: %d\n", RD_VERSION);
+		exit(1);
+	}
+
+	/* rd_log(1); */
+
+	/*
+	 * Child should now be waiting after the successful
+	 * exec.
+	 */
+	(void) snprintf(procname, PROCSIZE, "/proc/%d/ctl", EC_SWORD(cpid));
+	(void) printf("parent: %d child: %d child procname: %s\n",
+	    EC_SWORD(getpid()), EC_SWORD(cpid), procname);
+	if ((pctlfd = open(procname, O_WRONLY)) < 0) {
+		perror(procname);
+		(void) fprintf(stderr, "%s: can't open child %s\n",
+		    command, procname);
+		exit(1);
+	}
+
+	/*
+	 * wait for child process.
+	 */
+	oper = PCWSTOP;
+	piov[0].iov_base = (caddr_t)&oper;
+	piov[0].iov_len = sizeof (oper);
+	if (writev(pctlfd, piov, 1) == -1)
+		perr("PCWSTOP");
+
+	/*
+	 * open /proc/<cpid>/status
+	 */
+	(void) snprintf(procname, PROCSIZE, "/proc/%d/status", EC_SWORD(cpid));
+	if ((pstatusfd = open(procname, O_RDONLY)) == -1)
+		perr(procname);
+
+	if (read(pstatusfd, &pstatus, sizeof (pstatus)) == -1)
+		perr("status read failed");
+
+	/*
+	 * Make sure that it stopped where we expected.
+	 */
+	while ((pstatus.pr_lwp.pr_why == PR_SYSEXIT) &&
+	    (pstatus.pr_lwp.pr_what == SYS_execve)) {
+		long	pflags = 0;
+		if (!(pstatus.pr_lwp.pr_reg[R_PS] & ERRBIT)) {
+			/* successfull exec(2) */
+			break;
+		}
+
+		oper = PCRUN;
+		piov[1].iov_base = (caddr_t)&pflags;
+		piov[1].iov_len = sizeof (pflags);
+		if (writev(pctlfd, piov, 2) == -1)
+			perr("PCRUN1");
+
+		oper = PCWSTOP;
+		if (writev(pctlfd, piov, 1) == -1)
+			perr("PCWSTOP");
+
+		if (read(pstatusfd, &pstatus, sizeof (pstatus)) == -1)
+			perr("status read failed");
+	}
+
+	premptyset(&sysset);
+	oper = PCSEXIT;
+	piov[1].iov_base = (caddr_t)&sysset;
+	piov[1].iov_len = sizeof (sysset);
+	if (writev(pctlfd, piov, 2) == -1)
+		perr("PIOCSEXIT");
+
+	/*
+	 * Did we stop where we expected ?
+	 */
+	if ((pstatus.pr_lwp.pr_why != PR_SYSEXIT) ||
+	    (pstatus.pr_lwp.pr_what != SYS_execve)) {
+		long	pflags = 0;
+
+		(void) fprintf(stderr, "Didn't catch the exec, why: %d "
+		    "what: %d\n", pstatus.pr_lwp.pr_why,
+		    pstatus.pr_lwp.pr_what);
+
+		oper = PCRUN;
+		piov[1].iov_base = (caddr_t)&pflags;
+		piov[1].iov_len = sizeof (pflags);
+		if (writev(pctlfd, piov, 2) == -1)
+			perr("PCRUN2");
+		exit(1);
+	}
+
+	(void) ps_init(pctlfd, pstatusfd, cpid, &proch);
+
+	if (rdb_commands) {
+		if ((yyin = fopen(rdb_commands, "r")) == NULL) {
+			(void) printf("unable to open %s for input\n",
+			    rdb_commands);
+			perr("fopen");
+		}
+	} else {
+		proch.pp_flags |= FLG_PP_PROMPT;
+		rdb_prompt();
+	}
+	(void) yyparse();
+
+	if (proch.pp_flags & FLG_PP_PACT) {
+		long	pflags = PRCFAULT;
+
+		(void) printf("\ncontinuing the hung process...\n");
+
+		pctlfd = proch.pp_ctlfd;
+		(void) ps_close(&proch);
+
+		oper = PCRUN;
+		piov[1].iov_base = (caddr_t)&pflags;
+		piov[1].iov_len = sizeof (pflags);
+		if (writev(pctlfd, piov, 2) == -1)
+			perr("PCRUN2");
+		(void) close(pctlfd);
+	}
+
+	return (0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/maps.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,457 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/fault.h>
+#include <sys/syscall.h>
+#include <procfs.h>
+#include <sys/auxv.h>
+#include <libelf.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <link.h>
+#include <sys/param.h>
+#include <sys/machelf.h>
+#include <stdarg.h>
+
+#include "rdb.h"
+
+static char *
+conv_lmid(Lmid_t ident, char *buf, size_t len)
+{
+	if (len < 17)
+		return (NULL);
+	if (ident == LM_ID_BASE)
+		return (strncpy(buf, "  BASE  ", len));
+
+	if (ident == LM_ID_LDSO)
+		return (strncpy(buf, "  LDSO  ", len));
+
+	(void) sprintf(buf, "0x%llx", (unsigned long long)ident);
+	return (buf);
+}
+
+map_info_t *
+str_to_map(struct ps_prochandle *ph, const char *soname)
+{
+	map_info_t *mip;
+
+	if (soname == PS_OBJ_LDSO)
+		mip = (map_info_t *)&(ph->pp_ldsomap);
+	else if (soname == PS_OBJ_EXEC)
+		mip = (map_info_t *)&(ph->pp_execmap);
+	else {
+		for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next)
+			if (strcmp(soname, mip->mi_name) == 0)
+				break;
+	}
+	return (mip);
+}
+
+map_info_t *
+addr_to_map(struct ps_prochandle *ph, ulong_t addr)
+{
+	map_info_t *mip;
+	if (ph->pp_lmaplist.ml_head == NULL) {
+		/*
+		 * To early to have the full Link Map info available
+		 * so we use the initial info obtained from procfs
+		 */
+		if ((addr >= ph->pp_ldsomap.mi_addr) &&
+		    (addr <= ph->pp_ldsomap.mi_end))
+			return ((map_info_t *)&(ph->pp_ldsomap));
+
+		if ((addr >= ph->pp_execmap.mi_addr) &&
+		    (addr <= ph->pp_execmap.mi_end))
+			return ((map_info_t *)&(ph->pp_execmap));
+
+		return (NULL);
+	}
+
+	for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next)
+		if ((addr >= mip->mi_addr) &&
+		    (addr <= mip->mi_end))
+			return (mip);
+
+	return (NULL);
+}
+
+retc_t
+display_linkmaps(struct ps_prochandle *ph)
+{
+	char	flagstr[1024];
+	map_info_t *mip;
+
+	if (ph->pp_lmaplist.ml_head == NULL) {
+		(void) printf("link-maps not yet available\n");
+		return (RET_FAILED);
+	}
+	(void) printf("Link Maps\n");
+	(void) printf("---------\n");
+	for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next) {
+		char sbuf[32];
+		rd_loadobj_t *lp = &mip->mi_loadobj;
+		(void) printf("link-map: id: %s name: ",
+		    conv_lmid(lp->rl_lmident, sbuf, 32));
+		if (mip->mi_refname)
+			(void) printf("%s(%s)\n", mip->mi_name,
+			    mip->mi_refname);
+		else
+			(void) printf("%s\n", mip->mi_name);
+
+		(void) printf("       base: 0x%08lx   padd_base: 0x%08lx\n",
+		    lp->rl_base, lp->rl_padstart);
+		(void) printf("  data_base: 0x%08llx\n",
+		    (unsigned long long)lp->rl_data_base);
+		(void) printf("        end: 0x%08lx    padd_end: 0x%08lx\n",
+		    lp->rl_bend, lp->rl_padend);
+		flagstr[0] = '\0';
+
+		if (lp->rl_flags & RD_FLG_MEM_OBJECT) {
+			(void) strcat(flagstr, " MEMOBJECT");
+		}
+		(void) printf("    dynamic: 0x%08lx       flags: "
+		    "0x%08x:[%s ]\n", lp->rl_dynamic, lp->rl_flags, flagstr);
+	}
+
+	return (RET_OK);
+}
+
+retc_t
+display_maps(struct ps_prochandle *ph)
+{
+	struct stat	stbuf;
+	void 		*ptr;
+	prmap_t 	*mapptr;
+
+	if (fstat(ph->pp_mapfd, &stbuf) == -1)
+		perr("stat map");
+
+	ptr = malloc(stbuf.st_size);
+	if (pread(ph->pp_mapfd, ptr, stbuf.st_size, 0) == -1)
+		perr("dm: reading map");
+
+	(void) puts("\nMappings");
+	(void) puts("--------");
+	if (ph->pp_dmodel == PR_MODEL_LP64)
+		(void) puts("addr               size     prot ident name");
+	else
+		(void) puts("addr       size     prot ident name");
+
+	for (mapptr = (prmap_t *)ptr;
+	    (uintptr_t)mapptr < ((uintptr_t)ptr + stbuf.st_size);
+	    mapptr++) {
+		map_info_t *mip;
+
+		if (ph->pp_dmodel == PR_MODEL_LP64)
+			(void) printf("%#18llx %#08llx %#04x",
+			    EC_ADDR(mapptr->pr_vaddr), EC_OFF(mapptr->pr_size),
+			    mapptr->pr_mflags);
+		else
+			(void) printf("0x%08llx 0x%06llx 0x%02x",
+			    EC_ADDR(mapptr->pr_vaddr), EC_OFF(mapptr->pr_size),
+			    mapptr->pr_mflags);
+
+		if ((mip = addr_to_map(ph,
+		    (ulong_t)(mapptr->pr_vaddr))) != NULL) {
+			if (mip->mi_refname) {
+				(void) printf(" 0x%02lx  %s(%s)",
+				    mip->mi_lmident, mip->mi_name,
+				    mip->mi_refname);
+			} else
+				(void) printf(" 0x%02lx  %s", mip->mi_lmident,
+				    mip->mi_name);
+		}
+		(void) putchar('\n');
+	}
+	(void) putchar('\n');
+
+	free(ptr);
+	return (RET_OK);
+}
+
+retc_t
+load_map(struct ps_prochandle *procp, caddr_t baddr, map_info_t *mp)
+{
+	Elf 		*elf;
+	GElf_Ehdr 	ehdr;
+	GElf_Phdr	phdr;
+	Elf_Scn 	*scn = NULL;
+	int		cnt;
+	prmap_t 	*mapptr;
+	void 		*ptr;
+	struct stat	stbuf;
+	int		filefd = -1;
+
+	if (fstat(procp->pp_mapfd, &stbuf) == -1)
+		perr("stat map");
+
+	ptr = malloc(stbuf.st_size);
+	if (pread(procp->pp_mapfd, ptr, stbuf.st_size, 0) == -1)
+		perr("dm: reading map");
+
+	for (mapptr = (prmap_t *)ptr;
+	    (uintptr_t)mapptr < ((uintptr_t)ptr + stbuf.st_size);
+	    mapptr++) {
+
+		if ((mapptr->pr_vaddr <= (uintptr_t)baddr) &&
+		    ((mapptr->pr_vaddr + mapptr->pr_size) >
+		    (uintptr_t)baddr)) {
+			if (mapptr->pr_mapname[0]) {
+				char	procname[MAXPATHLEN];
+
+				(void) snprintf(procname, MAXPATHLEN - 1,
+				    "/proc/%d/object/%s", procp->pp_pid,
+				    mapptr->pr_mapname);
+				filefd = open(procname, O_RDONLY);
+			}
+			break;
+		}
+	}
+	free(ptr);
+
+	if (filefd == -1) {
+		(void) fprintf(stderr, "unable to find file association to "
+		    "mapping address 0x%08llx\n", EC_NATPTR(baddr));
+		return (RET_FAILED);
+	}
+
+	if ((elf = elf_begin(filefd, ELF_C_READ, 0)) == NULL) {
+		(void) fprintf(stderr, "elf_begin(): %s\n", elf_errmsg(-1));
+		return (RET_FAILED);
+	}
+
+	if (elf_kind(elf) != ELF_K_ELF) {
+		(void) printf("non-elf file\n");
+		(void) elf_end(elf);
+		return (RET_FAILED);
+	}
+
+	mp->mi_elf = elf;
+	mp->mi_flags = 0;
+	mp->mi_mapfd = filefd;
+
+	if (gelf_getehdr(mp->mi_elf, &ehdr) == NULL) {
+		(void) printf("gelf_getehdr(): %s\n", elf_errmsg(-1));
+		(void) elf_end(mp->mi_elf);
+		return (RET_FAILED);
+	}
+	mp->mi_ehdr = ehdr;
+	if (ehdr.e_type == ET_EXEC)
+		mp->mi_flags |= FLG_MI_EXEC;
+
+	mp->mi_end = 0;
+#if	defined(_ELF64)
+	mp->mi_addr = (ulong_t)0xffffffffffffffff;
+#else
+	mp->mi_addr = (ulong_t)0xffffffff;
+#endif
+	for (cnt = 0; cnt < (int)(ehdr.e_phnum); cnt++) {
+		if (gelf_getphdr(mp->mi_elf, cnt, &phdr) == NULL) {
+			(void) printf("gelf_getphdr(): %s\n", elf_errmsg(-1));
+			(void) elf_end(mp->mi_elf);
+			return (RET_FAILED);
+		}
+
+		if (phdr.p_type == PT_LOAD) {
+			if (mp->mi_end < (ulong_t)(phdr.p_vaddr +
+			    phdr.p_memsz))
+				mp->mi_end = (ulong_t)(phdr.p_vaddr +
+				    phdr.p_memsz);
+			if (mp->mi_addr > phdr.p_vaddr)
+				mp->mi_addr = phdr.p_vaddr;
+		}
+	}
+
+	mp->mi_pltbase = 0;
+	mp->mi_pltsize = 0;
+	mp->mi_pltentsz = 0;
+	mp->mi_dynsym.st_symn = 0;
+	while ((scn = elf_nextscn(mp->mi_elf, scn)) != NULL) {
+		GElf_Shdr 	shdr;
+		Elf_Data	*dp;
+		Elf_Scn		*tscn = NULL;
+
+		if (gelf_getshdr(scn, &shdr) == NULL) {
+			(void) printf("gelf_getshdr(): %s\n", elf_errmsg(-1));
+			(void) elf_end(mp->mi_elf);
+			return (RET_FAILED);
+		}
+
+		switch (shdr.sh_type) {
+		case SHT_DYNSYM:
+			dp = elf_getdata(scn, 0);
+			mp->mi_dynsym.st_syms_pri = dp;
+			tscn = elf_getscn(mp->mi_elf, shdr.sh_link);
+			mp->mi_dynsym.st_symn +=
+			    shdr.sh_size / shdr.sh_entsize;
+			dp = elf_getdata(tscn, 0);
+			mp->mi_dynsym.st_strs = (char *)dp->d_buf;
+			break;
+		case SHT_SUNW_LDYNSYM:
+			dp = elf_getdata(scn, 0);
+			mp->mi_dynsym.st_syms_aux = dp;
+			mp->mi_dynsym.st_symn_aux =
+			    shdr.sh_size / shdr.sh_entsize;
+			mp->mi_dynsym.st_symn += mp->mi_dynsym.st_symn_aux;
+			break;
+		case SHT_SYMTAB:
+			dp = elf_getdata(scn, 0);
+			mp->mi_symtab.st_syms_pri = dp;
+			tscn = elf_getscn(mp->mi_elf, shdr.sh_link);
+			mp->mi_symtab.st_symn =
+			    shdr.sh_size / shdr.sh_entsize;
+			dp = elf_getdata(tscn, 0);
+			mp->mi_symtab.st_strs = (char *)dp->d_buf;
+			break;
+		case PLTSECTT:
+			if (strcmp(PLTSECT, elf_strptr(mp->mi_elf,
+			    ehdr.e_shstrndx, shdr.sh_name)) == 0) {
+				mp->mi_pltbase = shdr.sh_addr;
+				mp->mi_pltsize = shdr.sh_size;
+				mp->mi_pltentsz = shdr.sh_entsize;
+			}
+			break;
+		default:
+			/* nothing */
+			break;
+		}
+	}
+	return (RET_OK);
+}
+
+static int
+map_iter(const rd_loadobj_t *lop, void *cd)
+{
+	struct ps_prochandle 	*ph = (struct ps_prochandle *)cd;
+	map_info_t 		*mip;
+	char			buf[MAXPATHLEN];
+
+	if ((mip = (map_info_t *)calloc(1, sizeof (map_info_t))) == NULL) {
+		(void) fprintf(stderr, "map_iter: memory error: allocation "
+		    "failed\n");
+		return (0);
+	}
+
+	mip->mi_loadobj = *lop;
+
+	if (proc_string_read(ph, lop->rl_nameaddr,
+	    buf, MAXPATHLEN) == RET_FAILED) {
+		(void) fprintf(stderr, "mi: bad object name address "
+		    "passed: 0x%lx\n", lop->rl_nameaddr);
+		free(mip);
+		return (0);
+	}
+	mip->mi_name = strdup(buf);
+
+
+	if (lop->rl_refnameaddr) {
+		if (proc_string_read(ph, lop->rl_refnameaddr, buf,
+		    MAXPATHLEN) == RET_FAILED) {
+			(void) fprintf(stderr, "mi1: bad object name address "
+			    "passed: 0x%lx\n", lop->rl_refnameaddr);
+			free(mip);
+			return (0);
+		}
+		mip->mi_refname = strdup(buf);
+	} else
+		mip->mi_refname = NULL;
+
+	/*
+	 * Relocatable objects are processed to create in-memory shared objects,
+	 * and as such have no file associated with the allocated memory shared
+	 * object.
+	 */
+	if ((lop->rl_flags & RD_FLG_MEM_OBJECT) == 0)
+		(void) load_map(ph, (caddr_t)lop->rl_base, mip);
+	if ((mip->mi_flags & FLG_MI_EXEC) == 0) {
+		mip->mi_end += lop->rl_base;
+		mip->mi_addr += lop->rl_base;
+	}
+	mip->mi_lmident = lop->rl_lmident;
+	mip->mi_next = NULL;
+
+	if (ph->pp_lmaplist.ml_head == NULL) {
+		ph->pp_lmaplist.ml_head = ph->pp_lmaplist.ml_tail = mip;
+		return (1);
+	}
+
+	ph->pp_lmaplist.ml_tail->mi_next = mip;
+	ph->pp_lmaplist.ml_tail = mip;
+
+	return (1);
+}
+
+void
+free_linkmaps(struct ps_prochandle *ph)
+{
+	map_info_t *cur, *prev;
+
+	for (cur = ph->pp_lmaplist.ml_head, prev = NULL; cur;
+	    prev = cur, cur = cur->mi_next) {
+		if (prev) {
+			(void) elf_end(prev->mi_elf);
+			(void) close(prev->mi_mapfd);
+			free(prev->mi_name);
+			if (prev->mi_refname)
+				free(prev->mi_refname);
+			free(prev);
+		}
+	}
+	if (prev) {
+		(void) elf_end(prev->mi_elf);
+		(void) close(prev->mi_mapfd);
+		free(prev->mi_name);
+		if (prev->mi_refname)
+			free(prev->mi_refname);
+		free(prev);
+	}
+	ph->pp_lmaplist.ml_head = ph->pp_lmaplist.ml_tail = NULL;
+}
+
+retc_t
+get_linkmaps(struct ps_prochandle *ph)
+{
+	free_linkmaps(ph);
+	(void) rd_loadobj_iter(ph->pp_rap, map_iter, ph);
+	return (RET_OK);
+}
+
+retc_t
+set_objpad(struct ps_prochandle *ph, size_t padsize)
+{
+	if (rd_objpad_enable(ph->pp_rap, padsize) != RD_OK) {
+		(void) printf("rdb: error setting object padding\n");
+		return (RET_FAILED);
+	}
+	return (RET_OK);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/ps.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,370 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/uio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <sys/fault.h>
+#include <sys/syscall.h>
+#include <procfs.h>
+#include <sys/auxv.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <libelf.h>
+#include <sys/param.h>
+#include <sys/machelf.h>
+#include <stdarg.h>
+
+#include <proc_service.h>
+
+#include "rdb.h"
+#include "disasm.h"
+
+#if	!defined(_LP64)
+static void
+gelf_sym_to_elf32(GElf_Sym *src, Elf32_Sym *dst)
+{
+	dst->st_name	= src->st_name;
+	dst->st_value	= src->st_value;
+	dst->st_size	= src->st_size;
+	dst->st_info	= ELF32_ST_INFO(GELF_ST_BIND(src->st_info),
+	    GELF_ST_TYPE(src->st_info));
+	dst->st_other	= src->st_other;
+	dst->st_shndx	= src->st_shndx;
+}
+#endif
+
+#define	PROCSIZE	20
+
+static void
+get_ldbase(struct ps_prochandle *procp)
+{
+	int		pauxvfd;
+	char		pname[PROCSIZE];
+	struct stat	stbuf;
+	void		*auxvptr, *auxvtail;
+	auxv_t		*auxvp;
+	uint_t		entsize;
+
+	(void) snprintf(pname, PROCSIZE, "/proc/%d/auxv",
+	    EC_SWORD(procp->pp_pid));
+	if ((pauxvfd = open(pname, O_RDONLY)) == -1)
+		perr("open auxv");
+
+	if (fstat(pauxvfd, &stbuf) == -1)
+		perr("stat auxv");
+
+	auxvptr = malloc(stbuf.st_size);
+	if (read(pauxvfd, auxvptr, stbuf.st_size) == -1)
+		perr("gldb: reading auxv");
+
+	(void) close(pauxvfd);
+
+	procp->pp_auxvp = auxvptr;
+	auxvtail = (void *)((uintptr_t)auxvptr + stbuf.st_size);
+
+#if defined(_LP64)
+	if (procp->pp_dmodel == PR_MODEL_ILP32)
+		entsize = sizeof (auxv32_t);
+	else
+#endif
+		entsize = sizeof (auxv_t);
+
+	while (auxvptr < auxvtail) {
+		auxvp = auxvptr;
+		if (auxvp->a_type == AT_BASE) {
+#if defined(_LP64)
+			if (procp->pp_dmodel == PR_MODEL_ILP32)
+				procp->pp_ldsobase =
+				    ((uintptr_t)((auxv32_t *)auxvp)->
+				    a_un.a_val);
+			else
+#endif
+				procp->pp_ldsobase =  auxvp->a_un.a_val;
+		} else if (auxvp->a_type == AT_PHDR) {
+#if defined(_LP64)
+			if (procp->pp_dmodel == PR_MODEL_ILP32)
+				procp->pp_execphdr =
+				    ((uintptr_t)((auxv32_t *)auxvp)->
+				    a_un.a_val);
+			else
+#endif
+				procp->pp_execphdr =  auxvp->a_un.a_val;
+		}
+		auxvptr = (void *)((uintptr_t)auxvptr + entsize);
+	}
+}
+
+retc_t
+ps_init(int pctlfd, int pstatusfd, pid_t pid, struct ps_prochandle *procp)
+{
+	rd_notify_t	rd_notify;
+	char		procname[PROCSIZE];
+	long		oper, pflags;
+	struct iovec	piov[2];
+
+	procp->pp_pid = pid;
+	procp->pp_ctlfd = pctlfd;
+	procp->pp_statusfd = pstatusfd;
+
+	(void) snprintf(procname, PROCSIZE, "/proc/%d/map",
+	    EC_SWORD(procp->pp_pid));
+	if ((procp->pp_mapfd = open(procname, O_RDONLY)) == -1)
+		perr("psi: open of /proc/dpid/map failed");
+
+	(void) snprintf(procname, PROCSIZE, "/proc/%d/as",
+	    EC_SWORD(procp->pp_pid));
+	if ((procp->pp_asfd = open(procname, O_RDWR)) == -1)
+		perr("psi: open of /proc/dpid/as failed");
+
+	if (ps_pdmodel(procp, &procp->pp_dmodel) != PS_OK)
+		perr("psi: data model");
+
+#if	!defined(_LP64)
+	if (procp->pp_dmodel == PR_MODEL_LP64)
+		perr("psi:  run 64-bit rdb to debug a 64-bit process");
+#endif
+	get_ldbase(procp);
+
+	(void) load_map(procp, (caddr_t)procp->pp_ldsobase,
+	    &(procp->pp_ldsomap));
+	procp->pp_ldsomap.mi_addr += procp->pp_ldsobase;
+	procp->pp_ldsomap.mi_end += procp->pp_ldsobase;
+	procp->pp_ldsomap.mi_name = "<procfs: interp>";
+
+	(void) load_map(procp, (caddr_t)procp->pp_execphdr,
+	    &(procp->pp_execmap));
+	procp->pp_execmap.mi_name = "<procfs: exec>";
+
+	procp->pp_breakpoints = NULL;
+	procp->pp_flags = FLG_PP_PACT | FLG_PP_PLTSKIP;
+	procp->pp_lmaplist.ml_head = NULL;
+	procp->pp_lmaplist.ml_tail = NULL;
+	if ((procp->pp_rap = rd_new(procp)) == NULL) {
+		(void) fprintf(stderr, "rdb: rtld_db: rd_new() call failed\n");
+		exit(1);
+	}
+	(void) rd_event_enable(procp->pp_rap, 1);
+
+	/*
+	 * For those architectures that increment the PC on
+	 * a breakpoint fault we enable the PR_BPTADJ adjustments.
+	 */
+	oper = PCSET;
+	pflags = PR_BPTADJ;
+	piov[0].iov_base = (caddr_t)(&oper);
+	piov[0].iov_len = sizeof (oper);
+	piov[1].iov_base = (caddr_t)(&pflags);
+	piov[1].iov_len = sizeof (pflags);
+	if (writev(procp->pp_ctlfd, piov, 2) == -1)
+		perr("psinit: PCSET(PR_BTPADJ)");
+
+	/*
+	 * Set breakpoints for special handshakes between librtld_db.so
+	 * and the debugger.  These include:
+	 *	PREINIT		- before .init processing.
+	 *	POSTINIT	- after .init processing
+	 *	DLACTIVITY	- link_maps status has changed
+	 */
+	if (rd_event_addr(procp->pp_rap, RD_PREINIT, &rd_notify) == RD_OK) {
+		if (set_breakpoint(procp, rd_notify.u.bptaddr,
+		    FLG_BP_RDPREINIT) != RET_OK)
+			(void) fprintf(stderr,
+			    "psi: failed to set BP for preinit at: 0x%lx\n",
+			    rd_notify.u.bptaddr);
+	} else
+		(void) fprintf(stderr, "psi: no event registered for "
+		    "preinit\n");
+
+	if (rd_event_addr(procp->pp_rap, RD_POSTINIT, &rd_notify) == RD_OK) {
+		if (set_breakpoint(procp, rd_notify.u.bptaddr,
+		    FLG_BP_RDPOSTINIT) != RET_OK)
+			(void) fprintf(stderr,
+			    "psi: failed to set BP for postinit at: 0x%lx\n",
+			    rd_notify.u.bptaddr);
+	} else
+		(void) fprintf(stderr, "psi: no event registered for "
+		    "postinit\n");
+
+	if (rd_event_addr(procp->pp_rap, RD_DLACTIVITY, &rd_notify) == RD_OK) {
+		if (set_breakpoint(procp, rd_notify.u.bptaddr,
+		    FLG_BP_RDDLACT) != RET_OK)
+			(void) fprintf(stderr,
+			    "psi: failed to set BP for dlact at: 0x%lx\n",
+			    rd_notify.u.bptaddr);
+	} else
+		(void) fprintf(stderr, "psi: no event registered for dlact\n");
+
+	return (RET_OK);
+}
+
+retc_t
+ps_close(struct ps_prochandle *ph)
+{
+	(void) delete_all_breakpoints(ph);
+
+	if (ph->pp_auxvp)
+		free(ph->pp_auxvp);
+	free_linkmaps(ph);
+	return (RET_OK);
+}
+
+ps_err_e
+ps_pauxv(struct ps_prochandle *ph, const auxv_t **auxvp)
+{
+	*auxvp = ph->pp_auxvp;
+	return (PS_OK);
+}
+
+ps_err_e
+ps_pdmodel(struct ps_prochandle *ph, int *dm)
+{
+	pstatus_t	pstatus;
+
+	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
+		return (PS_ERR);
+
+	*dm = (int)pstatus.pr_dmodel;
+	return (PS_OK);
+}
+
+ps_err_e
+ps_pread(struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t size)
+{
+	if (pread(ph->pp_asfd, buf, size, (off_t)addr) != size)
+		return (PS_ERR);
+
+	return (PS_OK);
+}
+
+ps_err_e
+ps_pwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf, size_t size)
+{
+	if (pwrite(ph->pp_asfd, buf, size, (off_t)addr) != size)
+		return (PS_ERR);
+
+	return (PS_OK);
+}
+
+ps_err_e
+ps_pglobal_sym(struct ps_prochandle *ph, const char *object_name,
+    const char *sym_name, ps_sym_t *symp)
+{
+	map_info_t	*mip;
+	GElf_Sym	gsym;
+
+	if ((mip = str_to_map(ph, object_name)) == NULL)
+		return (PS_ERR);
+
+	if (str_map_sym(sym_name, mip, &gsym, NULL) == RET_FAILED)
+		return (PS_ERR);
+
+#if	defined(_LP64)
+	*symp = gsym;
+#else
+	gelf_sym_to_elf32(&gsym, (Elf32_Sym *)symp);
+#endif
+
+	return (PS_OK);
+}
+
+ps_err_e
+ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
+    const char *sym_name, ulong_t *sym_addr)
+{
+	GElf_Sym	sym;
+	map_info_t	*mip;
+
+	if ((mip = str_to_map(ph, object_name)) == NULL)
+		return (PS_ERR);
+
+	if (str_map_sym(sym_name, mip, &sym, NULL) == RET_FAILED)
+		return (PS_ERR);
+
+	*sym_addr = sym.st_value;
+
+	return (PS_OK);
+}
+
+ps_err_e
+ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset)
+{
+	char		procname[MAXPATHLEN];
+	int		lwpfd;
+	lwpstatus_t	lwpstatus;
+
+	(void) snprintf(procname, MAXPATHLEN - 1,
+	    "/proc/%d/lwp/%d/lwpstatus", EC_SWORD(ph->pp_pid), EC_SWORD(lid));
+
+	if ((lwpfd = open(procname, O_RDONLY)) == -1)
+		return (PS_ERR);
+
+	if (read(lwpfd, &lwpstatus, sizeof (lwpstatus)) == -1)
+		return (PS_ERR);
+
+	gregset = lwpstatus.pr_reg;
+
+	(void) close(lwpfd);
+	return (PS_OK);
+}
+
+void
+ps_plog(const char *fmt, ...)
+{
+	va_list		args;
+	static FILE	*log_fp = NULL;
+
+	if (log_fp == NULL) {
+		char		log_fname[256];
+		(void) sprintf(log_fname, "/tmp/tdlog.%d", EC_SWORD(getpid()));
+		if ((log_fp = fopen(log_fname, "w")) == NULL) {
+			/*
+			 * Unable to open log file - default to stderr.
+			 */
+			(void) fprintf(stderr, "unable to open %s, logging "
+			    "redirected to stderr", log_fname);
+			log_fp = stderr;
+		}
+	}
+
+	va_start(args, fmt);
+	(void) vfprintf(log_fp, fmt, args);
+	va_end(args);
+	(void) fputc('\n', log_fp);
+	(void) fflush(log_fp);
+}
+
+/* ARGSUSED0 */
+ps_err_e
+ps_pbrandname(struct ps_prochandle *P, char *buf, size_t len)
+{
+	return (PS_ERR);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/rdb.h	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,252 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#ifndef _RDB_H
+#define	_RDB_H
+
+#include <rtld_db.h>
+#include <sys/types.h>
+#include <procfs.h>
+#include <proc_service.h>
+#include <libelf.h>
+#include <gelf.h>
+
+#include <rdb_mach.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/*
+ * Definitions from 2.7 sys/procfs_isa.h.
+ */
+#ifndef	PR_MODEL_LP64
+#define	PR_MODEL_UNKNOWN 0
+#define	PR_MODEL_ILP32	1	/* process data model is ILP32 */
+#define	PR_MODEL_LP64	2	/* process data model is LP64 */
+#endif
+
+#define	INTERPSECT	".interp"
+#define	PLTSECT		".plt"
+
+/*
+ * Flags for step_n routine
+ */
+typedef enum {
+	FLG_SN_NONE = 0,
+	FLG_SN_VERBOSE = (1 << 0),	/* disassemble instructions */
+	FLG_SN_PLTSKIP = (1 << 1)	/* step *over* PLTS */
+} sn_flags_e;
+
+
+typedef	enum {
+	RET_FAILED = -1,
+	RET_OK = 0
+} retc_t;
+
+/*
+ * sym_tbl_t contains a primary and an (optional) auxiliary symbol table, which
+ * we wish to treat as a single logical symbol table. In this logical table,
+ * the data from the auxiliary table precedes that from the primary. Symbol
+ * indices start at [0], which is the first item in the auxiliary table
+ * if there is one. The sole purpose for this is so that we can treat the
+ * combination of .SUNW_ldynsym and .dynsym sections as a logically single
+ * entity without having to violate the public interface to libelf.
+ *
+ * Both tables must share the same string table section.
+ *
+ * The symtab_getsym() function serves as a gelf_getsym() replacement
+ * that is aware of the two tables and makes them look like a single table
+ * to the caller.
+ *
+ */
+typedef struct sym_tbl {
+	Elf_Data	*st_syms_pri;	/* start of primary table */
+	Elf_Data	*st_syms_aux;	/* start of auxiliary table */
+	char		*st_strs;	/* ptr to strings */
+	size_t		st_symn;	/* Total # of entries in both tables */
+	size_t		st_symn_aux;	/* # of entries in auxiliary table */
+} sym_tbl_t;
+
+typedef struct	map_info {
+	char			*mi_name;	/* file info */
+	char			*mi_refname;	/* filter reference name */
+	ulong_t			mi_addr;	/* start address */
+	ulong_t			mi_end;		/* end address */
+	int			mi_mapfd;	/* file desc. for mapping */
+	size_t			mi_pltentsz;	/* size of PLT entries */
+	Elf			*mi_elf;	/* elf handle so we can close */
+	GElf_Ehdr		mi_ehdr;
+	sym_tbl_t		mi_symtab;	/* symbol table */
+	sym_tbl_t		mi_dynsym;	/* dynamic symbol table */
+	Lmid_t			mi_lmident;	/* Link Map Ident */
+	ulong_t			mi_pltbase;	/* PLT base address */
+	ulong_t			mi_pltsize;	/* size of PLT table */
+	struct map_info		*mi_next;
+	ulong_t			mi_flags;	/* misc flags */
+	rd_loadobj_t		mi_loadobj;	/* keep the old loadobj for */
+						/* 	good luck */
+} map_info_t;
+
+#define	FLG_MI_EXEC		0x0001		/* is object an EXEC */
+
+#define	FLG_PAP_SONAME		0x0001		/* embed SONAME in sym name */
+#define	FLG_PAP_NOHEXNAME	0x0002		/* if no symbol return */
+						/* null string */
+#define	FLG_PAP_PLTDECOM	0x0004		/* decompe PLT name if */
+						/* possible */
+typedef struct map_list {
+	map_info_t		*ml_head;
+	map_info_t		*ml_tail;
+} map_list_t;
+
+/*
+ * Break point information
+ */
+typedef struct bpt_struct {
+	ulong_t			bl_addr;	/* address of breakpoint */
+	bptinstr_t 		bl_instr;	/* original instruction */
+	unsigned		bl_flags;	/* break point flags */
+	struct bpt_struct	*bl_next;
+} bptlist_t;
+
+#define	FLG_BP_USERDEF		0x0001		/* user defined BP */
+#define	FLG_BP_RDPREINIT	0x0002		/* PREINIT BreakPoint */
+#define	FLG_BP_RDPOSTINIT	0x0004		/* POSTINIT BreakPoint */
+#define	FLG_BP_RDDLACT		0x0008		/* DLACT BreakPoint */
+#define	FLG_BP_PLTRES		0x0010		/* PLT Resolve BP */
+
+#define	MASK_BP_SPECIAL \
+		(FLG_BP_RDPREINIT | FLG_BP_RDPOSTINIT | FLG_BP_RDDLACT)
+#define	MASK_BP_STOP \
+		(FLG_BP_USERDEF | FLG_BP_PLTRES)
+#define	MASK_BP_ALL \
+		(MASK_BP_SPECIAL | FLG_BP_USERDEF)
+
+/*
+ * Proc Services Structure
+ */
+struct ps_prochandle {
+	pid_t		pp_pid;		/* debug process pid */
+	rd_agent_t	*pp_rap;	/* rtld_db handle */
+	int		pp_ctlfd;	/* open ctl proc fd */
+	int		pp_statusfd;	/* open status proc fd */
+	int		pp_asfd;	/* open as proc fd */
+	int		pp_mapfd;	/* open map proc fd */
+	uintptr_t	pp_ldsobase;	/* ld.so.1 base address */
+	uintptr_t	pp_execphdr;	/* a.out phdr address */
+	map_info_t	pp_ldsomap;	/* ld.so.1 map info */
+	map_info_t	pp_execmap;	/* exec map info */
+	map_list_t	pp_lmaplist;	/* list of link map infos */
+	bptlist_t	*pp_breakpoints; /* break point list */
+	void		*pp_auxvp;	/* pointer to AUX vectors */
+	int		pp_flags;	/* misc flags */
+	int		pp_dmodel;	/* data model */
+};
+
+#define	FLG_PP_PROMPT	0x0001		/* display debugger prompt */
+#define	FLG_PP_LMAPS	0x0002		/* link maps available */
+#define	FLG_PP_PACT	0x0004		/* active process being traced */
+#define	FLG_PP_PLTSKIP	0x0008		/* PLT skipping is active */
+
+/*
+ * Debugging Structure
+ */
+typedef struct rtld_debug {
+	int		rd_vers;
+	caddr_t		rd_preinit;
+	caddr_t		rd_postinit;
+} rtld_debug_t;
+
+#define	TRAPBREAK	0x91d02001	/* ta	ST_BREAKPOINT */
+
+/*
+ * values for rdb_flags
+ */
+#define	RDB_FL_EVENTS	0x0001		/* enable printing event information */
+
+/*
+ * Globals
+ */
+
+extern struct ps_prochandle	proch;
+extern unsigned long		rdb_flags;
+
+/*
+ * Functions
+ */
+extern map_info_t	*addr_to_map(struct ps_prochandle *, ulong_t);
+extern retc_t		addr_to_sym(struct ps_prochandle *, ulong_t,
+				GElf_Sym *, char **);
+extern void		CallStack(struct ps_prochandle *ph);
+extern unsigned		continue_to_break(struct ps_prochandle *);
+extern retc_t		delete_all_breakpoints(struct ps_prochandle *);
+extern retc_t		delete_breakpoint(struct ps_prochandle *, ulong_t,
+				unsigned);
+extern void		disasm(struct ps_prochandle *, int);
+extern retc_t		disasm_addr(struct ps_prochandle *, ulong_t, int);
+extern retc_t		display_all_regs(struct ps_prochandle *);
+extern retc_t		display_maps(struct ps_prochandle *);
+extern retc_t		display_linkmaps(struct ps_prochandle *);
+extern void		free_linkmaps(struct ps_prochandle *);
+extern retc_t		get_linkmaps(struct ps_prochandle *);
+extern ulong_t		hexstr_to_num(const char *);
+extern ulong_t		is_plt(struct ps_prochandle *, ulong_t);
+extern void		list_breakpoints(struct ps_prochandle *);
+extern retc_t		load_map(struct ps_prochandle *, caddr_t,
+				map_info_t *mp);
+extern char		*print_address(unsigned long);
+extern char		*print_address_ps(struct ps_prochandle *,
+				unsigned long, unsigned);
+extern void		print_mem(struct ps_prochandle *, ulong_t, int,
+				char *);
+extern void		print_varstring(struct ps_prochandle *, const char *);
+extern void		print_mach_varstring(struct ps_prochandle *,
+				const char *);
+extern void		rdb_help(const char *);
+extern void		rdb_prompt();
+extern void		perr(char *);
+extern retc_t		proc_string_read(struct ps_prochandle *,
+				ulong_t, char *, int);
+extern retc_t		ps_close(struct ps_prochandle *);
+extern retc_t		ps_init(int, int, pid_t, struct ps_prochandle *);
+extern retc_t		set_breakpoint(struct ps_prochandle *, ulong_t,
+				unsigned);
+extern retc_t		set_objpad(struct ps_prochandle *, size_t);
+extern retc_t		step_n(struct ps_prochandle *, size_t, sn_flags_e);
+extern void		step_to_addr(struct ps_prochandle *, ulong_t);
+extern retc_t		str_map_sym(const char *, map_info_t *, GElf_Sym *,
+				char **);
+extern map_info_t	*str_to_map(struct ps_prochandle *, const char *);
+extern retc_t		str_to_sym(struct ps_prochandle *, const char *,
+				GElf_Sym *);
+extern int		yyparse(void);
+extern int		yyerror(char *);
+extern int		yylex(void);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* _RDB_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/rdb.man	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,185 @@
+.\"
+.\" 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
+.\" or http://www.opensolaris.org/os/licensing.
+.\" 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 (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+.\"
+.if n .tr \--
+.TH rdb 1 "24 April 2008"
+.SH NAME
+rdb \- run-time demo debugger
+.SH SYNOPSIS
+.B rdb
+[
+.B -f
+.I file
+]
+executable [executable arguments ...]
+.SH AVAILABILITY
+.LP
+SUNWosdem
+.SH DESCRIPTION
+.B rdb
+is a simple general purpose debugger built on top of 
+.I procfs
+and
+.I librtld_db.
+.B rdb
+is distributed is source code format and is a sample
+of how to use the
+.I rtld_db
+interface and is not meant to be used in a production environment. 
+.LP
+Each invocation of
+.B rdb
+will debug a single process.  In order to start debugging the process
+again from the beginning
+.B rdb
+must be reinvoked.
+.SH OPTIONS
+.TP 15
+.BI \-f " file"
+file containing a list of commands to be executed by rdb.  This option
+can be used to run 
+.B rdb
+in batch mode.
+.SH USAGE
+.B rdb
+by default reads commands from standard input and displays responses on the
+standard output.  
+.B rdb 
+is terminated when it reads an EOF on input.
+The commands that
+.B rdb 
+accepts follow:
+.TP 15
+.BI break " [address]"
+Set a break point at address.  If no address is specified then list
+all currently set breakpoints.
+.TP
+.B cont
+Continue execution of the debugged process.  Note that when rdb
+is first invoked it halts the program before it starts to run.  To
+start executing it you must use cont.
+.TP
+.BI delete " address"
+delete the breakpoint at address.
+.TP
+.BI echo " string"
+Prints a string to standard output.  The string must be surrounded
+by double-quotes("").
+.TP
+.BI event " {on|off}"
+To enable or disable the printing of event information to standard output.
+If enabled then 
+.B rdb
+will monitor
+.I rtld_db
+events and print a message to standard output as they occur.
+.TP
+.B getmaps
+Instructs 
+.B rdb
+to load the current link-maps via the
+.I rtld_db
+interface.  No information is printed.
+.TP
+.B linkmaps
+display current link-map information.
+.TP
+.B maps
+display memory mapping information.
+.TP
+.BI objpad " size"
+Set object padding to
+.I size
+bytes for objects mmap()'ed in by 
+.B ld.so.1.  
+object padding will only effect the loading of new objects,
+those already loaded in memory are not effected.
+.TP
+.B pltskip
+enables and disables the skipping over of procedure linkage table entries
+when stepping through a function call.
+.TP
+.BI print " {address [count [format]]|varname}"
+displays data stored at
+.I address
+or register information.  Type 'help print' from within rdb for more
+details on usage.
+.TP
+.BI step " [count [silent]]"
+single step
+.I count
+instructions.  If count is not given then signle step 1 instruction.  If
+the keyword silent is specified then do not dis-assemble the instructions
+as they are stepped.
+.TP
+.BI value " symbol_name"
+display the value (address) associated with a symbol
+.TP
+.B where
+display a stack trace
+.SH EXAMPLES
+A simple example showing how to load a program, set a break point
+at main, and to then display the link-maps of all objects loaded:
+.LP
+.nf
+.ft 3
+polyslo 310% rdb /usr/bin/ls
+parent: 28300 child: 28301 child procname: /proc/28301
+<rdb> break main
+break point set at: 0x11110
+<rdb> cont
+break point reached at addr: 0x11110
+<rdb> linkmaps
+Link Maps
+---------
+link-map: id: 0x0 name: /usr/bin/ls
+       base: 0x00010000   padd_base: 0xeffffa7c
+  data_base: 0x00000000
+        end: 0x00010000    padd_end: 0x00023ad0
+link-map: id: 0x0 name: /usr/lib/libc.so.1(/usr/platform/$PLATFORM/lib/libc_psr.so.1)
+       base: 0xef700000   padd_base: 0xef7f131c
+  data_base: 0x00000000
+        end: 0xef700000    padd_end: 0xef7991cc
+link-map: id: 0x0 name: /usr/lib/libdl.so.1(/usr/lib/ld.so.1)
+       base: 0xef7c0000   padd_base: 0xef7f1478
+  data_base: 0x00000000
+        end: 0xef7c0000    padd_end: 0xef7c0074
+link-map: id: 0x0 name: /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
+       base: 0xef6f0000   padd_base: 0xef7f15bc
+  data_base: 0x00000000
+        end: 0xef6f0000    padd_end: 0xef6f0074
+link-map: id: 0x1 name: /usr/lib/ld.so.1
+       base: 0xef7d0000   padd_base: 0xef7d1375
+  data_base: 0x00000000
+        end: 0xef7d0000    padd_end: 0xef7f01f8
+<rdb> cont 
+Makefile    gram.h      m_utils.c   rdb         regs.c
+gram.c      lex.c       objs        rdb_mach.h
+process terminated.
+<rdb>
+.ft
+.fi
+.SH SEE ALSO
+.BR ld.so.1 (1)
+.br
+.TZ LLM
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/syms.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,236 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <libelf.h>
+#include "rdb.h"
+
+/*
+ * Given a symbol index, look up the corresponding symbol from the
+ * given symbol table.
+ *
+ * This function allows the caller to treat the symbol table as a single
+ * logical entity even though there may be 2 actual ELF symbol tables
+ * involved. See the comments in Pcontrol.h for details.
+ */
+static GElf_Sym *
+symtab_getsym(sym_tbl_t *symtab, int ndx, GElf_Sym *dst)
+{
+	/* If index is in range of primary symtab, look it up there */
+	if (ndx >= symtab->st_symn_aux) {
+		return (gelf_getsym(symtab->st_syms_pri,
+		    ndx - symtab->st_symn_aux, dst));
+	}
+
+	/* Not in primary: Look it up in the auxiliary symtab */
+	return (gelf_getsym(symtab->st_syms_aux, ndx, dst));
+}
+
+retc_t
+str_map_sym(const char *symname, map_info_t *mp, GElf_Sym *symptr, char **str)
+{
+	sym_tbl_t	*symp;
+	char		*strs;
+	int		i;
+
+	if (mp->mi_symtab.st_syms_pri)
+		symp = &(mp->mi_symtab);
+	else if (mp->mi_dynsym.st_syms_pri)
+		symp = &(mp->mi_dynsym);
+	else
+		return (RET_FAILED);
+
+	strs = symp->st_strs;
+
+	for (i = 0; i < (int)symp->st_symn; i++) {
+		GElf_Sym sym;
+
+		if (symtab_getsym(symp, i, &sym) == NULL) {
+			(void) printf("symtab_getsym(): %s\n", elf_errmsg(-1));
+			return (RET_FAILED);
+		}
+
+		if (sym.st_name == 0)
+			continue;
+		if ((sym.st_shndx == SHN_UNDEF) ||
+		    (strcmp(strs + sym.st_name, symname) != 0))
+			continue;
+		*symptr = sym;
+		if (str != NULL)
+			*str = (char *)strs + symptr->st_name;
+		if ((mp->mi_flags & FLG_MI_EXEC) == 0)
+			symptr->st_value += (GElf_Addr)(mp->mi_addr);
+		return (RET_OK);
+	}
+
+	return (RET_FAILED);
+}
+
+/*
+ * If two syms are of equal value this routine will
+ * favor one over the other based off of it's symbol
+ * type.
+ */
+static GElf_Sym
+sym_swap(GElf_Sym * s1, GElf_Sym * s2)
+{
+	int	t1 = GELF_ST_TYPE(s1->st_info);
+	int	t2 = GELF_ST_TYPE(s2->st_info);
+
+	if ((t1 == STT_FUNC) || (t2 == STT_FUNC)) {
+		if (t1 == STT_FUNC)
+			return (*s1);
+		return (*s2);
+	}
+
+	if ((t1 == STT_OBJECT) || (t2 == STT_OBJECT)) {
+		if (t1 == STT_OBJECT)
+			return (*s1);
+		return (*s2);
+	}
+
+	if ((t1 == STT_OBJECT) || (t2 == STT_OBJECT)) {
+		if (t1 == STT_OBJECT)
+			return (*s1);
+		return (*s2);
+	}
+	return (*s1);
+}
+
+static retc_t
+addr_map_sym(map_info_t *mp, ulong_t addr, GElf_Sym *symptr, char **str)
+{
+	sym_tbl_t	*symp;
+	GElf_Sym	sym;
+	GElf_Sym	*symr = NULL;
+	GElf_Sym	*lsymr = NULL;
+	GElf_Sym	rsym;
+	GElf_Sym	lsym;
+	ulong_t		baseaddr = 0;
+	int		i;
+
+	if ((mp->mi_flags & FLG_MI_EXEC) == 0)
+		baseaddr = (ulong_t)mp->mi_addr;
+
+	if (mp->mi_symtab.st_syms_pri)
+		symp = &(mp->mi_symtab);
+	else if (mp->mi_dynsym.st_syms_pri)
+		symp = &(mp->mi_dynsym);
+	else
+		return (RET_FAILED);
+
+	/*
+	 * normalize address
+	 */
+	addr -= baseaddr;
+	for (i = 0; i < (int)symp->st_symn; i++) {
+		ulong_t	svalue;
+
+		if (symtab_getsym(symp, i, &sym) == NULL) {
+			(void) printf("symtab_getsym(): %s\n", elf_errmsg(-1));
+			return (RET_FAILED);
+		}
+		if ((sym.st_name == 0) || (sym.st_shndx == SHN_UNDEF))
+			continue;
+
+		svalue = (ulong_t)sym.st_value;
+
+		if (svalue <= addr) {
+			/*
+			 * track both the best local and best
+			 * global fit for this address.  Later
+			 * we will favor the global over the local
+			 */
+			if ((GELF_ST_BIND(sym.st_info) == STB_LOCAL) &&
+			    ((lsymr == NULL) ||
+			    (svalue >= (ulong_t)lsymr->st_value))) {
+				if (lsymr && (lsymr->st_value == svalue))
+					*lsymr = sym_swap(lsymr, &sym);
+				else {
+					lsymr = &lsym;
+					*lsymr = sym;
+				}
+			} else if ((symr == NULL) ||
+			    (svalue >= (ulong_t)symr->st_value)) {
+				if (symr && (symr->st_value == svalue))
+					*symr = sym_swap(symr, &sym);
+				else {
+					symr = &rsym;
+					*symr = sym;
+				}
+			}
+		}
+	}
+	if ((symr == NULL) && (lsymr == NULL))
+		return (RET_FAILED);
+
+	if (lsymr) {
+		/*
+		 * If a possible local symbol was found should
+		 * we use it.
+		 */
+		if (symr && (lsymr->st_value > symr->st_value))
+			symr = lsymr;
+		else if (symr == NULL)
+			symr = lsymr;
+	}
+
+	*symptr = *symr;
+	*str = (char *)(symp->st_strs + symptr->st_name);
+	symptr->st_value += baseaddr;
+	return (RET_OK);
+}
+
+retc_t
+addr_to_sym(struct ps_prochandle *ph, ulong_t addr,
+	GElf_Sym *symp, char **str)
+{
+	map_info_t	*mip;
+
+	if ((mip = addr_to_map(ph, addr)) == NULL)
+		return (RET_FAILED);
+
+	return (addr_map_sym(mip, addr, symp, str));
+}
+
+retc_t
+str_to_sym(struct ps_prochandle *ph, const char *name, GElf_Sym *symp)
+{
+	map_info_t	*mip;
+
+	if (ph->pp_lmaplist.ml_head == NULL) {
+		if (str_map_sym(name, &(ph->pp_ldsomap), symp, NULL) == RET_OK)
+			return (RET_OK);
+
+		return (str_map_sym(name, &(ph->pp_execmap), symp, NULL));
+	}
+
+	for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next)
+		if (str_map_sym(name, mip, symp, NULL) == RET_OK)
+			return (RET_OK);
+
+	return (RET_FAILED);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/common/utils.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,155 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libelf.h>
+#include <sys/param.h>
+
+#include "rdb.h"
+
+void
+perr(char *s)
+{
+	perror(s);
+	exit(1);
+}
+
+ulong_t
+hexstr_to_num(const char *str)
+{
+	ulong_t		num = 0;
+	size_t		i, len = strlen(str);
+
+	for (i = 0; i < len; i++)
+		if (str[i] >= '0' && str[i] <= '9')
+			num = num * 16 +((int)str[i] - (int)'0');
+		else if (str[i] >= 'a' && str[i] <= 'f')
+			num = num * 16 +((int)str[i] - (int)'a' + 10);
+		else if (str[i] >= 'A' && str[i] <= 'F')
+			num = num * 16 + ((int)str[i] - (int)'A' + 10);
+	return (num);
+}
+
+#define	STBUFSIZ	1024
+
+retc_t
+proc_string_read(struct ps_prochandle *ph, ulong_t addr, char *buf, int bufsiz)
+{
+	char	intbuf[STBUFSIZ];
+	int	bufind = 0, intbufind = STBUFSIZ, cont = 1;
+	ssize_t	bufbytes = 0;
+
+	if (lseek(ph->pp_asfd, addr, SEEK_SET) == -1)
+		return (RET_FAILED);
+	while (cont && (bufind < bufsiz)) {
+		if (intbufind >= bufbytes) {
+			if ((bufbytes = read(ph->pp_asfd, intbuf,
+			    STBUFSIZ)) == -1)
+				return (RET_FAILED);
+			intbufind = 0;
+		}
+		buf[bufind] = intbuf[intbufind];
+		if (buf[bufind] == '\0')
+			return (RET_OK);
+		bufind++;
+		intbufind++;
+	}
+	return (RET_FAILED);
+}
+
+void
+print_varstring(struct ps_prochandle *ph, const char *varname)
+{
+	(void) printf("print_varstring: %s\n", varname);
+	if (strcmp(varname, "regs") == 0) {
+		(void) display_all_regs(ph);
+		return;
+	}
+	print_mach_varstring(ph, varname);
+}
+
+void
+print_mem(struct ps_prochandle *ph, ulong_t address, int count, char *format)
+{
+	(void) printf("\n%17s:", print_address_ps(ph, address, FLG_PAP_SONAME));
+
+	if ((*format == 'X') || (*format == 'x')) {
+		int	i;
+
+		for (i = 0; i < count; i++) {
+			unsigned long word;
+			if ((i % 4) == 0)
+				(void) printf("\n  0x%08lx: ", address);
+
+			if (ps_pread(ph, address, (char *)&word,
+			    sizeof (unsigned long)) != PS_OK) {
+				(void) printf("\nfailed to read memory at: "
+				    "0x%lx\n", address);
+				return;
+			}
+			(void) printf("  0x%08lx", word);
+			address += 4;
+		}
+		(void) putchar('\n');
+		return;
+	}
+
+	if (*format == 'b') {
+		int	i;
+
+		for (i = 0; i < count; i++, address ++) {
+			unsigned char	byte;
+
+			if ((i % 8) == 0)
+				(void) printf("\n 0x%08lx: ", address);
+
+			if (ps_pread(ph, address, (char *)&byte,
+			    sizeof (unsigned char)) != PS_OK) {
+				(void) fprintf(stderr, "\nfailed to read byte "
+				    "at: 0x%lx\n", address);
+				return;
+			}
+			(void) printf("  %02x", (unsigned)byte);
+		}
+		(void) putchar('\n');
+		return;
+	}
+
+	if (*format == 's') {
+		char	buf[MAXPATHLEN];
+		if (proc_string_read(ph, address, buf,
+		    MAXPATHLEN) != RET_OK) {
+			(void) printf("unable to read string at: %lx\n",
+			    address);
+			return;
+		}
+		(void) printf(" %s\n", buf);
+		return;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/i386/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,40 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include		../Makefile.com
+
+.KEEP_STATE:
+
+all:		$(OBJDIR) .WAIT $(PROG)
+
+test:		$(TESTS)
+
+# DEMO DELETE START
+install:	all $(ROOTONLDBINPROG)
+
+lint:		$(LINTOUT)
+# DEMO DELETE END
+
+include		../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/i386/m_utils.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,33 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#include <stdio.h>
+
+#include "rdb.h"
+
+/* ARGSUSED 0 */
+void
+print_mach_varstring(struct ps_prochandle *ph, const char *varname)
+{
+	(void) printf("print: unknown variable given ($%s)\n", varname);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/i386/rdb_mach.h	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#ifndef _RDB_MACH_H
+#define	_RDB_MACH_H
+
+#include <sys/regset.h>
+#include <sys/psw.h>
+
+#define	ERRBIT	PS_C
+#define	R_PS	EFL
+
+/*
+ * Breakpoint instruction
+ */
+typedef	unsigned char	bptinstr_t;
+#define	BPINSTR		0xcc		/* int	3 */
+
+/*
+ * PLT section type
+ */
+#define	PLTSECTT	SHT_PROGBITS
+
+#endif	/* _RDB_MACH_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/i386/regs.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,71 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/regset.h>
+
+#include "rdb.h"
+
+static void
+disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
+    char *r2, int ind2)
+{
+	char	str1[MAXPATHLEN], str2[MAXPATHLEN];
+
+	(void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
+	    FLG_PAP_NOHEXNAME));
+	(void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
+	    FLG_PAP_NOHEXNAME));
+
+	(void) printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n", r1,
+	    prst->pr_lwp.pr_reg[ind1], str1, r2, prst->pr_lwp.pr_reg[ind2],
+	    str2);
+}
+
+retc_t
+display_all_regs(struct ps_prochandle *ph)
+{
+	pstatus_t	pstatus;
+
+	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+	    0) == -1) {
+		perror("dar: reading status");
+		return (RET_FAILED);
+	}
+	(void) printf("registers:\n");
+	disp_reg_line(ph, &pstatus, "gs", GS, "fs", FS);
+	disp_reg_line(ph, &pstatus, "es", ES, "ds", DS);
+	disp_reg_line(ph, &pstatus, "edi", EDI, "esi", ESI);
+	disp_reg_line(ph, &pstatus, "ebp", EBP, "esp", ESP);
+	disp_reg_line(ph, &pstatus, "ebx", EBX, "edx", EDX);
+	disp_reg_line(ph, &pstatus, "ecx", ECX, "eax", EAX);
+	disp_reg_line(ph, &pstatus, "trapno", TRAPNO, "err", ERR);
+	disp_reg_line(ph, &pstatus, "eip", EIP, "cs", CS);
+	disp_reg_line(ph, &pstatus, "efl", EFL, "uesp", UESP);
+	return (RET_OK);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparc/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,40 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include		../Makefile.com
+
+.KEEP_STATE:
+
+all:		$(OBJDIR) .WAIT $(PROG)
+
+test:		$(TESTS)
+
+# DEMO DELETE START
+install:	all $(ROOTONLDBINPROG)
+
+lint:		$(LINTOUT)
+# DEMO DELETE END
+
+include		../Makefile.targ
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparc/m_utils.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,55 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "rdb.h"
+
+void
+print_mach_varstring(struct ps_prochandle *ph, const char *varname)
+{
+	if (strcmp(varname, "ins") == 0) {
+		display_in_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "globs") == 0) {
+		display_global_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "outs") == 0) {
+		display_out_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "locs") == 0) {
+		display_local_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "specs") == 0) {
+		display_special_regs(ph, NULL);
+		return;
+	}
+	(void) printf("print: unknown variable given ($%s)\n", varname);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparc/rdb_mach.h	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#ifndef _RDB_MACH_H
+#define	_RDB_MACH_H
+
+#include <sys/psw.h>
+#include <procfs.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define	ERRBIT	PSR_C
+
+struct ps_prochandle;
+
+/*
+ * BreakPoint instruction
+ */
+typedef	unsigned	bptinstr_t;
+
+#define	BPINSTR		0x91d02001	/* ta   ST_BREAKPOINT */
+
+/*
+ * PLT section type
+ */
+#define	PLTSECTT	SHT_PROGBITS
+
+extern void	display_in_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_local_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_out_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_special_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_global_regs(struct ps_prochandle *, pstatus_t *);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* _RDB_MACH_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparc/regs.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,167 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include "rdb.h"
+
+static void
+disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
+    char *r2, int ind2)
+{
+	char	str1[MAXPATHLEN], str2[MAXPATHLEN];
+
+	(void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
+	    FLG_PAP_NOHEXNAME));
+
+	(void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
+	    FLG_PAP_NOHEXNAME));
+
+	(void) printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n", r1,
+	    prst->pr_lwp.pr_reg[ind1], str1, r2, prst->pr_lwp.pr_reg[ind2],
+	    str2);
+}
+
+void
+display_local_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dlr: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("locals:\n");
+	disp_reg_line(ph, prst, "l0", R_L0, "l4", R_L4);
+	disp_reg_line(ph, prst, "l1", R_L1, "l5", R_L5);
+	disp_reg_line(ph, prst, "l2", R_L2, "l6", R_L6);
+	disp_reg_line(ph, prst, "l3", R_L3, "l7", R_L7);
+}
+
+void
+display_out_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dor: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("outs:\n");
+	disp_reg_line(ph, prst, "o0", R_O0, "o4", R_O4);
+	disp_reg_line(ph, prst, "o1", R_O1, "o5", R_O5);
+	disp_reg_line(ph, prst, "o2", R_O2, "o6(sp)", R_O6);
+	disp_reg_line(ph, prst, "o3", R_O3, "o7", R_O7);
+}
+
+void
+display_special_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dsr: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("specials:\n");
+	disp_reg_line(ph, prst, "psr", R_PSR, "pc", R_PC);
+	disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y);
+	disp_reg_line(ph, prst, "wim", R_WIM, "TBR", R_TBR);
+}
+
+void
+display_global_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dgr: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("globals:\n");
+	disp_reg_line(ph, prst, "g0", R_G0, "g4", R_G4);
+	disp_reg_line(ph, prst, "g1", R_G1, "g5", R_G5);
+	disp_reg_line(ph, prst, "g2", R_G2, "g6", R_G6);
+	disp_reg_line(ph, prst, "g3", R_G3, "g7", R_G7);
+}
+
+void
+display_in_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dir: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("ins:\n");
+	disp_reg_line(ph, prst, "i0", R_I0, "i4", R_I4);
+	disp_reg_line(ph, prst, "i1", R_I1, "i5", R_I5);
+	disp_reg_line(ph, prst, "i2", R_I2, "i6(fp)", R_I6);
+	disp_reg_line(ph, prst, "i3", R_I3, "i7", R_I7);
+
+}
+
+retc_t
+display_all_regs(struct ps_prochandle *ph)
+{
+	pstatus_t	pstatus;
+
+	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+	    0) == -1) {
+		perror("dar: reading status");
+		return (RET_FAILED);
+	}
+	display_global_regs(ph, &pstatus);
+	display_in_regs(ph, &pstatus);
+	display_local_regs(ph, &pstatus);
+	display_out_regs(ph, &pstatus);
+	display_special_regs(ph, &pstatus);
+
+	return (RET_OK);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparcv9/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,59 @@
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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 (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+
+include		../Makefile.com
+
+CPPFLAGS +=	-D_SYSCALL32
+
+# DEMO DELETE START
+CCVERBOSE=
+
+LDFLAGS=	-L ../../$(MACH64) \
+		-L ../../../libelf/$(MACH64)
+
+# DEMO DELETE END
+
+# Change -m64 to -xarch=generic64 for use with older Sun compilers.
+DEMOCFLAGS=	-m64
+
+.KEEP_STATE:
+
+all:		$(OBJDIR) .WAIT $(PROG)
+
+test:		$(TESTS)
+
+# DEMO DELETE START
+DEMOCFLAGS=
+
+install:	all $(ROOTONLDBINPROG64)
+
+lint:		$(LINTOUT)
+# DEMO DELETE END
+
+include		../Makefile.targ
+
+# DEMO DELETE START
+include		../../../../../Makefile.master.64
+# DEMO DELETE END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparcv9/m_utils.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,55 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "rdb.h"
+
+void
+print_mach_varstring(struct ps_prochandle *ph, const char *varname)
+{
+	if (strcmp(varname, "ins") == 0) {
+		display_in_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "globs") == 0) {
+		display_global_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "outs") == 0) {
+		display_out_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "locs") == 0) {
+		display_local_regs(ph, NULL);
+		return;
+	}
+	if (strcmp(varname, "specs") == 0) {
+		display_special_regs(ph, NULL);
+		return;
+	}
+	(void) printf("print: unknown variable given ($%s)\n", varname);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparcv9/rdb_mach.h	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#ifndef _RDB_MACH_H
+#define	_RDB_MACH_H
+
+#include <sys/psw.h>
+#include <procfs.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#define	ERRBIT	PSR_C
+
+struct ps_prochandle;
+
+/*
+ * BreakPoint instruction
+ */
+typedef	unsigned	bptinstr_t;
+
+#define	BPINSTR		0x91d02001U	/* ta   ST_BREAKPOINT */
+
+/*
+ * PLT section type
+ */
+#define	PLTSECTT	SHT_PROGBITS
+
+extern void	display_in_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_local_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_out_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_special_regs(struct ps_prochandle *, pstatus_t *);
+extern void	display_global_regs(struct ps_prochandle *, pstatus_t *);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* _RDB_MACH_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/sparcv9/regs.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,186 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include "rdb.h"
+
+static void
+disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
+    char *r2, int ind2)
+{
+	char	str1[MAXPATHLEN], str2[MAXPATHLEN];
+
+	(void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
+	    FLG_PAP_NOHEXNAME));
+
+	(void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
+	    FLG_PAP_NOHEXNAME));
+
+	if (ph->pp_dmodel == PR_MODEL_LP64) {
+		/*
+		 *  In 64-bits, the display gets too wide when
+		 *  you have both a 64-bit address and a symbol
+		 *  name, e.g. _GLOBAL_OFFSET_TABLE;  therefore,
+		 *  each is put on a separate line.  This isn't
+		 *  as convenient as the 32-bit display.
+		 */
+		(void) printf("%8s: 0x%08lx %-16s\n", r1,
+		    prst->pr_lwp.pr_reg[ind1], str1);
+		(void) printf("%8s: 0x%08lx %-16s\n", r2,
+		    prst->pr_lwp.pr_reg[ind2], str2);
+	} else
+		(void) printf("%8s: 0x%08lx %-16s %8s: 0x%08lx %-16s\n", r1,
+		    prst->pr_lwp.pr_reg[ind1], str1, r2,
+		    prst->pr_lwp.pr_reg[ind2], str2);
+}
+
+void
+display_local_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dar: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("locals:\n");
+	disp_reg_line(ph, prst, "l0", R_L0, "l4", R_L4);
+	disp_reg_line(ph, prst, "l1", R_L1, "l5", R_L5);
+	disp_reg_line(ph, prst, "l2", R_L2, "l6", R_L6);
+	disp_reg_line(ph, prst, "l3", R_L3, "l7", R_L7);
+}
+
+void
+display_out_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dar: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("outs:\n");
+	disp_reg_line(ph, prst, "o0", R_O0, "o4", R_O4);
+	disp_reg_line(ph, prst, "o1", R_O1, "o5", R_O5);
+	disp_reg_line(ph, prst, "o2", R_O2, "o6(sp)", R_O6);
+	disp_reg_line(ph, prst, "o3", R_O3, "o7", R_O7);
+}
+
+void
+display_special_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dar: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("specials:\n");
+	if (ph->pp_dmodel == PR_MODEL_LP64) {
+		disp_reg_line(ph, prst, "ccr", R_CCR, "pc", R_PC);
+		disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y);
+		disp_reg_line(ph, prst, "asi", R_ASI, "FPRS", R_FPRS);
+	} else {
+		disp_reg_line(ph, prst, "psr", R_PSR, "pc", R_PC);
+		disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y);
+		disp_reg_line(ph, prst, "wim", R_WIM, "TBR", R_TBR);
+	}
+}
+
+void
+display_global_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dar: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("globals:\n");
+	disp_reg_line(ph, prst, "g0", R_G0, "g4", R_G4);
+	disp_reg_line(ph, prst, "g1", R_G1, "g5", R_G5);
+	disp_reg_line(ph, prst, "g2", R_G2, "g6", R_G6);
+	disp_reg_line(ph, prst, "g3", R_G3, "g7", R_G7);
+}
+
+void
+display_in_regs(struct ps_prochandle *ph, pstatus_t *prst)
+{
+	pstatus_t	pstatus;
+
+	if (prst == NULL) {
+		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+		    0) == -1) {
+			perror("dar: reading status");
+			return;
+		}
+		prst = &pstatus;
+	}
+	(void) printf("ins:\n");
+	disp_reg_line(ph, prst, "i0", R_I0, "i4", R_I4);
+	disp_reg_line(ph, prst, "i1", R_I1, "i5", R_I5);
+	disp_reg_line(ph, prst, "i2", R_I2, "i6(fp)", R_I6);
+	disp_reg_line(ph, prst, "i3", R_I3, "i7", R_I7);
+
+}
+
+retc_t
+display_all_regs(struct ps_prochandle *ph)
+{
+	pstatus_t	pstatus;
+
+	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
+	    0) == -1) {
+		perror("dar: reading status");
+		return (RET_FAILED);
+	}
+	display_global_regs(ph, &pstatus);
+	display_in_regs(ph, &pstatus);
+	display_local_regs(ph, &pstatus);
+	display_out_regs(ph, &pstatus);
+	display_special_regs(ph, &pstatus);
+
+	return (RET_OK);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/breaks	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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
+#
+break
+break _start
+break
+delete _start
+break
+break main
+cont
+break
+break printf
+cont
+delete printf
+cont
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/loadmaps	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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
+#
+echo "==============================================================="
+echo "Display maps before any link-maps are available."
+echo "==============================================================="
+maps
+break main
+cont
+echo "==============================================================="
+echo "Now that link-maps are available display both memory maps and "
+echo "link-maps"
+echo "==============================================================="
+maps
+linkmaps
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/object_padding_maps	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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
+#
+echo "==============================================================="
+echo "Enable object padding with a padd of 0x90000"
+echo "==============================================================="
+objpad 0x90000
+break main
+cont
+echo "==============================================================="
+echo "Now display both mapping and link-maps to show results of"
+echo "object paddings."
+echo "==============================================================="
+maps
+linkmaps
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/plt_skip	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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
+#
+break main
+cont
+#
+# First it does several steps over the call to small_sub
+echo "==============================================================="
+echo "The following step will step over the PLT's and directly"
+echo "into the functions."
+echo "==============================================================="
+step 30
+#
+# Disable the pltskip routine to see it step through
+# PLT's
+#
+pltskip
+echo "==============================================================="
+echo "Plt skipping has now been disabled and we should see the PLT's"
+echo "as we call into small_sub()"
+echo "==============================================================="
+step 30
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/simp.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,37 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+#include	<stdio.h>
+
+extern void small_sub(void);
+
+int
+main()
+{
+	int i;
+	for (i = 0; i < 10; i++)
+		small_sub();
+
+	(void) printf("simple run.\n");
+	return (0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/steps	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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
+#
+break main
+cont
+step 10
+break printf
+cont
+step
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/sub.c	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,27 @@
+/*
+ * 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
+ * or http://www.opensolaris.org/os/licensing.
+ * 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ */
+void
+small_sub(void)
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/sgs/librtld_db/demo/tests/test-sparc-regs	Tue Jul 27 22:49:34 2010 -0700
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# or http://www.opensolaris.org/os/licensing.
+# 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
+#
+break main
+cont
+#
+#
+echo "===================================================="
+echo "Display all registers"
+echo "===================================================="
+print $regs
+echo "===================================================="
+echo "Display IN registers"
+echo "===================================================="
+print $ins
+echo "===================================================="
+echo "Display OUT registers"
+echo "===================================================="
+print $outs
+echo "===================================================="
+echo "Display LOCAL registers"
+echo "===================================================="
+print $locs
+echo "===================================================="
+echo "Display SPECIAL registers"
+echo "===================================================="
+print $specs
+echo "===================================================="
+echo "Display GLOBAL registers"
+echo "===================================================="
+print $globs
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/00README	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-This directory contains source code to the rdb debugger.  This debugger
-is distributed as an example client of the librtld_db.so.1 interface.
-As well as offering examples of the proper calling sequence for the
-librtld_db.so.1 interface rdb also offers a sample implementation of the
-proc_services (/usr/include/proc_service.h) that rdb is dependent upon.
-
-The following is an overview of the directory structure and highlight
-of some of the important files contained within:
-
-rdb.man		- man page for the rdb debugger
-Makefile.com
-Makefile.targ	- common Makefiles included by ${MACH)/Makefile
-common/*	- common source code used for all architectures
-sparc/
-sparcv9/
-i386/		- contains architecture specific source files and also
-		  acts as the build directory
-sparc/Makefile
-sparcv9/Makefile
-i386/Makefile	- makefiles to build rdb for each architecture
-test/*		- sample command files which can be used to test rdb
-
-Building rdb
-------------
-Before attempting to build the rdb debugger be sure that you have
-installed the Solaris Developer Cluster and a C compiler (purchased
-serpartly) onto your system.
-
-To build rdb:
-
-% cd {sparc,sparcv9,i386}	- depending on which architecture you are building for
-% make all
-
-To test the demo:
-
-% make test
-
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-#
-# 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
-# or http://www.opensolaris.org/os/licensing.
-# 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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include		../../../../Makefile.master
-
-MACHDEMOFILES= \
-		i386/regs.c \
-		i386/m_utils.c \
-		i386/rdb_mach.h \
-		i386/Makefile \
-		amd64/regs.c \
-		amd64/rdb_mach.h \
-		amd64/Makefile \
-		sparc/regs.c \
-		sparc/m_utils.c \
-		sparc/rdb_mach.h \
-		sparc/Makefile \
-		sparcv9/regs.c \
-		sparcv9/m_utils.c \
-		sparcv9/rdb_mach.h \
-		sparcv9/Makefile
-
-DEMOFILES= \
-		00README \
-		Makefile.com \
-		Makefile.targ \
-		common/bpt.c \
-		common/dis.c \
-		common/disasm.c \
-		common/disasm.h \
-		common/main.c \
-		common/ps.c \
-		common/gram.y \
-		common/lex.l \
-		common/globals.c \
-		common/help.c \
-		common/utils.c \
-		common/maps.c \
-		common/syms.c \
-		common/callstack.c \
-		common/rdb.h \
-		common/rdb.man \
-		tests/breaks \
-		tests/loadmaps \
-		tests/object_padding_maps \
-		tests/plt_skip \
-		tests/steps \
-		tests/test-sparc-regs \
-		tests/simp.c \
-		tests/sub.c \
-		$(MACHDEMOFILES)
-
-
-ROOTDEMODIRBASE=	$(ROOT)/usr/demo/librtld_db
-
-ROOTDEMODIRS=	$(ROOTDEMODIRBASE) \
-		$(ROOTDEMODIRBASE)/common \
-		$(ROOTDEMODIRBASE)/tests \
-		$(ROOTDEMODIRBASE)/i386 \
-		$(ROOTDEMODIRBASE)/amd64 \
-		$(ROOTDEMODIRBASE)/sparc \
-		$(ROOTDEMODIRBASE)/sparcv9
-
-ROOTDEMOFILES=	$(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
-
-$(ROOTDEMODIRS) :=	DIRMODE =	755
-
-SED=		sed -e "/DEMO DELETE START/,/DEMO DELETE END/d"
-
-CLEANFILES=	*.demo */*.demo
-
-.KEEP_STATE:
-.PARALLEL:	$(ROOTDEMOFILES)
-
-all catalog chkmsg lint:
-
-install:	$(ROOTDEMODIRS) .WAIT $(ROOTDEMOFILES)
-
-clean clobber: FRC
-	$(RM) $(CLEANFILES)
-
-
-
-
-$(ROOTDEMODIRS):
-		$(INS.dir)
-
-$(ROOTDEMODIRBASE)/Makefile.%: Makefile.%.demo
-		$(INS.rename)
-
-$(ROOTDEMODIRBASE)/%/Makefile: %/Makefile.demo
-		$(INS.rename)
-
-Makefile.%.demo: Makefile.%
-		$(SED) < $< > $@
-
-%/Makefile.demo: %/Makefile
-		$(SED) < $< > $@
-
-$(ROOTDEMODIRBASE)/%: %
-	$(INS.file)
-
-
-$(ROOTDEMODIRBASE)/common/%:	common/%
-		$(INS.file)
-
-$(ROOTDEMODIRBASE)/tests/%:	tests/%
-		$(INS.file)
-
-$(ROOTDEMODIRBASE)/sparc/%:	sparc/%
-		$(INS.file)
-
-$(ROOTDEMODIRBASE)/sparcv9/%:	sparcv9/%
-		$(INS.file)
-
-$(ROOTDEMODIRBASE)/i386/%:	i386/%
-		$(INS.file)
-
-FRC:
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-
-PROG=		rdb
-
-# DEMO DELETE START
-include 	../../../../Makefile.cmd
-# DEMO DELETE END
-
-MACH:sh=	uname -p
-
-CFLAGS +=	$(DEMOCFLAGS)
-
-COMSRC=		bpt.c dis.c main.c ps.c gram.c lex.c globals.c help.c \
-		utils.c maps.c syms.c callstack.c disasm.c
-M_SRC=		regs.c m_utils.c
-
-BLTSRC=		gram.c lex.c
-BLTHDR=		gram.h
-
-# DEMO DELETE START
-ONLDLIBDIR=	/opt/SUNWonld/lib
-
-# DEMO DELETE END
-OBJDIR=		objs
-OBJS =		$(COMSRC:%.c=$(OBJDIR)/%.o) $(M_SRC:%.c=$(OBJDIR)/%.o)
-
-SRCS =		$(COMSRC:%=../common/%) $(M_SRC) $(BLTSRC)
-
-.PARALLEL:	$(OBJS)
-
-CPPFLAGS=	-I../common -I. $(CPPFLAGS.master)
-LDLIBS +=	-lrtld_db -lelf -ll -ly
-
-CLEANFILES +=	$(BLTSRC) $(BLTHDR) simp libsub.so.1
-
-# DEMO DELETE START
-LINTFLAGS +=	$(LDLIBS) -L../../$(MACH)
-CLEANFILES +=	$(LINTOUT)
-# DEMO DELETE END
-
-test-sparc=	test-sparc-regs
-test-i386=	
-TESTS= test-maps test-breaks test-steps test-plt_skip test-object-padding \
-	$(test-$(MACH))
-
-# DEMO DELETE START
-ROOTONLDBIN=		$(ROOT)/opt/SUNWonld/bin
-ROOTONLDBINPROG=	$(PROG:%=$(ROOTONLDBIN)/%)
-ROOTONLDBINPROG64=	$(PROG:%=$(ROOTONLDBIN)/$(MACH64)/%)
-
-FILEMODE=	0755
-# DEMO DELETE END
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/Makefile.targ	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-$(OBJDIR)/%.o:	%.c
-		$(COMPILE.c) $< -o $@
-		$(POST_PROCESS_O)
-
-$(OBJDIR)/%.o:	../common/%.c
-		$(COMPILE.c) $< -o $@
-		$(POST_PROCESS_O)
-
-# DEMO DELETE START
-$(ROOTONLDBIN)/%: %
-		$(INS.file)
-
-$(ROOTONLDBIN)/$(MACH64)/%: %
-		$(INS.file)
-# DEMO DELETE END
-
-$(OBJDIR)/main.o: gram.h
-
-gram.c + gram.h: ../common/gram.y
-	$(YACC) -d ../common/gram.y
-	$(MV) y.tab.c gram.c
-	$(MV) y.tab.h gram.h
-
-lex.c: ../common/lex.l
-	$(LEX) ../common/lex.l
-	$(MV) lex.yy.c lex.c
-
-$(PROG):	$(OBJS)
-		$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
-# DEMO DELETE START
-		$(POST_PROCESS)
-# DEMO DELETE END
-
-
-simp: ../tests/simp.c libsub.so.1
-	$(LINK.c) $(LDFLAG) -o $@ ../tests/simp.c -R. ./libsub.so.1
-
-libsub.so.1: ../tests/sub.c
-	$(LINK.c) $(LDFLAG) -o $@ -G -Kpic -hlibsub.so.1 ../tests/sub.c
-
-#
-# RDB sample runs & tests
-#
-test-maps: simp FRC
-	./rdb -f ../tests/loadmaps ./simp
-
-test-breaks: simp FRC
-	./rdb -f ../tests/breaks ./simp
-
-test-steps: simp FRC
-	./rdb -f ../tests/steps ./simp
-
-test-plt_skip: simp FRC
-	./rdb -f ../tests/plt_skip ./simp
-
-test-sparc-regs: simp FRC
-	./rdb -f ../tests/test-sparc-regs simp
-
-test-object-padding: simp FRC
-	./rdb -f ../tests/object_padding_maps simp
-
-
-
-$(OBJDIR):
-	-@mkdir -p $(OBJDIR)
-
-
-clean: FRC
-		$(RM) $(OBJS) $(CLEANFILES)
-
-clobber: clean FRC
-		$(RM) $(PROG)
-
-FRC:
-
-# DEMO DELETE START
-$(LINTOUT):	$(SRCS)
-		$(LINT.c) $(SRCS) > $(LINTOUT) 2>&1
-
-
-include		../../../../Makefile.targ
-# DEMO DELETE END
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/TODO	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-#pragma	ident	"%Z%%M%	%I%	%E% SMI"
-
-Features yet to be impelemented for rdb:
-
-
-* Displaying of registers for x86
-* Displaying of registers for ppc
-* libdis for ppc
-* libdis for x86
-* stack trace for x86
-* stack trace for ppc
-* ability to read in command file while entering commands from
-  the keyboard (ie: adb's $<'file').
-* add support for the multiple run-time linkers that are loaded
-  when sbcp is invoked
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/amd64/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#
-# 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
-# or http://www.opensolaris.org/os/licensing.
-# 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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include		../Makefile.com
-
-CPPFLAGS +=	-D_SYSCALL32
-
-# DEMO DELETE START
-CCVERBOSE=
-
-LDFLAGS=	-L ../../$(MACH64) \
-		-L ../../../libelf/$(MACH64)
-
-LINTFLAGS64 +=	$(VAR_LIBRTLD_DB_LINTFLAGS64)
-# DEMO DELETE END
-
-# Change -m64 to -xarch=generic64 for use with older Sun compilers.
-DEMOCFLAGS=	-m64
-
-.KEEP_STATE:
-
-all:		$(OBJDIR) .WAIT $(PROG)
-
-test:		$(TESTS)
-
-# DEMO DELETE START
-DEMOCFLAGS=
-
-install:	all $(ROOTONLDBINPROG64)
-
-lint:		$(LINTOUT)
-# DEMO DELETE END
-
-include		../Makefile.targ
-
-$(OBJDIR)/%.o:	../i386/%.c
-		$(COMPILE.c) $< -o $@
-		$(POST_PROCESS_O)
-
-# DEMO DELETE START
-include		../../../../../Makefile.master.64
-# DEMO DELETE END
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/amd64/rdb_mach.h	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _RDB_MACH_H
-#define	_RDB_MACH_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/regset.h>
-#include <sys/psw.h>
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#define	ERRBIT	PS_C
-#define	R_PS	REG_RFL
-
-
-/*
- * Breakpoint instruction
- */
-typedef	unsigned char	bptinstr_t;
-#define	BPINSTR		0xcc		/* int	3 */
-
-
-/*
- * PLT section type
- */
-#define	PLTSECTT	SHT_PROGBITS
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _RDB_MACH_H */
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/amd64/regs.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/reg.h>
-
-#include "rdb.h"
-
-static void
-disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst,
-	char *r1, int ind1, char *r2, int ind2)
-{
-	char	str1[MAXPATHLEN];
-	char	str2[MAXPATHLEN];
-	strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
-		FLG_PAP_NOHEXNAME));
-	strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
-		FLG_PAP_NOHEXNAME));
-
-	printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n",
-		r1, prst->pr_lwp.pr_reg[ind1], str1,
-		r2, prst->pr_lwp.pr_reg[ind2], str2);
-}
-
-
-retc_t
-display_all_regs(struct ps_prochandle *ph)
-{
-	pstatus_t	pstatus;
-	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-	    0) == -1) {
-		perror("dar: reading status");
-		return (RET_FAILED);
-	}
-	printf("registers:\n");
-	disp_reg_line(ph, &pstatus, "gs", REG_GS, "fs", REG_FS);
-	disp_reg_line(ph, &pstatus, "es", REG_ES, "ds", REG_DS);
-	disp_reg_line(ph, &pstatus, "rdi", REG_RDI, "rsi", REG_RSI);
-	disp_reg_line(ph, &pstatus, "rbp", REG_RBP, "rsp", REG_RSP);
-	disp_reg_line(ph, &pstatus, "rbx", REG_RBX, "rdx", REG_RDX);
-	disp_reg_line(ph, &pstatus, "rcx", REG_RCX, "rax", REG_RAX);
-	disp_reg_line(ph, &pstatus, "trapno", REG_TRAPNO, "err", REG_ERR);
-	disp_reg_line(ph, &pstatus, "rip", REG_RIP, "cs", REG_CS);
-	disp_reg_line(ph, &pstatus, "rfl", REG_RFL, "uesp", REG_RSP);
-	return (RET_OK);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/bpt.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,552 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2000 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/fault.h>
-#include <sys/syscall.h>
-#include <procfs.h>
-#include <sys/auxv.h>
-#include <libelf.h>
-#include <sys/param.h>
-#include <stdarg.h>
-
-#include "rdb.h"
-
-
-static const char * fault_strings[] = {
-	"<null string>",
-	"illegal instruction",
-	"privileged instruction",
-	"breakpoint instruction",
-	"trace trap (single-step)",
-	"Memory access (e.g., alignment)",
-	"Memory bounds (invalid address)",
-	"Integer overflow",
-	"Integer zero divide"
-	"Floating-point exception",
-	"Irrecoverable stack faul",
-	"Recoverable page fault (no associated sig)"
-};
-
-#define	MAXFAULT	FLTPAGE
-
-retc_t
-set_breakpoint(struct ps_prochandle * ph, ulong_t addr, unsigned flags)
-{
-	bptlist_t *	new;
-	bptlist_t *	cur;
-	bptlist_t *	prev;
-
-	for (cur = ph->pp_breakpoints, prev = 0;
-	    (cur && (cur->bl_addr < addr));
-	    prev = cur, cur = cur->bl_next)
-		;
-	if (cur && (cur->bl_addr == addr)) {
-		/*
-		 * already have break point set here.
-		 */
-		cur->bl_flags |= flags;
-		return (RET_OK);
-	}
-
-	new = malloc(sizeof (bptlist_t));
-	new->bl_addr = addr;
-	new->bl_flags = flags;
-	if (prev == 0) {
-		/*
-		 * insert at head
-		 */
-		new->bl_next = ph->pp_breakpoints;
-		ph->pp_breakpoints = new;
-		return (RET_OK);
-	}
-
-	prev->bl_next = new;
-	new->bl_next = cur;
-	return (RET_OK);
-}
-
-bptlist_t *
-find_bp(struct ps_prochandle * ph, ulong_t addr)
-{
-	bptlist_t *	cur;
-
-	for (cur = ph->pp_breakpoints;
-	    (cur && (cur->bl_addr != addr));
-	    cur = cur->bl_next)
-		;
-
-	if ((cur == 0) || (cur->bl_addr != addr))
-		return ((bptlist_t *)-1);
-	return (cur);
-}
-
-
-retc_t
-delete_bp(struct ps_prochandle * ph, ulong_t addr)
-{
-	bptlist_t *	cur;
-	bptlist_t *	prev;
-
-	for (cur = ph->pp_breakpoints, prev = 0;
-	    (cur && (cur->bl_addr < addr));
-	    prev = cur, cur = cur->bl_next)
-		;
-	if ((cur == 0) || (cur->bl_addr != addr))
-		return (RET_FAILED);
-
-	if (prev == 0)
-		ph->pp_breakpoints = cur->bl_next;
-	else
-		prev->bl_next = cur->bl_next;
-
-	free(cur);
-	return (RET_OK);
-}
-
-
-void
-list_breakpoints(struct ps_prochandle * ph)
-{
-	bptlist_t *	cur;
-
-	if (ph->pp_breakpoints == 0) {
-		printf("no active breakpoints.\n");
-		return;
-	}
-
-	printf("active breakpoints:\n");
-	for (cur = ph->pp_breakpoints; cur; cur = cur->bl_next) {
-		printf("\t0x%08lx:0x%04x - %s\n", cur->bl_addr,
-			cur->bl_flags,
-			print_address_ps(ph, cur->bl_addr,
-			FLG_PAP_SONAME));
-	}
-}
-
-
-static void
-set_breaks(struct ps_prochandle * ph)
-{
-	bptlist_t *	cur;
-	bptinstr_t	bpt_instr = BPINSTR;
-
-	for (cur = ph->pp_breakpoints; cur; cur = cur->bl_next) {
-		bptinstr_t	old_inst;
-		old_inst = 0;
-
-		if (ps_pread(ph, cur->bl_addr, (char *)&old_inst,
-		    sizeof (bptinstr_t)) != PS_OK)
-			perr("sb: error setting breakpoint");
-
-		cur->bl_instr = old_inst;
-
-		if (ps_pwrite(ph, cur->bl_addr, (char *)&bpt_instr,
-		    sizeof (bptinstr_t)) != PS_OK)
-			perr("sb1: error setting breakpoint\n");
-	}
-
-}
-
-
-static void
-clear_breaks(struct ps_prochandle * ph)
-{
-	bptlist_t *	cur;
-
-	/*
-	 * Restore all the original instructions
-	 */
-	for (cur = ph->pp_breakpoints; cur; cur = cur->bl_next)
-		if (ps_pwrite(ph, cur->bl_addr, (char *)&(cur->bl_instr),
-		    sizeof (bptinstr_t)) != PS_OK)
-			perr("cb: error clearing breakpoint");
-}
-
-retc_t
-delete_all_breakpoints(struct ps_prochandle * ph)
-{
-	bptlist_t *	cur;
-	bptlist_t *	prev;
-
-
-	if (ph->pp_breakpoints == 0)
-		return (RET_OK);
-
-	for (prev = 0, cur = ph->pp_breakpoints;
-	    cur; prev = cur, cur = cur->bl_next)
-		if (prev)
-			free(prev);
-	if (prev)
-		free(prev);
-
-	ph->pp_breakpoints = 0;
-	return (RET_OK);
-}
-
-retc_t
-delete_breakpoint(struct ps_prochandle * ph, ulong_t addr, unsigned flags)
-{
-	bptlist_t *	bpt;
-
-	if (((bpt = find_bp(ph, addr)) == (bptlist_t *)-1) ||
-	    ((bpt->bl_flags & flags) == 0))
-		return (RET_FAILED);
-
-	bpt->bl_flags &= ~flags;
-	if (bpt->bl_flags)
-		return (RET_OK);
-
-	return (delete_bp(ph, addr));
-}
-
-
-static void
-handle_sp_break(struct ps_prochandle * ph)
-{
-	rd_event_msg_t	emt;
-
-	if (rd_event_getmsg(ph->pp_rap, &emt) != RD_OK) {
-		fprintf(stderr, "hsb: failed rd_event_getmsg()\n");
-		return;
-	}
-
-
-	if (emt.type == RD_DLACTIVITY) {
-		if (emt.u.state == RD_CONSISTENT)
-			ph->pp_flags |= FLG_PP_LMAPS;
-		else
-			ph->pp_flags &= ~FLG_PP_LMAPS;
-		if ((rdb_flags & RDB_FL_EVENTS) == 0)
-			return;
-
-		printf("dlactivity: state changed to: ");
-		switch (emt.u.state) {
-		case RD_CONSISTENT:
-			printf("RD_CONSISTENT\n");
-			break;
-		case RD_ADD:
-			printf("RD_ADD\n");
-			break;
-		case RD_DELETE:
-			printf("RD_DELETE\n");
-			break;
-		default:
-			printf("unknown: 0x%x\n", emt.u.state);
-		}
-		return;
-	}
-
-	if ((rdb_flags & RDB_FL_EVENTS) == 0)
-		return;
-
-	if (emt.type == RD_PREINIT) {
-		printf("preinit reached\n");
-		return;
-	}
-
-	if (emt.type == RD_POSTINIT)
-		printf("postinit reached\n");
-}
-
-unsigned
-continue_to_break(struct ps_prochandle * ph)
-{
-	bptlist_t *	bpt;
-	pstatus_t	pstatus;
-	struct iovec	piov[5];
-	long		oper1, oper2, oper3;
-	long		pflags = 0;
-	fltset_t	faults;
-
-	/*
-	 * We step by the first instruction incase their was
-	 * a break-point there.
-	 */
-	step_n(ph, 1, FLG_SN_NONE);
-
-
-	premptyset(&faults);
-	praddset(&faults, FLTBPT);
-	praddset(&faults, FLTILL);
-	praddset(&faults, FLTPRIV);
-	praddset(&faults, FLTACCESS);
-	praddset(&faults, FLTBOUNDS);
-	praddset(&faults, FLTIZDIV);
-	praddset(&faults, FLTSTACK);
-	praddset(&faults, FLTTRACE);
-
-
-	/* LINTED CONSTANT */
-	while (1) {
-		set_breaks(ph);
-		oper1 = PCSFAULT;
-		piov[0].iov_base = (caddr_t)(&oper1);
-		piov[0].iov_len = sizeof (oper1);
-
-		piov[1].iov_base = (caddr_t)(&faults);
-		piov[1].iov_len = sizeof (faults);
-
-		oper2 = PCRUN;
-		piov[2].iov_base = (caddr_t)(&oper2);
-		piov[2].iov_len = sizeof (oper2);
-		pflags = PRCFAULT;
-		piov[3].iov_base = (caddr_t)(&pflags);
-		piov[3].iov_len = sizeof (pflags);
-
-		oper3 = PCWSTOP;
-		piov[4].iov_base = (caddr_t)(&oper3);
-		piov[4].iov_len = sizeof (oper3);
-
-		if (writev(ph->pp_ctlfd, piov, 5) == -1) {
-			if (errno == ENOENT) {
-				ph->pp_flags &= ~FLG_PP_PACT;
-				ps_close(ph);
-				printf("process terminated.\n");
-				return (0);
-			}
-			perr("ctb: PCWSTOP");
-		}
-
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
-			perr("ctb: reading status");
-
-
-		if ((pstatus.pr_lwp.pr_why != PR_FAULTED) ||
-		    (pstatus.pr_lwp.pr_what != FLTBPT)) {
-			const char * fltmsg;
-			if ((pstatus.pr_lwp.pr_what <= MAXFAULT) &&
-			    (pstatus.pr_lwp.pr_why == PR_FAULTED))
-				fltmsg = fault_strings[pstatus.pr_lwp.pr_what];
-			else
-				fltmsg = "<unknown error>";
-
-			fprintf(stderr, "ctb: bad stop - stoped on why: 0x%x "
-				"what: %s(0x%x)\n",
-				pstatus.pr_lwp.pr_why, fltmsg,
-				pstatus.pr_lwp.pr_what);
-			return (0);
-		}
-
-		oper1 = PCCFAULT;
-		if (writev(ph->pp_ctlfd, piov, 1) == -1)
-			perr("ctb: PCCFAULT");
-
-		if ((bpt = find_bp(ph, pstatus.pr_lwp.pr_reg[R_PC])) ==
-		    (bptlist_t *)-1) {
-			fprintf(stderr,
-			    "stoped at unregistered breakpoint! "
-			    "addr: 0x%lx\n",
-			    pstatus.pr_lwp.pr_reg[R_PC]);
-			break;
-		}
-		clear_breaks(ph);
-
-		/*
-		 * If this was a BP at which we should stop
-		 */
-		if (bpt->bl_flags & MASK_BP_STOP)
-			break;
-
-		step_n(ph, 1, FLG_SN_NONE);
-	}
-
-	if (bpt->bl_flags & FLG_BP_USERDEF)
-		printf("break point reached at addr: 0x%lx\n",
-			pstatus.pr_lwp.pr_reg[R_PC]);
-
-	if (bpt->bl_flags & MASK_BP_SPECIAL)
-		handle_sp_break(ph);
-
-	if (ph->pp_flags & FLG_PP_LMAPS) {
-		if (get_linkmaps(ph) != PS_OK)
-			fprintf(stderr, "problem loading linkmaps\n");
-	}
-
-	return (bpt->bl_flags);
-}
-
-
-ulong_t
-is_plt(struct ps_prochandle * ph, ulong_t pc)
-{
-	map_info_t *	mip;
-	ulong_t	pltbase;
-
-	if ((mip = addr_to_map(ph, pc)) == (map_info_t *)0)
-		return ((ulong_t)0);
-
-	pltbase = mip->mi_pltbase;
-	if ((mip->mi_flags & FLG_MI_EXEC) == 0)
-		pltbase += mip->mi_addr;
-
-	if ((pc >= pltbase) && (pc <= (pltbase + mip->mi_pltsize)))
-		return (pltbase);
-
-	return ((ulong_t)0);
-}
-
-
-retc_t
-step_n(struct ps_prochandle * ph, size_t count, sn_flags_e flgs)
-{
-	pstatus_t	pstatus;
-	fltset_t	faults;
-	int		i;
-	long		oper;
-	long		flags;
-	struct iovec	piov[2];
-
-	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
-		perr("stn: reading status");
-
-	piov[0].iov_base = (caddr_t)(&oper);
-	piov[0].iov_len = sizeof (oper);
-
-	premptyset(&faults);
-	praddset(&faults, FLTTRACE);
-
-	flags = PRSTEP | PRCFAULT;
-
-	for (i = 0; i < count; i++) {
-		bptlist_t *	bpt;
-		uintptr_t	pc;
-		uintptr_t	pltbase;
-
-		pc = pstatus.pr_lwp.pr_reg[R_PC];
-
-		if ((bpt = find_bp(ph, pc)) != (bptlist_t *)-1) {
-			if (bpt->bl_flags & MASK_BP_SPECIAL)
-				handle_sp_break(ph);
-		}
-
-		if (flgs & FLG_SN_VERBOSE)
-			disasm(ph, 1);
-
-		oper = PCSFAULT;
-		piov[1].iov_base = (caddr_t)(&faults);
-		piov[1].iov_len = sizeof (faults);
-
-		if (writev(ph->pp_ctlfd, piov, 2) == -1)
-			perr("stn: PCSFAULT");
-
-		oper = PCRUN;
-		piov[1].iov_base = (caddr_t)(&flags);
-		piov[1].iov_len = sizeof (flags);
-		if (writev(ph->pp_ctlfd, piov, 2) == -1)
-			perr("stn: PCRUN(PRSETP)");
-
-		oper = PCWSTOP;
-		if (writev(ph->pp_ctlfd, piov, 1) == -1)
-			perr("stn: PCWSTOP stepping");
-
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
-			perr("stn1: reading status");
-		pc = pstatus.pr_lwp.pr_reg[R_PC];
-
-
-		if ((pstatus.pr_lwp.pr_why != PR_FAULTED) ||
-		    (pstatus.pr_lwp.pr_what != FLTTRACE)) {
-			fprintf(stderr, "sn: bad stop - stoped on why: 0x%x "
-				"what: 0x%x\n",
-				pstatus.pr_lwp.pr_why, pstatus.pr_lwp.pr_what);
-			return (RET_FAILED);
-		}
-
-		if ((flgs & FLG_SN_PLTSKIP) &&
-		    ((pltbase = is_plt(ph, pc)) != (ulong_t)0)) {
-			rd_plt_info_t	rp;
-			if (rd_plt_resolution(ph->pp_rap, pc,
-			    pstatus.pr_lwp.pr_lwpid, pltbase, &rp) != RD_OK) {
-				fprintf(stderr,
-				    "sn: rd_plt_resolution failed\n");
-				return (RET_FAILED);
-			}
-			if (rp.pi_skip_method == RD_RESOLVE_TARGET_STEP) {
-				unsigned	bpflags;
-
-				set_breakpoint(ph, rp.pi_target,
-					FLG_BP_PLTRES);
-				bpflags = continue_to_break(ph);
-				delete_breakpoint(ph, rp.pi_target,
-					FLG_BP_PLTRES);
-				if (bpflags & FLG_BP_PLTRES)
-					step_n(ph, rp.pi_nstep, FLG_SN_NONE);
-			} else if (rp.pi_skip_method == RD_RESOLVE_STEP)
-				step_n(ph, rp.pi_nstep, FLG_SN_NONE);
-		}
-
-	}
-	oper = PRCFAULT;
-	if (writev(ph->pp_ctlfd, piov, 1) == -1)
-		perr("stn: PRCFAULT");
-
-	if ((flgs & FLG_SN_VERBOSE) && (ph->pp_flags & FLG_PP_LMAPS)) {
-		if (get_linkmaps(ph) != PS_OK)
-			fprintf(stderr, "problem loading linkmaps\n");
-	}
-
-	return (RET_OK);
-}
-
-
-void
-step_to_addr(struct ps_prochandle * ph, ulong_t addr)
-{
-	pstatus_t	pstat;
-	int		count = 0;
-	ulong_t		caddr;
-
-	if (read(ph->pp_statusfd, &pstat, sizeof (pstat)) == -1)
-		perr("sta: reading status");
-
-	caddr = pstat.pr_lwp.pr_reg[R_PC];
-
-	while ((caddr > addr) || ((caddr + 0xff) < addr)) {
-		step_n(ph, 1, FLG_SN_NONE);
-		if (read(ph->pp_statusfd, &pstat, sizeof (pstat)) == -1)
-			perr("sta1: reading status");
-		caddr = pstat.pr_lwp.pr_reg[R_PC];
-		if ((count % 10000) == 0) {
-			printf("%d: ", count);
-			disasm(ph, 1);
-		}
-
-		count++;
-	}
-
-	printf("address found %d instructions in: pc: 0x%lx addr: 0x%lx\n",
-		count, caddr, addr);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/callstack.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * 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
- * or http://www.opensolaris.org/os/licensing.
- * 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 <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/reg.h>
-#include <sys/frame.h>
-#include <sys/stack.h>
-#include <procfs.h>
-
-#include "rdb.h"
-
-#ifndef	STACK_BIAS
-#define	STACK_BIAS	0
-#endif
-
-static int
-get_frame(struct ps_prochandle *ph, psaddr_t fp, struct frame *frm)
-{
-#if	defined(_LP64)
-	/*
-	 * Use special structures to read a 32-bit process
-	 * from a 64-bit process.
-	 */
-	if (ph->pp_dmodel == PR_MODEL_ILP32) {
-		struct frame32	frm32;
-
-		if (ps_pread(ph, (psaddr_t)fp, (char *)&frm32,
-		    sizeof (struct frame32)) != PS_OK) {
-			printf("stack trace: bad frame pointer: 0x%lx\n",
-				fp);
-			return (-1);
-		}
-
-		frm->fr_savpc = (long)frm32.fr_savpc;
-#if	defined(__sparcv9)
-		frm->fr_savfp = (struct frame *)(uintptr_t)frm32.fr_savfp;
-#elif	defined(__amd64)
-		frm->fr_savfp = (long)frm32.fr_savfp;
-#endif
-		return (0);
-	}
-#endif	/* defined(_LP64) */
-
-	if (ps_pread(ph, (psaddr_t)fp + STACK_BIAS, (char *)frm,
-	    sizeof (struct frame)) != PS_OK) {
-		printf("stack trace: bad frame pointer: 0x%lx\n", fp);
-		return (-1);
-	}
-	return (0);
-}
-
-/*
- * Relatively architecture neutral routine to display the callstack.
- */
-void
-CallStack(struct ps_prochandle *ph)
-{
-	pstatus_t	pstatus;
-	greg_t		fp;
-	struct frame	frm;
-	char		*symstr;
-
-	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
-		perr("cs: reading status");
-
-	symstr = print_address_ps(ph, (ulong_t)pstatus.pr_lwp.pr_reg[R_PC],
-		FLG_PAP_SONAME);
-	printf(" 0x%08lx:%-17s\n", pstatus.pr_lwp.pr_reg[R_PC],
-		symstr);
-
-	fp = pstatus.pr_lwp.pr_reg[R_FP];
-
-	while (fp) {
-		if (get_frame(ph, (psaddr_t)fp, &frm) == -1)
-			return;
-		if (frm.fr_savpc) {
-			symstr = print_address_ps(ph, (ulong_t)frm.fr_savpc,
-				FLG_PAP_SONAME);
-			printf(" 0x%08lx:%-17s\n", frm.fr_savpc,
-				symstr);
-		}
-		fp = (greg_t)frm.fr_savfp;
-	}
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/dis.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2000 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/fault.h>
-#include <sys/syscall.h>
-#include <procfs.h>
-#include <sys/auxv.h>
-#include <libelf.h>
-#include <sys/param.h>
-#include <stdarg.h>
-
-#include "rdb.h"
-#include "disasm.h"
-
-
-/*
- * I don't link this global but it's a work-around for the
- * poor disassemble interface for now.
- */
-static struct ps_prochandle *	cur_ph;
-
-/*
- * This routine converts 'address' into it's closest symbol
- * representation.
- *
- * The following flags are used to effect the output:
- *
- *	FLG_PAP_SONAME
- *		embed the SONAME in the symbol name
- *	FLG_PAP_NOHEXNAME
- *		if no symbol found return a null string
- *		If this flag is not set return a string displaying
- *		the 'hex' value of address.
- *	FLG_PAP_PLTDECOM
- *		decompose the PLT symbol if possible
- */
-char *
-print_address_ps(struct ps_prochandle * ph, ulong_t address, unsigned flags)
-{
-	static char	buf[256];
-	GElf_Sym	sym;
-	char *		str;
-	ulong_t		val;
-
-	if (addr_to_sym(ph, address, &sym, &str) == RET_OK) {
-		map_info_t *	mip;
-		ulong_t		pltbase;
-
-		if (flags & FLG_PAP_SONAME) {
-			/*
-			 * Embed SOName in symbol name
-			 */
-			if (mip = addr_to_map(ph, address)) {
-				strcpy(buf, mip->mi_name);
-				strcat(buf, ":");
-			} else
-				sprintf(buf, "0x%08lx:", address);
-		} else
-			buf[0] = '\0';
-
-		if ((flags & FLG_PAP_PLTDECOM) &&
-		    (pltbase = is_plt(ph, address)) != 0) {
-			rd_plt_info_t	rp;
-			pstatus_t	pstatus;
-
-			if (pread(ph->pp_statusfd, &pstatus,
-			    sizeof (pstatus), 0) == -1)
-				perr("pap: reading pstatus");
-
-			if (rd_plt_resolution(ph->pp_rap, address,
-			    pstatus.pr_lwp.pr_lwpid, pltbase,
-			    &rp) == RD_OK) {
-				if (rp.pi_flags & RD_FLG_PI_PLTBOUND) {
-					GElf_Sym	_sym;
-					char *		_str;
-					if (addr_to_sym(ph, rp.pi_baddr,
-					    &_sym, &_str) == RET_OK) {
-						sprintf(buf,
-						    "%s0x%lx:plt(%s)",
-						    buf, address, _str);
-						return (buf);
-					}
-				}
-			}
-			val = sym.st_value;
-			sprintf(buf, "%s0x%lx:plt(unbound)+0x%lx", buf,
-			    address, address - val);
-			return (buf);
-		} else {
-
-			val = sym.st_value;
-
-			if (val < address)
-				sprintf(buf, "%s%s+0x%lx", buf, str,
-					address - val);
-			else
-				sprintf(buf, "%s%s", buf, str);
-			return (buf);
-		}
-	} else {
-		if (flags & FLG_PAP_NOHEXNAME)
-			buf[0] = '\0';
-		else
-			sprintf(buf, "0x%lx", address);
-		return (buf);
-	}
-}
-
-
-char *
-print_address(unsigned long address)
-{
-	return (print_address_ps(cur_ph, address,
-		FLG_PAP_SONAME| FLG_PAP_PLTDECOM));
-}
-
-retc_t
-disasm_addr(struct ps_prochandle * ph, ulong_t addr, int num_inst)
-{
-	ulong_t 	offset;
-	ulong_t 	end;
-	int		vers = V8_MODE;
-
-	if (ph->pp_dmodel == PR_MODEL_LP64)
-		vers = V9_MODE | V9_SGI_MODE;
-
-	for (offset = addr,
-	    end = addr + num_inst * 4;
-	    offset < end; offset += 4) {
-		char *		instr_str;
-		unsigned int	instr;
-
-		if (ps_pread(ph, offset, (char *)&instr,
-		    sizeof (unsigned)) != PS_OK)
-			perror("da: ps_pread");
-
-		cur_ph = ph;
-		instr_str = disassemble(instr, offset, print_address,
-			0, 0, vers);
-
-		printf("%-30s: %s\n", print_address(offset), instr_str);
-	}
-	return (RET_OK);
-}
-
-void
-disasm(struct ps_prochandle * ph, int num_inst)
-{
-	pstatus_t	pstat;
-
-	if (pread(ph->pp_statusfd, &pstat, sizeof (pstat), 0) == -1)
-		perr("disasm: PIOCSTATUS");
-
-	disasm_addr(ph, (ulong_t)pstat.pr_lwp.pr_reg[R_PC], num_inst);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/disasm.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-
-#include "rdb.h"
-
-
-typedef char *(*FUNCPTR)();
-
-
-/*
- * stub routine until I can figure out what to plug in here.
- */
-/* ARGSUSED 1 */
-char *
-disassemble(unsigned int instr, unsigned long pc,
-	FUNCPTR prtAddress, unsigned int next, unsigned int prev,
-	int vers)
-{
-	static char	buf[256];
-	sprintf(buf, "0x%x", instr);
-	return (buf);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/disasm.h	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#if ! defined(_DISASM_H)
-#define	_DISASM_H
-
-typedef char *(*FUNCPTR)();
-
-extern char *	disassemble(unsigned int, unsigned long, FUNCPTR,
-			unsigned int, unsigned int, int);
-
-#define	V8_MODE		1	/* V8 */
-#define	V9_MODE		2	/* V9 */
-#define	V9_SGI_MODE	4	/* V9/SGI */
-
-#endif
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/globals.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#include <libelf.h>
-#include "rdb.h"
-
-
-unsigned long		rdb_flags = 0;	/* misc flags for rdb */
-
-struct ps_prochandle	proch;
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/gram.y	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,286 +0,0 @@
-%{
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1998 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <libelf.h>
-#include "rdb.h"
-
-extern	void	rdb_prompt();
-
-%}
-
-%token	VALUE STEP HELP NUMBER NEWLINE SYMBOL PLUS BREAK CONT DIS GETMAPS
-%token	DELETE MAPS PLTSKIP WHERE PRINT OBJPAD QSTRING VARSTRING ECHO_OUT
-%token	EVENT LINKMAPS
-
-%union {
-	char *		str;
-	ulong_t		addr;
-	int		num;
-}
-
-%type <addr> NUMBER address 
-%type <str> SYMBOL QSTRING VARSTRING
-
-%left PLUS
-
-%%
-start: commands
-	;
-
-commands: /* empty */
-	| commands command
-	;
-command: BREAK NEWLINE
-	{
-		list_breakpoints(&proch);
-		rdb_prompt();
-	}
-	| BREAK address NEWLINE
-	{
-		if (set_breakpoint(&proch, $2, FLG_BP_USERDEF) == RET_OK)
-			printf("break point set at: 0x%lx\n", (unsigned long)$2);
-		else
-			printf("unable to set breakpoint.\n");
-		rdb_prompt();
-	}
-	| CONT NEWLINE
-	{
-		continue_to_break(&proch);
-		rdb_prompt();
-	}
-	| DELETE address NEWLINE
-	{
-		if (delete_breakpoint(&proch, $2, FLG_BP_USERDEF) != RET_OK)
-			printf("unable to delete breakpoint at %#lx\n", (unsigned long)$2);
-		else
-			printf("breakpoint deleted at 0x%lx\n", (unsigned long)$2);
-
-		rdb_prompt();
-	}
-	| DIS NEWLINE
-	{
-		disasm(&proch, 10);
-		rdb_prompt();
-	}
-	| DIS address NEWLINE
-	{
-		disasm_addr(&proch, (ulong_t)$2, 10);
-		rdb_prompt();
-	}
-	| DIS address NUMBER NEWLINE
-	{
-		disasm_addr(&proch, (ulong_t)$2, (int)$3);
-		rdb_prompt();
-	}
-	| ECHO_OUT QSTRING NEWLINE
-	{
-		puts($2);
-		free ($2);
-		rdb_prompt();
-	}
-	| EVENT SYMBOL NEWLINE
-	{
-		if (strcmp($2, "on") == 0) {
-			printf("rdb: event information enabled.\n");
-			rdb_flags |= RDB_FL_EVENTS;
-		} else if (strcmp($2, "off") == 0) {
-			printf("rdb: event information disabled.\n");
-			rdb_flags &= ~RDB_FL_EVENTS;
-		} else {
-			printf("rdb: unknown event command: %s\n", $2);
-		}
-		free($2);
-		rdb_prompt();
-	}
-	| GETMAPS NEWLINE
-	{
-		if (get_linkmaps(&proch) != RET_OK)
-			printf("get_linkmaps failed\n");
-
-		rdb_prompt();
-	}
-	| LINKMAPS NEWLINE
-	{
-		if (display_linkmaps(&proch) != RET_OK)
-			printf("display_linkmaps failed\n");
-		rdb_prompt();
-	}
-	| MAPS NEWLINE
-	{
-		if (display_maps(&proch) != RET_OK)
-			printf("display_maps failed\n");
-
-		rdb_prompt();
-	}
-	| STEP NEWLINE
-	{
-		sn_flags_e	sf;
-
-		printf("single step\n");
-		sf = FLG_SN_VERBOSE;
-		if (proch.pp_flags & FLG_PP_PLTSKIP)
-			sf |= FLG_SN_PLTSKIP;
-
-		step_n(&proch, 1, sf);
-		rdb_prompt();
-	}
-	| STEP NUMBER NEWLINE
-	{
-		sn_flags_e	sf;
-
-		printf("stepping %d\n", (int)$2);
-
-		sf = FLG_SN_VERBOSE;
-		if (proch.pp_flags & FLG_PP_PLTSKIP)
-			sf |= FLG_SN_PLTSKIP;
-
-		step_n(&proch, $2, sf);
-		rdb_prompt();
-	}
-	| STEP NUMBER SYMBOL NEWLINE
-	{
-		sn_flags_e	sf;
-
-		sf = FLG_SN_VERBOSE;
-		if (proch.pp_flags & FLG_PP_PLTSKIP)
-			sf |= FLG_SN_PLTSKIP;
-
-		if (strcmp("silent", $3) == 0)
-			step_n(&proch, $2, sf);
-		else
-			printf("error: step <count> [silent]\n");
-
-		free($3);
-		rdb_prompt();
-	}
-	| HELP NEWLINE
-	{
-		rdb_help(0);
-		rdb_prompt();
-	}
-	| HELP SYMBOL NEWLINE
-	{
-		rdb_help($2);
-		free($2);
-		rdb_prompt();
-	}
-	| OBJPAD NUMBER NEWLINE
-	{
-		printf("setting object padding to: %#lx\n", $2);
-		set_objpad(&proch, $2);
-		rdb_prompt();
-	}
-	| PLTSKIP NEWLINE
-	{
-		if (proch.pp_flags & FLG_PP_PLTSKIP) {
-			proch.pp_flags &= ~ FLG_PP_PLTSKIP;
-			printf("plt skipping disabled\n");
-		} else {
-			proch.pp_flags |= FLG_PP_PLTSKIP;
-			printf("plt skipping enabled\n");
-		}
-
-		rdb_prompt();
-	}
-	| PRINT VARSTRING NEWLINE
-	{
-		print_varstring(&proch, $2);
-		free($2);
-		rdb_prompt();
-	}
-	| PRINT address NEWLINE
-	{
-		print_mem(&proch, $2, 4, "X");
-		rdb_prompt();
-	}
-	| PRINT address NUMBER NEWLINE
-	{
-		print_mem(&proch, $2, (int)$3, "X");
-		rdb_prompt();
-	}
-	| PRINT address NUMBER SYMBOL NEWLINE
-	{
-		print_mem(&proch, $2, (int)$3, $4);
-		rdb_prompt();
-	}
-	| VALUE address NEWLINE
-	{
-		printf("value: %#lx\n", (unsigned long)$2);
-		rdb_prompt();
-	}
-	| WHERE NEWLINE
-	{
-		printf("printing stack trace\n");
-		CallStack(&proch);
-		rdb_prompt();
-	}
-	| error NEWLINE
-	{
-		yyerrok;
-		rdb_prompt();
-	}
-	| NEWLINE
-	{
-		disasm(&proch, 1);
-		rdb_prompt();
-	}
-	;
-
-address: address PLUS address
-	{
-		$$ = $1 + $3;
-	}
-	| SYMBOL
-	{
-		GElf_Sym	sym;
-		if (str_to_sym(&proch, $1, &sym) == RET_OK)
-			$$ = (ulong_t)sym.st_value;
-		else {
-			printf("unknown symbol: %s\n", $1);
-			$$ = 0;
-		}
-		free($1);
-	}
-	| NUMBER
-	{
-		$$ = $1;
-	}
-	;
-%%
-
-void
-rdb_prompt()
-{
-	if (proch.pp_flags & FLG_PP_PROMPT) {
-		fputs("<rdb> ", stdout);
-		fflush(stdout);
-	}
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/help.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,242 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-#include <libelf.h>
-#include <string.h>
-
-#include "rdb.h"
-
-
-typedef struct {
-	char *	ht_key;		/* HELP keyword for topic */
-	char *	ht_desc;	/* description of topic */
-	void (*	ht_func)();	/* detailed info on topic */
-} help_topics;
-
-
-static void
-break_help()
-{
-	printf("Break Help:\n"
-		"\tbreak            - list breakpoints\n"
-		"\tbreak <address>  - set break point at <address\n");
-}
-
-static void
-delete_help()
-{
-	printf("Delete Help:\n"
-		"\tdelete <address> - delete breakpoint at <address>\n");
-}
-
-static void
-dis_help()
-{
-	printf("Disassemble Help:\n"
-		"\tdis -\t\t\tdisassemble from current PC\n"
-		"\tdis <address> [count] -\tdissasemble from address for\n"
-		"\t\t\t\t<count> instructions\n");
-}
-
-static void
-echo_help()
-{
-	printf("Echo Help:\n"
-		"\tEcho '<quoted string>'\n"
-		"\t\tthe echo command can be used to display output to\n"
-		"\t\tthe main terminal.  This is useful when running\n"
-		"\t\tcommand scripts and wanting to display status\n"
-		"\n"
-		"\t\tcurrently only <quoted strings> may be displayed\n");
-}
-
-static void
-print_help()
-{
-	printf("Print Help:\n"
-		"\tprint <address> [count [format]]\n"
-		"\t\tcount  - number of units to print (default 4)\n"
-		"\t\tformat - how to display data:\n"
-		"\t\t\t\tX - Hex Words (default)\n"
-		"\t\t\t\tb - unsigned hex bytes\n"
-		"\t\t\t\ts - string\n"
-		"\tprint <varname>\n"
-		"\t\thelp varname for more info\n");
-}
-
-
-static void
-step_help()
-{
-	printf("Step Help:\n");
-	printf("\tstep -		step one instruction.\n");
-	printf("\tstep count [silent] -	step count instructions\n");
-	printf("\t\t\t\tif silent is specified to not disassemble\n"
-		"\t\t\t\tinstr. durring stepping\n");
-}
-
-static void
-value_help()
-{
-	printf("Value Help:\n"
-		"\tvalue <symbol name> -\tdisplay the value associated with\n"
-	"\t\t\t\tsymbol <symbol name>.\n");
-}
-
-static void
-varname_help()
-{
-	printf("Variable Name Help:\n"
-		"\tVariable names are in the form of $<name> and are used\n"
-		"\tto access special information.  Possible varnames\n"
-		"\tare:\n"
-		"\t\tcommon:\n"
-		"\t\t\t$regs - display all registers\n"
-		"\t\tsparc:\n"
-		"\t\t\t$ins -   display IN registers\n"
-		"\t\t\t$globs - display GLOBAL registers\n"
-		"\t\t\t$outs -  display OUT registers\n"
-		"\t\t\t$locs -  display LOCAL registers\n"
-		"\t\t\t$specs -  display SPECIAL registers\n"
-		"\t\ti86pc:\n");
-}
-
-
-static const help_topics	htops[] = {
-	{
-		"break",
-		"Set and display breakpoints",
-		break_help
-	},
-	{
-		"cont",
-		"continue execution of process",
-		0
-	},
-	{
-		"delete",
-		"delete breakpoints",
-		delete_help
-	},
-	{
-		"dis",
-		"Help on the Disassemble Command",
-		dis_help
-	},
-	{
-		"echo",
-		"Help on the Echo Command",
-		echo_help
-	},
-	{
-		"event",
-		"event [on|off] to enable or disable event information",
-		0
-	},
-	{
-		"getmaps",
-		"Read Link_Map structure from run-time linker",
-		0
-	},
-	{
-		"linkmaps",
-		"Display link-map information",
-		0
-	},
-	{
-		"maps",
-		"Display memory mapping information",
-		0
-	},
-	{
-		"objpad",
-		"Set object padding for ld.so.1 mmap'ed objects",
-		0
-	},
-	{
-		"pltskip",
-		"Enables and disables stepping through PLT's",
-		0
-	},
-	{
-		"print",
-		"Display memory at <address>",
-		print_help
-	},
-	{
-		"step",
-		"Help on the Step Command",
-		step_help
-	},
-	{
-		"value",
-		"Help on the Value Command",
-		value_help
-	},
-	{
-		"varname",
-		"Help on $variable values",
-		varname_help
-	},
-	{
-		"where",
-		"Display stack trace",
-		0
-	},
-	{
-		0,
-		0,
-		0
-	}
-};
-
-void
-rdb_help(const char * topic) {
-	int	i;
-	if (topic) {
-		for (i = 0; htops[i].ht_key; i++) {
-			if (strcmp(htops[i].ht_key, topic) == 0) {
-				if (htops[i].ht_func)
-					htops[i].ht_func();
-				else
-					printf("no additional help available"
-					    " for %s\n", htops[i].ht_key);
-				return;
-			}
-		}
-		printf("Help not available for topic: %s\n", topic);
-	}
-	printf("The following commands are available\n");
-	for (i = 0; htops[i].ht_key; i++) {
-		printf("\t%10s\t%s", htops[i].ht_key, htops[i].ht_desc);
-		if (htops[i].ht_func)
-			putchar('*');
-		putchar('\n');
-	}
-	printf("\n(*) more help is available by typing 'help <topic>'\n\n");
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/lex.l	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-%{
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include "gram.h"
-#include "rdb.h"
-%}
-
-ws		[ \t]+
-nl		\n
-symbol		[_a-zA-Z][_a-zA-Z0-9]*
-varstring	\$[_a-zA-Z][_a-zA-Z0-9]*	/* $<name> */
-hexnumber	0[xX][0-9a-zA-Z]+
-decnumber	[0-9]+
-qstring		\"[^\"\n]*[\"\n]
-
-%%
-\#[^\n]*		;	/* igore comments */
-\\\n			;	/* perform line continuation... */
-{ws}			;	/* ignore whitespace */
-{hexnumber}		{yylval.addr = hexstr_to_num(yytext); return (NUMBER);}
-{decnumber}		{yylval.addr = atoi(yytext); return (NUMBER);}
-\+			{return (PLUS);}
-^{ws}*break		{return (BREAK);}
-^{ws}*cont		{return (CONT);}
-^{ws}*echo		{return (ECHO_OUT);}
-^{ws}*event		{return (EVENT);}
-^{ws}*delete		{return (DELETE);}
-^{ws}*dis		{return (DIS);}
-^{ws}*getmaps		{return (GETMAPS);}
-^{ws}*help		{return (HELP);}
-^{ws}*linkmaps		{return (LINKMAPS);}
-^{ws}*maps		{return (MAPS);}
-^{ws}*objpad		{return (OBJPAD);}
-^{ws}*pltskip		{return (PLTSKIP);}
-^{ws}*print		{return (PRINT);}
-^{ws}*step		{return (STEP);}
-^{ws}*value		{return (VALUE);}
-^{ws}*where		{return (WHERE);}
-{symbol}		{yylval.str = strdup(yytext); return (SYMBOL);}
-{varstring}		{
-				yylval.str = strdup(yytext + 1);
-				return (VARSTRING);
-			}
-{qstring}		{
-				yylval.str = strdup(yytext + 1);
-				if (yylval.str[yyleng - 2] == '"')
-					yylval.str[yyleng - 2] = '\0';
-				return (QSTRING);
-			}
-{nl}			{return (NEWLINE);}
-%%
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/main.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-/*
- * 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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/fault.h>
-#include <sys/syscall.h>
-#include <procfs.h>
-#include <sys/auxv.h>
-#include <libelf.h>
-#include <sys/param.h>
-#include <stdarg.h>
-
-#include <proc_service.h>
-
-#include "rdb.h"
-#include "disasm.h"
-#include "gram.h"
-
-static void
-init_proc()
-{
-	int		pfd;
-	pid_t		pid;
-	char		procname[MAXPATHLEN];
-	sigset_t	sigset;
-	fltset_t	fltset;
-	sysset_t	sysset;
-	long		oper, pflags;
-	struct iovec	piov[2];
-
-	/*
-	 * open our own /proc file and set tracing flags
-	 */
-	pid = getpid();
-	(void) sprintf(procname, "/proc/%d/ctl", pid);
-	if ((pfd = open(procname, O_WRONLY)) < 0) {
-		(void) fprintf(stderr, "can't open %s\n", procname);
-		exit(1);
-	}
-
-	/*
-	 * inherit on fork, and kill-on-last-close
-	 */
-	oper = PCSET;
-	piov[0].iov_base = (caddr_t)(&oper);
-	piov[0].iov_len = sizeof (oper);
-	pflags = PR_FORK;
-	piov[1].iov_base = (caddr_t)&pflags;
-	piov[1].iov_len = sizeof (pflags);
-
-	if (writev(pfd, piov, 2) == -1)
-		perr("init_proc: PCSET");
-
-	/*
-	 * no signal tracing
-	 */
-	oper = PCSTRACE;
-	premptyset(&sigset);
-	piov[1].iov_base = (caddr_t)&sigset;
-	piov[1].iov_len = sizeof (sigset);
-	if (writev(pfd, piov, 2) == -1)
-		perr("PCSTRACE");
-
-	/*
-	 * no fault tracing
-	 */
-	oper = PCSFAULT;
-	premptyset(&fltset);
-	piov[1].iov_base = (caddr_t)&fltset;
-	piov[1].iov_len = sizeof (fltset);
-	if (writev(pfd, piov, 2) == -1)
-		perr("PCSFAULT");
-
-	/*
-	 * no syscall tracing
-	 */
-	oper = PCSENTRY;
-	premptyset(&sysset);
-	piov[1].iov_base = (caddr_t)&sysset;
-	piov[1].iov_len = sizeof (sysset);
-	if (writev(pfd, piov, 2) == -1)
-		perr("PSENTRY");
-
-	/*
-	 * except exit from exec() or execve()
-	 */
-	oper = PCSEXIT;
-	premptyset(&sysset);
-	praddset(&sysset, SYS_execve);
-	if (writev(pfd, piov, 2) == -1)
-		perr("PCSEXIT");
-
-	(void) close(pfd);
-}
-
-int
-main(int argc, char *argv[])
-{
-	int			pctlfd;
-	int			pstatusfd;
-	char			procname[MAXPATHLEN];
-	char			*command;
-	char			*rdb_commands = NULL;
-	pid_t			cpid;
-	pstatus_t		pstatus;
-	sysset_t		sysset;
-	int			c;
-	int			error = 0;
-	long			oper;
-	struct iovec		piov[2];
-	extern FILE		*yyin;
-
-	command = argv[0];
-
-	while ((c = getopt(argc, argv, "f:")) != EOF)
-		switch (c) {
-		case 'f':
-			rdb_commands = optarg;
-			break;
-		case '?':
-			break;
-		}
-
-	if (error || (optind == argc)) {
-		(void) printf("usage: %s [-f file] executable "
-		    "[executable arguments ...]\n", command);
-		(void) printf("\t-f	command file\n");
-		exit(1);
-	}
-
-	/*
-	 * set up for tracing the child.
-	 */
-	init_proc();
-
-	/*
-	 * create a child to fork and exec from.
-	 */
-	if ((cpid = fork()) == 0) {
-		(void) execv(argv[optind], &argv[optind]);
-		perr(argv[1]);
-	}
-
-	if (cpid == -1)	/* fork() failure */
-		perr(command);
-
-	/*
-	 * initialize libelf
-	 */
-	if (elf_version(EV_CURRENT) == EV_NONE) {
-		(void) fprintf(stderr, "elf_version() failed: %s\n",
-		    elf_errmsg(0));
-		exit(1);
-	}
-
-	/*
-	 * initialize librtld_db
-	 */
-	if (rd_init(RD_VERSION) != RD_OK) {
-		(void) fprintf(stderr, "librtld_db::rd_init() failed: version "
-		    "submitted: %d\n", RD_VERSION);
-		exit(1);
-	}
-
-	/* rd_log(1); */
-
-	/*
-	 * Child should now be waiting after the successful
-	 * exec.
-	 */
-	(void) sprintf(procname, "/proc/%d/ctl", cpid);
-	(void) printf("parent: %d child: %d child procname: %s\n", getpid(),
-	    cpid, procname);
-	if ((pctlfd = open(procname, O_WRONLY)) < 0) {
-		perror(procname);
-		(void) fprintf(stderr, "%s: can't open child %s\n",
-		    command, procname);
-		exit(1);
-	}
-
-	/*
-	 * wait for child process.
-	 */
-	oper = PCWSTOP;
-	piov[0].iov_base = (caddr_t)&oper;
-	piov[0].iov_len = sizeof (oper);
-	if (writev(pctlfd, piov, 1) == -1)
-		perr("PCWSTOP");
-
-	/*
-	 * open /proc/<cpid>/status
-	 */
-	(void) sprintf(procname, "/proc/%d/status", cpid);
-	if ((pstatusfd = open(procname, O_RDONLY)) == -1)
-		perr(procname);
-
-	if (read(pstatusfd, &pstatus, sizeof (pstatus)) == -1)
-		perr("status read failed");
-
-	/*
-	 * Make sure that it stopped where we expected.
-	 */
-	while ((pstatus.pr_lwp.pr_why == PR_SYSEXIT) &&
-	    (pstatus.pr_lwp.pr_what == SYS_execve)) {
-		long	pflags = 0;
-		if (!(pstatus.pr_lwp.pr_reg[R_PS] & ERRBIT)) {
-			/* successfull exec(2) */
-			break;
-		}
-
-		oper = PCRUN;
-		piov[1].iov_base = (caddr_t)&pflags;
-		piov[1].iov_len = sizeof (pflags);
-		if (writev(pctlfd, piov, 2) == -1)
-			perr("PCRUN1");
-
-		oper = PCWSTOP;
-		if (writev(pctlfd, piov, 1) == -1)
-			perr("PCWSTOP");
-
-		if (read(pstatusfd, &pstatus, sizeof (pstatus)) == -1)
-			perr("status read failed");
-	}
-
-	premptyset(&sysset);
-	oper = PCSEXIT;
-	piov[1].iov_base = (caddr_t)&sysset;
-	piov[1].iov_len = sizeof (sysset);
-	if (writev(pctlfd, piov, 2) == -1)
-		perr("PIOCSEXIT");
-
-	/*
-	 * Did we stop where we expected ?
-	 */
-	if ((pstatus.pr_lwp.pr_why != PR_SYSEXIT) ||
-	    (pstatus.pr_lwp.pr_what != SYS_execve)) {
-		long	pflags = 0;
-
-		(void) fprintf(stderr, "Didn't catch the exec, why: %d "
-		    "what: %d\n", pstatus.pr_lwp.pr_why,
-		    pstatus.pr_lwp.pr_what);
-
-		oper = PCRUN;
-		piov[1].iov_base = (caddr_t)&pflags;
-		piov[1].iov_len = sizeof (pflags);
-		if (writev(pctlfd, piov, 2) == -1)
-			perr("PCRUN2");
-		exit(1);
-	}
-
-	(void) ps_init(pctlfd, pstatusfd, cpid, &proch);
-
-	if (rdb_commands) {
-		if ((yyin = fopen(rdb_commands, "r")) == NULL) {
-			(void) printf("unable to open %s for input\n",
-			    rdb_commands);
-			perr("fopen");
-		}
-	} else {
-		proch.pp_flags |= FLG_PP_PROMPT;
-		rdb_prompt();
-	}
-	yyparse();
-
-	if (proch.pp_flags & FLG_PP_PACT) {
-		long	pflags = PRCFAULT;
-
-		(void) printf("\ncontinuing the hung process...\n");
-
-		pctlfd = proch.pp_ctlfd;
-		(void) ps_close(&proch);
-
-		oper = PCRUN;
-		piov[1].iov_base = (caddr_t)&pflags;
-		piov[1].iov_len = sizeof (pflags);
-		if (writev(pctlfd, piov, 2) == -1)
-			perr("PCRUN2");
-		(void) close(pctlfd);
-	}
-
-	return (0);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/maps.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,457 +0,0 @@
-/*
- * 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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/fault.h>
-#include <sys/syscall.h>
-#include <procfs.h>
-#include <sys/auxv.h>
-#include <libelf.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <link.h>
-#include <sys/param.h>
-#include <stdarg.h>
-
-#include "rdb.h"
-
-static char *
-conv_lmid(Lmid_t ident, char *buf, size_t len)
-{
-	if (len < 17)
-		return (NULL);
-	if (ident == LM_ID_BASE)
-		return (strncpy(buf, "  BASE  ", len));
-
-	if (ident == LM_ID_LDSO)
-		return (strncpy(buf, "  LDSO  ", len));
-
-	(void) sprintf(buf, "0x%llx", (unsigned long long)ident);
-	return (buf);
-}
-
-map_info_t *
-str_to_map(struct ps_prochandle *ph, const char *soname)
-{
-	map_info_t *mip;
-
-	if (soname == PS_OBJ_LDSO)
-		mip = (map_info_t *)&(ph->pp_ldsomap);
-	else if (soname == PS_OBJ_EXEC)
-		mip = (map_info_t *)&(ph->pp_execmap);
-	else {
-		for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next)
-			if (strcmp(soname, mip->mi_name) == 0)
-				break;
-	}
-	return (mip);
-}
-
-map_info_t *
-addr_to_map(struct ps_prochandle *ph, ulong_t addr)
-{
-	map_info_t *mip;
-	if (ph->pp_lmaplist.ml_head == NULL) {
-		/*
-		 * To early to have the full Link Map info available
-		 * so we use the initial info obtained from procfs
-		 */
-		if ((addr >= ph->pp_ldsomap.mi_addr) &&
-		    (addr <= ph->pp_ldsomap.mi_end))
-			return ((map_info_t *)&(ph->pp_ldsomap));
-
-		if ((addr >= ph->pp_execmap.mi_addr) &&
-		    (addr <= ph->pp_execmap.mi_end))
-			return ((map_info_t *)&(ph->pp_execmap));
-
-		return (NULL);
-	}
-
-	for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next)
-		if ((addr >= mip->mi_addr) &&
-		    (addr <= mip->mi_end))
-			return (mip);
-
-	return (NULL);
-}
-
-retc_t
-display_linkmaps(struct ps_prochandle *ph)
-{
-	char	flagstr[1024];
-	map_info_t *mip;
-
-	if (ph->pp_lmaplist.ml_head == NULL) {
-		(void) printf("link-maps not yet available\n");
-		return (RET_FAILED);
-	}
-	(void) printf("Link Maps\n");
-	(void) printf("---------\n");
-	for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next) {
-		char sbuf[32];
-		rd_loadobj_t *lp = &mip->mi_loadobj;
-		(void) printf("link-map: id: %s name: ",
-		    conv_lmid(lp->rl_lmident, sbuf, 32));
-		if (mip->mi_refname)
-			(void) printf("%s(%s)\n", mip->mi_name,
-			    mip->mi_refname);
-		else
-			(void) printf("%s\n", mip->mi_name);
-
-		(void) printf("       base: 0x%08lx   padd_base: 0x%08lx\n",
-		    lp->rl_base, lp->rl_padstart);
-		(void) printf("  data_base: 0x%08llx\n",
-		    (unsigned long long)lp->rl_data_base);
-		(void) printf("        end: 0x%08lx    padd_end: 0x%08lx\n",
-		    lp->rl_bend, lp->rl_padend);
-		flagstr[0] = '\0';
-
-		if (lp->rl_flags & RD_FLG_MEM_OBJECT) {
-			(void) strcat(flagstr, " MEMOBJECT");
-		}
-		(void) printf("    dynamic: 0x%08lx       flags: "
-		    "0x%08x:[%s ]\n", lp->rl_dynamic, lp->rl_flags, flagstr);
-	}
-
-	return (RET_OK);
-}
-
-retc_t
-display_maps(struct ps_prochandle *ph)
-{
-	struct stat	stbuf;
-	void 		*ptr;
-	prmap_t 	*mapptr;
-
-	if (fstat(ph->pp_mapfd, &stbuf) == -1)
-		perr("stat map");
-
-	ptr = malloc(stbuf.st_size);
-	if (pread(ph->pp_mapfd, ptr, stbuf.st_size, 0) == -1)
-		perr("dm: reading map");
-
-	(void) puts("\nMappings");
-	(void) puts("--------");
-	if (ph->pp_dmodel == PR_MODEL_LP64)
-		(void) puts("addr               size     prot ident name");
-	else
-		(void) puts("addr       size     prot ident name");
-
-	for (mapptr = (prmap_t *)ptr;
-	    (uintptr_t)mapptr < ((uintptr_t)ptr + stbuf.st_size);
-	    mapptr++) {
-		map_info_t *mip;
-
-		if (ph->pp_dmodel == PR_MODEL_LP64)
-			(void) printf("%#18lx %#08lx %#04x", mapptr->pr_vaddr,
-			    mapptr->pr_size, mapptr->pr_mflags);
-		else
-			(void) printf("0x%08lx 0x%06lx 0x%02x",
-			    mapptr->pr_vaddr, mapptr->pr_size,
-			    mapptr->pr_mflags);
-
-		if ((mip = addr_to_map(ph,
-		    (ulong_t)(mapptr->pr_vaddr))) != NULL) {
-			if (mip->mi_refname) {
-				(void) printf(" 0x%02lx  %s(%s)",
-				    mip->mi_lmident, mip->mi_name,
-				    mip->mi_refname);
-			} else
-				(void) printf(" 0x%02lx  %s", mip->mi_lmident,
-				    mip->mi_name);
-		}
-		(void) putchar('\n');
-	}
-	(void) putchar('\n');
-
-	free(ptr);
-	return (RET_OK);
-}
-
-retc_t
-load_map(struct ps_prochandle *procp, caddr_t baddr, map_info_t *mp)
-{
-	Elf 		*elf;
-	GElf_Ehdr 	ehdr;
-	GElf_Phdr	phdr;
-	Elf_Scn 	*scn = NULL;
-	int		cnt;
-	prmap_t 	*mapptr;
-	void 		*ptr;
-	struct stat	stbuf;
-	int		filefd = -1;
-
-	if (fstat(procp->pp_mapfd, &stbuf) == -1)
-		perr("stat map");
-
-	ptr = malloc(stbuf.st_size);
-	if (pread(procp->pp_mapfd, ptr, stbuf.st_size, 0) == -1)
-		perr("dm: reading map");
-
-	for (mapptr = (prmap_t *)ptr;
-	    (uintptr_t)mapptr < ((uintptr_t)ptr + stbuf.st_size);
-	    mapptr++) {
-
-		if ((mapptr->pr_vaddr <= (uintptr_t)baddr) &&
-		    ((mapptr->pr_vaddr + mapptr->pr_size) >
-		    (uintptr_t)baddr)) {
-			if (mapptr->pr_mapname[0]) {
-				char	procname[MAXPATHLEN];
-
-				(void) snprintf(procname, MAXPATHLEN - 1,
-				    "/proc/%d/object/%s", procp->pp_pid,
-				    mapptr->pr_mapname);
-				filefd = open(procname, O_RDONLY);
-			}
-			break;
-		}
-	}
-	free(ptr);
-
-	if (filefd == -1) {
-		(void) fprintf(stderr, "unable to find file association to "
-		    "maping address 0x%08lx\n", baddr);
-		return (RET_FAILED);
-	}
-
-	if ((elf = elf_begin(filefd, ELF_C_READ, 0)) == NULL) {
-		(void) fprintf(stderr, "elf_begin(): %s\n", elf_errmsg(-1));
-		return (RET_FAILED);
-	}
-
-	if (elf_kind(elf) != ELF_K_ELF) {
-		(void) printf("non-elf file\n");
-		(void) elf_end(elf);
-		return (RET_FAILED);
-	}
-
-	mp->mi_elf = elf;
-	mp->mi_flags = 0;
-	mp->mi_mapfd = filefd;
-
-	if (gelf_getehdr(mp->mi_elf, &ehdr) == NULL) {
-		(void) printf("gelf_getehdr(): %s\n", elf_errmsg(-1));
-		(void) elf_end(mp->mi_elf);
-		return (RET_FAILED);
-	}
-	mp->mi_ehdr = ehdr;
-	if (ehdr.e_type == ET_EXEC)
-		mp->mi_flags |= FLG_MI_EXEC;
-
-	mp->mi_end = 0;
-#if	defined(_ELF64)
-	mp->mi_addr = (ulong_t)0xffffffffffffffff;
-#else
-	mp->mi_addr = (ulong_t)0xffffffff;
-#endif
-	for (cnt = 0; cnt < (int)(ehdr.e_phnum); cnt++) {
-		if (gelf_getphdr(mp->mi_elf, cnt, &phdr) == NULL) {
-			(void) printf("gelf_getphdr(): %s\n", elf_errmsg(-1));
-			(void) elf_end(mp->mi_elf);
-			return (RET_FAILED);
-		}
-
-		if (phdr.p_type == PT_LOAD) {
-			if (mp->mi_end < (ulong_t)(phdr.p_vaddr +
-			    phdr.p_memsz))
-				mp->mi_end = (ulong_t)(phdr.p_vaddr +
-				    phdr.p_memsz);
-			if (mp->mi_addr > phdr.p_vaddr)
-				mp->mi_addr = phdr.p_vaddr;
-		}
-	}
-
-	mp->mi_pltbase = 0;
-	mp->mi_pltsize = 0;
-	mp->mi_pltentsz = 0;
-	mp->mi_dynsym.st_symn = 0;
-	while ((scn = elf_nextscn(mp->mi_elf, scn)) != NULL) {
-		GElf_Shdr 	shdr;
-		Elf_Data	*dp;
-		Elf_Scn		*tscn = NULL;
-
-		if (gelf_getshdr(scn, &shdr) == NULL) {
-			(void) printf("gelf_getshdr(): %s\n", elf_errmsg(-1));
-			(void) elf_end(mp->mi_elf);
-			return (RET_FAILED);
-		}
-
-		switch (shdr.sh_type) {
-		case SHT_DYNSYM:
-			dp = elf_getdata(scn, 0);
-			mp->mi_dynsym.st_syms_pri = dp;
-			tscn = elf_getscn(mp->mi_elf, shdr.sh_link);
-			mp->mi_dynsym.st_symn +=
-			    shdr.sh_size / shdr.sh_entsize;
-			dp = elf_getdata(tscn, 0);
-			mp->mi_dynsym.st_strs = (char *)dp->d_buf;
-			break;
-		case SHT_SUNW_LDYNSYM:
-			dp = elf_getdata(scn, 0);
-			mp->mi_dynsym.st_syms_aux = dp;
-			mp->mi_dynsym.st_symn_aux =
-			    shdr.sh_size / shdr.sh_entsize;
-			mp->mi_dynsym.st_symn += mp->mi_dynsym.st_symn_aux;
-			break;
-		case SHT_SYMTAB:
-			dp = elf_getdata(scn, 0);
-			mp->mi_symtab.st_syms_pri = dp;
-			tscn = elf_getscn(mp->mi_elf, shdr.sh_link);
-			mp->mi_symtab.st_symn =
-			    shdr.sh_size / shdr.sh_entsize;
-			dp = elf_getdata(tscn, 0);
-			mp->mi_symtab.st_strs = (char *)dp->d_buf;
-			break;
-		case PLTSECTT:
-			if (strcmp(PLTSECT, elf_strptr(mp->mi_elf,
-			    ehdr.e_shstrndx, shdr.sh_name)) == 0) {
-				mp->mi_pltbase = shdr.sh_addr;
-				mp->mi_pltsize = shdr.sh_size;
-				/* LINTED */
-				mp->mi_pltentsz = (unsigned)shdr.sh_entsize;
-			}
-			break;
-		default:
-			/* nothing */
-			break;
-		}
-	}
-	return (RET_OK);
-}
-
-static int
-map_iter(const rd_loadobj_t *lop, void *cd)
-{
-	struct ps_prochandle 	*ph = (struct ps_prochandle *)cd;
-	map_info_t 		*mip;
-	char			buf[MAXPATHLEN];
-
-	if ((mip = (map_info_t *)calloc(1, sizeof (map_info_t))) == NULL) {
-		(void) fprintf(stderr, "map_iter: memory error: allocation "
-		    "failed\n");
-		return (0);
-	}
-
-	mip->mi_loadobj = *lop;
-
-	if (proc_string_read(ph, lop->rl_nameaddr,
-	    buf, MAXPATHLEN) == RET_FAILED) {
-		(void) fprintf(stderr, "mi: bad object name address "
-		    "passed: 0x%lx\n", lop->rl_nameaddr);
-		free(mip);
-		return (0);
-	}
-	mip->mi_name = strdup(buf);
-
-
-	if (lop->rl_refnameaddr) {
-		if (proc_string_read(ph, lop->rl_refnameaddr, buf,
-		    MAXPATHLEN) == RET_FAILED) {
-			(void) fprintf(stderr, "mi1: bad object name address "
-			    "passed: 0x%lx\n", lop->rl_refnameaddr);
-			free(mip);
-			return (0);
-		}
-		mip->mi_refname = strdup(buf);
-	} else
-		mip->mi_refname = NULL;
-
-	/*
-	 * Relocatable objects are processed to create in-memory shared objects,
-	 * and as such have no file associated with the allocated memory shared
-	 * object.
-	 */
-	if ((lop->rl_flags & RD_FLG_MEM_OBJECT) == 0)
-		(void) load_map(ph, (caddr_t)lop->rl_base, mip);
-	if ((mip->mi_flags & FLG_MI_EXEC) == 0) {
-		mip->mi_end += lop->rl_base;
-		mip->mi_addr += lop->rl_base;
-	}
-	mip->mi_lmident = lop->rl_lmident;
-	mip->mi_next = NULL;
-
-	if (ph->pp_lmaplist.ml_head == 0) {
-		ph->pp_lmaplist.ml_head = ph->pp_lmaplist.ml_tail = mip;
-		return (1);
-	}
-
-	ph->pp_lmaplist.ml_tail->mi_next = mip;
-	ph->pp_lmaplist.ml_tail = mip;
-
-	return (1);
-}
-
-void
-free_linkmaps(struct ps_prochandle *ph)
-{
-	map_info_t *cur, *prev;
-
-	for (cur = ph->pp_lmaplist.ml_head, prev = NULL; cur;
-	    prev = cur, cur = cur->mi_next) {
-		if (prev) {
-			(void) elf_end(prev->mi_elf);
-			(void) close(prev->mi_mapfd);
-			free(prev->mi_name);
-			if (prev->mi_refname)
-				free(prev->mi_refname);
-			free(prev);
-		}
-	}
-	if (prev) {
-		(void) elf_end(prev->mi_elf);
-		(void) close(prev->mi_mapfd);
-		free(prev->mi_name);
-		if (prev->mi_refname)
-			free(prev->mi_refname);
-		free(prev);
-	}
-	ph->pp_lmaplist.ml_head = ph->pp_lmaplist.ml_tail = NULL;
-}
-
-retc_t
-get_linkmaps(struct ps_prochandle *ph)
-{
-	free_linkmaps(ph);
-	rd_loadobj_iter(ph->pp_rap, map_iter, ph);
-	return (RET_OK);
-}
-
-retc_t
-set_objpad(struct ps_prochandle *ph, size_t padsize)
-{
-	if (rd_objpad_enable(ph->pp_rap, padsize) != RD_OK) {
-		(void) printf("rdb: error setting object padding\n");
-		return (RET_FAILED);
-	}
-	return (RET_OK);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/ps.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,378 +0,0 @@
-/*
- * 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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2006 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/fault.h>
-#include <sys/syscall.h>
-#include <procfs.h>
-#include <sys/auxv.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <libelf.h>
-#include <sys/param.h>
-#include <stdarg.h>
-
-#include <proc_service.h>
-
-#include "rdb.h"
-#include "disasm.h"
-
-
-#if	!defined(_LP64)
-static void
-gelf_sym_to_elf32(GElf_Sym *src, Elf32_Sym *dst)
-{
-	dst->st_name	= src->st_name;
-	/* LINTED */
-	dst->st_value	= (Elf32_Addr)src->st_value;
-	/* LINTED */
-	dst->st_size	= (Elf32_Word)src->st_size;
-	dst->st_info	= ELF32_ST_INFO(GELF_ST_BIND(src->st_info),
-				GELF_ST_TYPE(src->st_info));
-	dst->st_other	= src->st_other;
-	dst->st_shndx	= src->st_shndx;
-}
-#endif
-
-static void
-get_ldbase(struct ps_prochandle *procp)
-{
-	int		pauxvfd;
-	char		pname[MAXPATHLEN];
-	struct stat	stbuf;
-	void		*auxvptr, *auxvtail;
-	auxv_t		*auxvp;
-	uint_t		entsize;
-
-	(void) snprintf(pname, MAXPATHLEN, "/proc/%d/auxv", procp->pp_pid);
-	if ((pauxvfd = open(pname, O_RDONLY)) == -1)
-		perr("open auxv");
-
-	if (fstat(pauxvfd, &stbuf) == -1)
-		perr("stat auxv");
-
-	auxvptr = malloc(stbuf.st_size);
-	if (read(pauxvfd, auxvptr, stbuf.st_size) == -1)
-		perr("gldb: reading auxv");
-
-	close(pauxvfd);
-
-	procp->pp_auxvp = auxvptr;
-	auxvtail = (void *)((uintptr_t)auxvptr + stbuf.st_size);
-
-#if defined(_LP64)
-	if (procp->pp_dmodel == PR_MODEL_ILP32)
-		entsize = sizeof (auxv32_t);
-	else
-#endif
-		entsize = sizeof (auxv_t);
-
-	while (auxvptr < auxvtail) {
-		auxvp = auxvptr;
-		if (auxvp->a_type == AT_BASE) {
-#if defined(_LP64)
-			if (procp->pp_dmodel == PR_MODEL_ILP32)
-				procp->pp_ldsobase =
-				    ((uintptr_t)((auxv32_t *)auxvp)->
-				    a_un.a_val);
-			else
-#endif
-				procp->pp_ldsobase =  auxvp->a_un.a_val;
-		} else if (auxvp->a_type == AT_PHDR) {
-#if defined(_LP64)
-			if (procp->pp_dmodel == PR_MODEL_ILP32)
-				procp->pp_execphdr =
-				    ((uintptr_t)((auxv32_t *)auxvp)->
-				    a_un.a_val);
-			else
-#endif
-				procp->pp_execphdr =  auxvp->a_un.a_val;
-		}
-		auxvptr = (void *)((uintptr_t)auxvptr + entsize);
-	}
-}
-
-retc_t
-ps_init(int pctlfd, int pstatusfd, pid_t pid, struct ps_prochandle *procp)
-{
-	rd_notify_t	rd_notify;
-	char		procname[MAXPATHLEN];
-	long		oper;
-	long		pflags;
-	struct iovec	piov[2];
-
-	procp->pp_pid = pid;
-	procp->pp_ctlfd = pctlfd;
-	procp->pp_statusfd = pstatusfd;
-
-	(void) sprintf(procname, "/proc/%d/map", procp->pp_pid);
-	if ((procp->pp_mapfd = open(procname, O_RDONLY)) == -1)
-		perr("psi: open of /proc/dpid/map failed");
-
-	(void) sprintf(procname, "/proc/%d/as", procp->pp_pid);
-	if ((procp->pp_asfd = open(procname, O_RDWR)) == -1)
-		perr("psi: open of /proc/dpid/as failed");
-
-	if (ps_pdmodel(procp, &procp->pp_dmodel) != PS_OK)
-		perr("psi: data model");
-
-#if	!defined(_LP64)
-	if (procp->pp_dmodel == PR_MODEL_LP64)
-		perr("psi:  run 64-bit rdb to debug a 64-bit process");
-#endif
-
-	get_ldbase(procp);
-
-	load_map(procp, (caddr_t)procp->pp_ldsobase, &(procp->pp_ldsomap));
-	procp->pp_ldsomap.mi_addr += procp->pp_ldsobase;
-	procp->pp_ldsomap.mi_end += procp->pp_ldsobase;
-	procp->pp_ldsomap.mi_name = "<procfs: interp>";
-
-	load_map(procp, (caddr_t)procp->pp_execphdr, &(procp->pp_execmap));
-	procp->pp_execmap.mi_name = "<procfs: exec>";
-
-	procp->pp_breakpoints = 0;
-	procp->pp_flags = FLG_PP_PACT | FLG_PP_PLTSKIP;
-	procp->pp_lmaplist.ml_head = 0;
-	procp->pp_lmaplist.ml_tail = 0;
-	if ((procp->pp_rap = rd_new(procp)) == 0) {
-		fprintf(stderr, "rdb: rtld_db: rd_new() call failed\n");
-		exit(1);
-	}
-	rd_event_enable(procp->pp_rap, 1);
-
-	/*
-	 * For those architectures that increment the PC on
-	 * a breakpoint fault we enable the PR_BPTADJ adjustments.
-	 */
-	oper = PCSET;
-	pflags = PR_BPTADJ;
-	piov[0].iov_base = (caddr_t)(&oper);
-	piov[0].iov_len = sizeof (oper);
-	piov[1].iov_base = (caddr_t)(&pflags);
-	piov[1].iov_len = sizeof (pflags);
-	if (writev(procp->pp_ctlfd, piov, 2) == -1)
-		perr("psinit: PCSET(PR_BTPADJ)");
-
-
-	/*
-	 * Set breakpoints for special handshakes between librtld_db.so
-	 * and the debugger.  These include:
-	 *	PREINIT		- before .init processing.
-	 *	POSTINIT	- after .init processing
-	 *	DLACTIVITY	- link_maps status has changed
-	 */
-	if (rd_event_addr(procp->pp_rap, RD_PREINIT, &rd_notify) == RD_OK) {
-		if (set_breakpoint(procp, rd_notify.u.bptaddr,
-		    FLG_BP_RDPREINIT) != RET_OK)
-			fprintf(stderr,
-				"psi: failed to set BP for preinit at: 0x%lx\n",
-				rd_notify.u.bptaddr);
-	} else
-		fprintf(stderr, "psi: no event registered for preinit\n");
-
-	if (rd_event_addr(procp->pp_rap, RD_POSTINIT, &rd_notify) == RD_OK) {
-		if (set_breakpoint(procp, rd_notify.u.bptaddr,
-		    FLG_BP_RDPOSTINIT) != RET_OK)
-			fprintf(stderr,
-			    "psi: failed to set BP for postinit at: 0x%lx\n",
-			    rd_notify.u.bptaddr);
-	} else
-		fprintf(stderr, "psi: no event registered for postinit\n");
-
-	if (rd_event_addr(procp->pp_rap, RD_DLACTIVITY, &rd_notify) == RD_OK) {
-		if (set_breakpoint(procp, rd_notify.u.bptaddr,
-		    FLG_BP_RDDLACT) != RET_OK)
-			fprintf(stderr,
-				"psi: failed to set BP for dlact at: 0x%lx\n",
-				rd_notify.u.bptaddr);
-	} else
-		fprintf(stderr, "psi: no event registered for dlact\n");
-
-	return (RET_OK);
-}
-
-
-retc_t
-ps_close(struct ps_prochandle *ph)
-{
-	delete_all_breakpoints(ph);
-	if (ph->pp_auxvp)
-		free(ph->pp_auxvp);
-	free_linkmaps(ph);
-	return (RET_OK);
-}
-
-
-ps_err_e
-ps_pauxv(struct ps_prochandle *ph, const auxv_t **auxvp)
-{
-	*auxvp = ph->pp_auxvp;
-	return (PS_OK);
-}
-
-
-ps_err_e
-ps_pdmodel(struct ps_prochandle *ph, int *dm)
-{
-	pstatus_t	pstatus;
-
-	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), 0) == -1)
-		return (PS_ERR);
-
-	*dm = (int)pstatus.pr_dmodel;
-	return (PS_OK);
-}
-
-
-ps_err_e
-ps_pread(struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t size)
-{
-	/* LINTED */
-	if (pread(ph->pp_asfd, buf, size, (off_t)addr) != size)
-		return (PS_ERR);
-
-	return (PS_OK);
-}
-
-
-ps_err_e
-ps_pwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf, size_t size)
-{
-	/* LINTED */
-	if (pwrite(ph->pp_asfd, buf, size, (off_t)addr) != size)
-		return (PS_ERR);
-
-	return (PS_OK);
-}
-
-
-ps_err_e
-ps_pglobal_sym(struct ps_prochandle *ph, const char *object_name,
-    const char *sym_name, ps_sym_t *symp)
-{
-	map_info_t	*mip;
-	GElf_Sym	gsym;
-
-	if ((mip = str_to_map(ph, object_name)) == 0)
-		return (PS_ERR);
-
-	if (str_map_sym(sym_name, mip, &gsym, NULL) == RET_FAILED)
-		return (PS_ERR);
-
-#if	defined(_LP64)
-	*symp = gsym;
-#else
-	gelf_sym_to_elf32(&gsym, (Elf32_Sym *)symp);
-#endif
-
-	return (PS_OK);
-}
-
-
-ps_err_e
-ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
-    const char *sym_name, ulong_t *sym_addr)
-{
-	GElf_Sym	sym;
-	map_info_t	*mip;
-
-	if ((mip = str_to_map(ph, object_name)) == 0)
-		return (PS_ERR);
-
-	if (str_map_sym(sym_name, mip, &sym, NULL) == RET_FAILED)
-		return (PS_ERR);
-
-	*sym_addr = sym.st_value;
-
-	return (PS_OK);
-}
-
-
-ps_err_e
-ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset)
-{
-	char		procname[MAXPATHLEN];
-	int		lwpfd;
-	lwpstatus_t	lwpstatus;
-
-	(void) snprintf(procname, MAXPATHLEN - 1,
-		"/proc/%d/lwp/%d/lwpstatus", ph->pp_pid, lid);
-
-	if ((lwpfd = open(procname, O_RDONLY)) == -1)
-		return (PS_ERR);
-
-	if (read(lwpfd, &lwpstatus, sizeof (lwpstatus)) == -1)
-		return (PS_ERR);
-
-	gregset = lwpstatus.pr_reg;
-
-	close(lwpfd);
-	return (PS_OK);
-}
-
-
-void
-ps_plog(const char *fmt, ...)
-{
-	va_list		args;
-	static FILE	*log_fp = 0;
-
-	if (log_fp == 0) {
-		char		log_fname[256];
-		(void) sprintf(log_fname, "/tmp/tdlog.%d", getpid());
-		if ((log_fp = fopen(log_fname, "w")) == 0) {
-			/*
-			 * unable to open log file - default to
-			 * stderr.
-			 */
-			fprintf(stderr, "unable to open %s, logging "
-				"redirected to stderr", log_fname);
-			log_fp = stderr;
-		}
-	}
-
-	va_start(args, fmt);
-	vfprintf(log_fp, fmt, args);
-	va_end(args);
-	fputc('\n', log_fp);
-	fflush(log_fp);
-}
-
-ps_err_e
-ps_pbrandname(struct ps_prochandle *P, char *buf, size_t len)
-{
-	return (PS_ERR);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/rdb.h	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,270 +0,0 @@
-/*
- * 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
- * or http://www.opensolaris.org/os/licensing.
- * 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.
- */
-
-#ifndef _RDB_H
-#define	_RDB_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <rtld_db.h>
-#include <sys/types.h>
-#include <procfs.h>
-#include <proc_service.h>
-#include <libelf.h>
-#include <gelf.h>
-
-#include <rdb_mach.h>
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-
-
-/*
- * Definitions from 2.7 sys/procfs_isa.h.
- */
-#ifndef	PR_MODEL_LP64
-#define	PR_MODEL_UNKNOWN 0
-#define	PR_MODEL_ILP32	1	/* process data model is ILP32 */
-#define	PR_MODEL_LP64	2	/* process data model is LP64 */
-#endif
-
-#define	INTERPSECT	".interp"
-#define	PLTSECT		".plt"
-
-
-/*
- * Flags for step_n routine
- */
-typedef enum {
-	FLG_SN_NONE = 0,
-	FLG_SN_VERBOSE = (1 << 0),	/* dissamble instructions */
-	FLG_SN_PLTSKIP = (1 << 1)	/* step *over* PLTS */
-} sn_flags_e;
-
-
-typedef	enum {
-	RET_FAILED = -1,
-	RET_OK = 0
-} retc_t;
-
-/*
- * sym_tbl_t contains a primary and an (optional) auxiliary symbol table, which
- * we wish to treat as a single logical symbol table. In this logical table,
- * the data from the auxiliary table preceeds that from the primary. Symbol
- * indices start at [0], which is the first item in the auxiliary table
- * if there is one. The sole purpose for this is so that we can treat the
- * combination of .SUNW_ldynsym and .dynsym sections as a logically single
- * entity without having to violate the public interface to libelf.
- *
- * Both tables must share the same string table section.
- *
- * The symtab_getsym() function serves as a gelf_getsym() replacement
- * that is aware of the two tables and makes them look like a single table
- * to the caller.
- *
- */
-typedef struct sym_tbl {
-	Elf_Data *	st_syms_pri;	/* start of primary table */
-	Elf_Data *	st_syms_aux;	/* start of auxiliary table */
-	char		*st_strs;	/* ptr to strings */
-	size_t		st_symn;	/* Total # of entries in both tables */
-	size_t		st_symn_aux;	/* # of entries in auxiliary table */
-} sym_tbl_t;
-
-
-typedef struct	map_info {
-	char			*mi_name;	/* file info */
-	char			*mi_refname;	/* filter reference name */
-	ulong_t			mi_addr;	/* start address */
-	ulong_t			mi_end;		/* end address */
-	int			mi_mapfd;	/* file desc. for mapping */
-	unsigned		mi_pltentsz;	/* size of PLT entries */
-	Elf			*mi_elf;	/* elf handle so we can close */
-	GElf_Ehdr		mi_ehdr;
-	sym_tbl_t		mi_symtab;	/* symbol table */
-	sym_tbl_t		mi_dynsym;	/* dynamic symbol table */
-	Lmid_t			mi_lmident;	/* Link Map Ident */
-	ulong_t			mi_pltbase;	/* PLT base address */
-	ulong_t			mi_pltsize;	/* size of PLT table */
-	struct map_info		*mi_next;
-	ulong_t			mi_flags;	/* misc flags */
-	rd_loadobj_t		mi_loadobj;	/* keep the old loadobj for */
-						/* 	good luck */
-} map_info_t;
-
-#define	FLG_MI_EXEC		0x0001		/* is object an EXEC */
-
-#define	FLG_PAP_SONAME		0x0001		/* embed SONAME in sym name */
-#define	FLG_PAP_NOHEXNAME	0x0002		/* if no symbol return */
-						/* null string */
-#define	FLG_PAP_PLTDECOM	0x0004		/* decompe PLT name if */
-						/* possible */
-
-
-typedef struct map_list {
-	map_info_t		*ml_head;
-	map_info_t		*ml_tail;
-} map_list_t;
-
-
-/*
- * Break point information
- */
-typedef struct bpt_struct {
-	ulong_t			bl_addr;	/* address of breakpoint */
-	bptinstr_t 		bl_instr;	/* original instruction */
-	unsigned		bl_flags;	/* break point flags */
-	struct bpt_struct	*bl_next;
-} bptlist_t;
-
-#define	FLG_BP_USERDEF		0x0001		/* user defined BP */
-#define	FLG_BP_RDPREINIT	0x0002		/* PREINIT BreakPoint */
-#define	FLG_BP_RDPOSTINIT	0x0004		/* POSTINIT BreakPoint */
-#define	FLG_BP_RDDLACT		0x0008		/* DLACT BreakPoint */
-#define	FLG_BP_PLTRES		0x0010		/* PLT Resolve BP */
-
-#define	MASK_BP_SPECIAL \
-		(FLG_BP_RDPREINIT | FLG_BP_RDPOSTINIT | FLG_BP_RDDLACT)
-#define	MASK_BP_STOP \
-		(FLG_BP_USERDEF | FLG_BP_PLTRES)
-#define	MASK_BP_ALL \
-		(MASK_BP_SPECIAL | FLG_BP_USERDEF)
-
-/*
- * Proc Services Structure
- */
-
-struct ps_prochandle {
-	pid_t		pp_pid;		/* debug process pid */
-	rd_agent_t	*pp_rap;	/* rtld_db handle */
-	int		pp_ctlfd;	/* open ctl proc fd */
-	int		pp_statusfd;	/* open status proc fd */
-	int		pp_asfd;	/* open as proc fd */
-	int		pp_mapfd;	/* open map proc fd */
-	uintptr_t	pp_ldsobase;	/* ld.so.1 base address */
-	uintptr_t	pp_execphdr;	/* a.out phdr address */
-	map_info_t	pp_ldsomap;	/* ld.so.1 map info */
-	map_info_t	pp_execmap;	/* exec map info */
-	map_list_t	pp_lmaplist;	/* list of link map infos */
-	bptlist_t	*pp_breakpoints; /* break point list */
-	void		*pp_auxvp;	/* pointer to AUX vectors */
-	int		pp_flags;	/* misc flags */
-	int		pp_dmodel;	/* data model */
-};
-
-#define	FLG_PP_PROMPT	0x0001		/* display debugger prompt */
-#define	FLG_PP_LMAPS	0x0002		/* link maps available */
-#define	FLG_PP_PACT	0x0004		/* active process being traced */
-#define	FLG_PP_PLTSKIP	0x0008		/* PLT skipping is active */
-
-
-
-/*
- * Debugging Structure
- */
-
-typedef struct rtld_debug {
-	int		rd_vers;
-	caddr_t		rd_preinit;
-	caddr_t		rd_postinit;
-} rtld_debug_t;
-
-
-
-#define	TRAPBREAK	0x91d02001	/* ta	ST_BREAKPOINT */
-
-
-/*
- * values for rdb_flags
- */
-#define	RDB_FL_EVENTS	0x0001		/* enable printing event information */
-
-/*
- * Globals
- */
-
-extern struct ps_prochandle	proch;
-extern unsigned long		rdb_flags;
-
-/*
- * Functions
- */
-extern map_info_t	*addr_to_map(struct ps_prochandle *, ulong_t);
-extern retc_t		addr_to_sym(struct ps_prochandle *, ulong_t,
-				GElf_Sym *, char **);
-extern void		CallStack(struct ps_prochandle *ph);
-extern unsigned		continue_to_break(struct ps_prochandle *);
-extern retc_t		delete_all_breakpoints(struct ps_prochandle *);
-extern retc_t		delete_breakpoint(struct ps_prochandle *, ulong_t,
-				unsigned);
-extern void		disasm(struct ps_prochandle *, int);
-extern retc_t		disasm_addr(struct ps_prochandle *, ulong_t, int);
-extern retc_t		display_all_regs(struct ps_prochandle *);
-extern retc_t		display_maps(struct ps_prochandle *);
-extern retc_t		display_linkmaps(struct ps_prochandle *);
-extern void		free_linkmaps(struct ps_prochandle *);
-extern bptlist_t	*find_bp(struct ps_prochandle *ph, ulong_t addr);
-extern retc_t		get_linkmaps(struct ps_prochandle *);
-extern ulong_t		hexstr_to_num(const char *);
-extern ulong_t		is_plt(struct ps_prochandle *, ulong_t);
-extern void		list_breakpoints(struct ps_prochandle *);
-extern retc_t		load_map(struct ps_prochandle *, caddr_t,
-				map_info_t *mp);
-extern char		*print_address(unsigned long);
-extern char		*print_address_ps(struct ps_prochandle *,
-				unsigned long, unsigned);
-extern void		print_mem(struct ps_prochandle *, ulong_t, int,
-				char *);
-extern void		print_varstring(struct ps_prochandle *, const char *);
-extern void		print_mach_varstring(struct ps_prochandle *,
-				const char *);
-extern void		rdb_help(const char *);
-extern void		rdb_prompt();
-extern void		perr(char *);
-extern retc_t		proc_string_read(struct ps_prochandle *,
-				ulong_t, char *, int);
-extern retc_t		ps_close(struct ps_prochandle *);
-extern retc_t		ps_init(int, int, pid_t, struct ps_prochandle *);
-extern retc_t		set_breakpoint(struct ps_prochandle *, ulong_t,
-				unsigned);
-extern retc_t		set_objpad(struct ps_prochandle *, size_t);
-extern retc_t		step_n(struct ps_prochandle *, size_t, sn_flags_e);
-extern void		step_to_addr(struct ps_prochandle *, ulong_t);
-extern retc_t		str_map_sym(const char *, map_info_t *, GElf_Sym *,
-				char **);
-extern map_info_t	*str_to_map(struct ps_prochandle *, const char *);
-extern retc_t		str_to_sym(struct ps_prochandle *, const char *,
-				GElf_Sym *);
-extern int		yyparse(void);
-extern void		yyerror(char *);
-extern int		yylex(void);
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _RDB_H */
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/rdb.man	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-.\"
-.\" 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
-.\" or http://www.opensolaris.org/os/licensing.
-.\" 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 2009 Sun Microsystems, Inc.  All rights reserved.
-.\" Use is subject to license terms.
-.\"
-.if n .tr \--
-.TH rdb 1 "24 April 2008"
-.SH NAME
-rdb \- run-time demo debugger
-.SH SYNOPSIS
-.B rdb
-[
-.B -f
-.I file
-]
-executable [executable arguments ...]
-.SH AVAILABILITY
-.LP
-SUNWosdem
-.SH DESCRIPTION
-.B rdb
-is a simple general purpose debugger built on top of 
-.I procfs
-and
-.I librtld_db.
-.B rdb
-is distributed is source code format and is a sample
-of how to use the
-.I rtld_db
-interface and is not meant to be used in a production environment. 
-.LP
-Each invocation of
-.B rdb
-will debug a single process.  In order to start debugging the process
-again from the beginning
-.B rdb
-must be reinvoked.
-.SH OPTIONS
-.TP 15
-.BI \-f " file"
-file containing a list of commands to be executed by rdb.  This option
-can be used to run 
-.B rdb
-in batch mode.
-.SH USAGE
-.B rdb
-by default reads commands from standard input and displays responses on the
-standard output.  
-.B rdb 
-is terminated when it reads an EOF on input.
-The commands that
-.B rdb 
-accepts follow:
-.TP 15
-.BI break " [address]"
-Set a break point at address.  If no address is specified then list
-all currently set breakpoints.
-.TP
-.B cont
-Continue execution of the debugged process.  Note that when rdb
-is first invoked it halts the program before it starts to run.  To
-start executing it you must use cont.
-.TP
-.BI delete " address"
-delete the breakpoint at address.
-.TP
-.BI echo " string"
-Prints a string to standard output.  The string must be surrounded
-by double-quotes("").
-.TP
-.BI event " {on|off}"
-To enable or disable the printing of event information to standard output.
-If enabled then 
-.B rdb
-will monitor
-.I rtld_db
-events and print a message to standard output as they occur.
-.TP
-.B getmaps
-Instructs 
-.B rdb
-to load the current link-maps via the
-.I rtld_db
-interface.  No information is printed.
-.TP
-.B linkmaps
-display current link-map information.
-.TP
-.B maps
-display memory mapping information.
-.TP
-.BI objpad " size"
-Set object padding to
-.I size
-bytes for objects mmap()'ed in by 
-.B ld.so.1.  
-object padding will only effect the loading of new objects,
-those already loaded in memory are not effected.
-.TP
-.B pltskip
-enables and disables the skipping over of procedure linkage table entries
-when stepping through a function call.
-.TP
-.BI print " {address [count [format]]|varname}"
-displays data stored at
-.I address
-or register information.  Type 'help print' from within rdb for more
-details on usage.
-.TP
-.BI step " [count [silent]]"
-single step
-.I count
-instructions.  If count is not given then signle step 1 instruction.  If
-the keyword silent is specified then do not dis-assemble the instructions
-as they are stepped.
-.TP
-.BI value " symbol_name"
-display the value (address) associated with a symbol
-.TP
-.B where
-display a stack trace
-.SH EXAMPLES
-A simple example showing how to load a program, set a break point
-at main, and to then display the link-maps of all objects loaded:
-.LP
-.nf
-.ft 3
-polyslo 310% rdb /usr/bin/ls
-parent: 28300 child: 28301 child procname: /proc/28301
-<rdb> break main
-break point set at: 0x11110
-<rdb> cont
-break point reached at addr: 0x11110
-<rdb> linkmaps
-Link Maps
----------
-link-map: id: 0x0 name: /usr/bin/ls
-       base: 0x00010000   padd_base: 0xeffffa7c
-  data_base: 0x00000000
-        end: 0x00010000    padd_end: 0x00023ad0
-link-map: id: 0x0 name: /usr/lib/libc.so.1(/usr/platform/$PLATFORM/lib/libc_psr.so.1)
-       base: 0xef700000   padd_base: 0xef7f131c
-  data_base: 0x00000000
-        end: 0xef700000    padd_end: 0xef7991cc
-link-map: id: 0x0 name: /usr/lib/libdl.so.1(/usr/lib/ld.so.1)
-       base: 0xef7c0000   padd_base: 0xef7f1478
-  data_base: 0x00000000
-        end: 0xef7c0000    padd_end: 0xef7c0074
-link-map: id: 0x0 name: /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
-       base: 0xef6f0000   padd_base: 0xef7f15bc
-  data_base: 0x00000000
-        end: 0xef6f0000    padd_end: 0xef6f0074
-link-map: id: 0x1 name: /usr/lib/ld.so.1
-       base: 0xef7d0000   padd_base: 0xef7d1375
-  data_base: 0x00000000
-        end: 0xef7d0000    padd_end: 0xef7f01f8
-<rdb> cont 
-Makefile    gram.h      m_utils.c   rdb         regs.c
-gram.c      lex.c       objs        rdb_mach.h
-process terminated.
-<rdb>
-.ft
-.fi
-.SH SEE ALSO
-.BR ld.so.1 (1)
-.br
-.TZ LLM
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/syms.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,243 +0,0 @@
-/*
- * 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
- * or http://www.opensolaris.org/os/licensing.
- * 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 <stdio.h>
-#include <string.h>
-#include <libelf.h>
-#include "rdb.h"
-
-
-/*
- * Given a symbol index, look up the corresponding symbol from the
- * given symbol table.
- *
- * This function allows the caller to treat the symbol table as a single
- * logical entity even though there may be 2 actual ELF symbol tables
- * involved. See the comments in Pcontrol.h for details.
- */
-static GElf_Sym *
-symtab_getsym(sym_tbl_t *symtab, int ndx, GElf_Sym *dst)
-{
-	/* If index is in range of primary symtab, look it up there */
-	if (ndx >= symtab->st_symn_aux) {
-		return (gelf_getsym(symtab->st_syms_pri,
-		    ndx - symtab->st_symn_aux, dst));
-	}
-
-	/* Not in primary: Look it up in the auxiliary symtab */
-	return (gelf_getsym(symtab->st_syms_aux, ndx, dst));
-}
-
-retc_t
-str_map_sym(const char *symname, map_info_t *mp, GElf_Sym *symptr,
-	char **str)
-{
-	sym_tbl_t	*symp;
-	char		*strs;
-	int		i;
-
-	if (mp->mi_symtab.st_syms_pri)
-		symp = &(mp->mi_symtab);
-	else if (mp->mi_dynsym.st_syms_pri)
-		symp = &(mp->mi_dynsym);
-	else
-		return (RET_FAILED);
-
-	strs = symp->st_strs;
-
-	for (i = 0; i < (int)symp->st_symn; i++) {
-		GElf_Sym sym;
-
-		if (symtab_getsym(symp, i, &sym) == 0) {
-			printf("symtab_getsym(): %s\n", elf_errmsg(-1));
-			return (RET_FAILED);
-		}
-
-		if (sym.st_name == 0)
-			continue;
-		if ((sym.st_shndx == SHN_UNDEF) ||
-		    (strcmp(strs + sym.st_name, symname) != 0))
-			continue;
-		*symptr = sym;
-		if (str != NULL)
-			*str = (char *)strs + symptr->st_name;
-		if ((mp->mi_flags & FLG_MI_EXEC) == 0)
-			symptr->st_value += (GElf_Addr)(mp->mi_addr);
-		return (RET_OK);
-	}
-
-	return (RET_FAILED);
-}
-
-/*
- * If two syms are of equal value this routine will
- * favor one over the other based off of it's symbol
- * type.
- */
-static GElf_Sym
-sym_swap(GElf_Sym * s1, GElf_Sym * s2)
-{
-	int	t1 = GELF_ST_TYPE(s1->st_info);
-	int	t2 = GELF_ST_TYPE(s2->st_info);
-
-	if ((t1 == STT_FUNC) || (t2 == STT_FUNC)) {
-		if (t1 == STT_FUNC)
-			return (*s1);
-		return (*s2);
-	}
-
-	if ((t1 == STT_OBJECT) || (t2 == STT_OBJECT)) {
-		if (t1 == STT_OBJECT)
-			return (*s1);
-		return (*s2);
-	}
-
-	if ((t1 == STT_OBJECT) || (t2 == STT_OBJECT)) {
-		if (t1 == STT_OBJECT)
-			return (*s1);
-		return (*s2);
-	}
-	return (*s1);
-}
-
-
-retc_t
-addr_map_sym(map_info_t *mp, ulong_t addr, GElf_Sym *symptr,
-	char **str)
-{
-	sym_tbl_t	*symp;
-	GElf_Sym	sym;
-	GElf_Sym	*symr = 0;
-	GElf_Sym	*lsymr = 0;
-	GElf_Sym	rsym;
-	GElf_Sym	lsym;
-	ulong_t		baseaddr = 0;
-	int		i;
-
-	if ((mp->mi_flags & FLG_MI_EXEC) == 0)
-		baseaddr = (ulong_t)mp->mi_addr;
-
-	if (mp->mi_symtab.st_syms_pri)
-		symp = &(mp->mi_symtab);
-	else if (mp->mi_dynsym.st_syms_pri)
-		symp = &(mp->mi_dynsym);
-	else
-		return (RET_FAILED);
-
-	/*
-	 * normalize address
-	 */
-	addr -= baseaddr;
-	for (i = 0; i < (int)symp->st_symn; i++) {
-		ulong_t	svalue;
-
-		if (symtab_getsym(symp, i, &sym) == 0) {
-			printf("symtab_getsym(): %s\n", elf_errmsg(-1));
-			return (RET_FAILED);
-		}
-		if ((sym.st_name == 0) || (sym.st_shndx == SHN_UNDEF))
-			continue;
-
-		svalue = (ulong_t)sym.st_value;
-
-		if (svalue <= addr) {
-			/*
-			 * track both the best local and best
-			 * global fit for this address.  Later
-			 * we will favor the global over the local
-			 */
-			if ((GELF_ST_BIND(sym.st_info) == STB_LOCAL) &&
-			    ((lsymr == 0) ||
-			    (svalue >= (ulong_t)lsymr->st_value))) {
-				if (lsymr && (lsymr->st_value == svalue))
-					*lsymr = sym_swap(lsymr, &sym);
-				else {
-					lsymr = &lsym;
-					*lsymr = sym;
-				}
-			} else if ((symr == 0) ||
-			    (svalue >= (ulong_t)symr->st_value)) {
-				if (symr && (symr->st_value == svalue))
-					*symr = sym_swap(symr, &sym);
-				else {
-					symr = &rsym;
-					*symr = sym;
-				}
-			}
-		}
-	}
-	if ((symr == 0) && (lsymr == 0))
-		return (RET_FAILED);
-
-	if (lsymr) {
-		/*
-		 * If a possible local symbol was found should
-		 * we use it.
-		 */
-		if (symr && (lsymr->st_value > symr->st_value))
-			symr = lsymr;
-		else if (symr == 0)
-			symr = lsymr;
-	}
-
-	*symptr = *symr;
-	*str = (char *)(symp->st_strs + symptr->st_name);
-	symptr->st_value += baseaddr;
-	return (RET_OK);
-}
-
-
-retc_t
-addr_to_sym(struct ps_prochandle *ph, ulong_t addr,
-	GElf_Sym *symp, char **str)
-{
-	map_info_t	*mip;
-
-	if ((mip = addr_to_map(ph, addr)) == 0)
-		return (RET_FAILED);
-
-	return (addr_map_sym(mip, addr, symp, str));
-}
-
-
-retc_t
-str_to_sym(struct ps_prochandle *ph, const char *name, GElf_Sym *symp)
-{
-	map_info_t	*mip;
-
-	if (ph->pp_lmaplist.ml_head == 0) {
-		if (str_map_sym(name, &(ph->pp_ldsomap), symp, NULL) == RET_OK)
-			return (RET_OK);
-
-		return (str_map_sym(name, &(ph->pp_execmap), symp, NULL));
-	}
-
-	for (mip = ph->pp_lmaplist.ml_head; mip; mip = mip->mi_next)
-		if (str_map_sym(name, mip, symp, NULL) == RET_OK)
-			return (RET_OK);
-
-	return (RET_FAILED);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/common/utils.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2000 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libelf.h>
-#include <sys/param.h>
-
-#include "rdb.h"
-
-
-void
-perr(char * s)
-{
-	perror(s);
-	exit(1);
-}
-
-
-ulong_t
-hexstr_to_num(const char * str)
-{
-	ulong_t		num = 0;
-	size_t		len = strlen(str);
-	size_t		i;
-
-	for (i = 0; i < len; i++)
-		if (str[i] >= '0' && str[i] <= '9')
-			num = num * 16 +((int)str[i] - (int)'0');
-		else if (str[i] >= 'a' && str[i] <= 'f')
-			num = num * 16 +((int)str[i] - (int)'a' + 10);
-		else if (str[i] >= 'A' && str[i] <= 'F')
-			num = num * 16 + ((int)str[i] - (int)'A' + 10);
-	return (num);
-}
-
-
-#define	STBUFSIZ	1024
-retc_t
-proc_string_read(struct ps_prochandle * ph, ulong_t addr,
-	char * buf, int bufsiz)
-{
-	char	intbuf[STBUFSIZ];
-	int	bufind = 0;
-	int	intbufind = STBUFSIZ;
-	ssize_t	bufbytes = 0;
-	int	cont = 1;
-
-	if (lseek(ph->pp_asfd, addr, SEEK_SET) == -1)
-		return (RET_FAILED);
-	while (cont && (bufind < bufsiz)) {
-		if (intbufind >= bufbytes) {
-			if ((bufbytes = read(ph->pp_asfd, intbuf,
-			    STBUFSIZ)) == -1)
-				return (RET_FAILED);
-			intbufind = 0;
-		}
-		buf[bufind] = intbuf[intbufind];
-		if (buf[bufind] == '\0')
-			return (RET_OK);
-		bufind++;
-		intbufind++;
-	}
-	return (RET_FAILED);
-}
-
-
-void
-print_varstring(struct ps_prochandle * ph, const char * varname)
-{
-	printf("print_varstring: %s\n", varname);
-	if (strcmp(varname, "regs") == 0) {
-		(void) display_all_regs(ph);
-		return;
-	}
-	print_mach_varstring(ph, varname);
-}
-
-void
-print_mem(struct ps_prochandle * ph, ulong_t address, int count,
-	char * format)
-{
-	printf("\n%17s:",
-		print_address_ps(ph, address, FLG_PAP_SONAME));
-
-	if ((*format == 'X') || (*format == 'x')) {
-		int	i;
-
-		for (i = 0; i < count; i++) {
-			unsigned long word;
-			if ((i % 4) == 0)
-				printf("\n  0x%08lx: ", address);
-
-			if (ps_pread(ph, address, (char *)&word,
-			    sizeof (unsigned long)) != PS_OK) {
-				printf("\nfailed to read memory at: 0x%lx\n",
-					address);
-				return;
-			}
-			printf("  0x%08lx", word);
-			address += 4;
-		}
-		putchar('\n');
-		return;
-	}
-
-	if (*format == 'b') {
-		int	i;
-
-		for (i = 0; i < count; i++, address ++) {
-			unsigned char	byte;
-			if ((i % 8) == 0)
-				printf("\n 0x%08lx: ", address);
-			if (ps_pread(ph, address, (char *)&byte,
-			    sizeof (unsigned char)) != PS_OK) {
-				fprintf(stderr, "\nfailed to read byte "
-					"at: 0x%lx\n", address);
-				return;
-			}
-			printf("  %02x", (unsigned)byte);
-		}
-		putchar('\n');
-		return;
-	}
-
-	if (*format == 's') {
-		char	buf[MAXPATHLEN];
-		if (proc_string_read(ph, address, buf,
-		    MAXPATHLEN) != RET_OK) {
-			printf("unable to read string at: %s\n", address);
-			return;
-		}
-		printf(" %s\n", buf);
-		return;
-	}
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/i386/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-#
-# 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
-# or http://www.opensolaris.org/os/licensing.
-# 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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include		../Makefile.com
-
-.KEEP_STATE:
-
-all:		$(OBJDIR) .WAIT $(PROG)
-
-test:		$(TESTS)
-
-# DEMO DELETE START
-
-install:	all $(ROOTONLDBINPROG)
-
-lint:		$(LINTOUT)
-
-# DEMO DELETE END
-
-include		../Makefile.targ
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/i386/m_utils.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-
-#include "rdb.h"
-
-/* ARGSUSED 0 */
-void
-print_mach_varstring(struct ps_prochandle * ph, const char * varname)
-{
-	printf("print: unknown variable given ($%s)\n", varname);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/i386/rdb_mach.h	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _RDB_MACH_H
-#define	_RDB_MACH_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/regset.h>
-#include <sys/psw.h>
-
-#define	ERRBIT	PS_C
-#define	R_PS	EFL
-
-
-/*
- * Breakpoint instruction
- */
-typedef	unsigned char	bptinstr_t;
-#define	BPINSTR		0xcc		/* int	3 */
-
-
-/*
- * PLT section type
- */
-#define	PLTSECTT	SHT_PROGBITS
-
-#endif
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/i386/regs.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/regset.h>
-
-#include "rdb.h"
-
-static void
-disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst,
-	char *r1, int ind1, char *r2, int ind2)
-{
-	char	str1[MAXPATHLEN];
-	char	str2[MAXPATHLEN];
-	strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
-		FLG_PAP_NOHEXNAME));
-	strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
-		FLG_PAP_NOHEXNAME));
-
-	printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n",
-		r1, prst->pr_lwp.pr_reg[ind1], str1,
-		r2, prst->pr_lwp.pr_reg[ind2], str2);
-}
-
-
-retc_t
-display_all_regs(struct ps_prochandle *ph)
-{
-	pstatus_t	pstatus;
-	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-	    0) == -1) {
-		perror("dar: reading status");
-		return (RET_FAILED);
-	}
-	printf("registers:\n");
-	disp_reg_line(ph, &pstatus, "gs", GS, "fs", FS);
-	disp_reg_line(ph, &pstatus, "es", ES, "ds", DS);
-	disp_reg_line(ph, &pstatus, "edi", EDI, "esi", ESI);
-	disp_reg_line(ph, &pstatus, "ebp", EBP, "esp", ESP);
-	disp_reg_line(ph, &pstatus, "ebx", EBX, "edx", EDX);
-	disp_reg_line(ph, &pstatus, "ecx", ECX, "eax", EAX);
-	disp_reg_line(ph, &pstatus, "trapno", TRAPNO, "err", ERR);
-	disp_reg_line(ph, &pstatus, "eip", EIP, "cs", CS);
-	disp_reg_line(ph, &pstatus, "efl", EFL, "uesp", UESP);
-	return (RET_OK);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-#
-# 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
-# or http://www.opensolaris.org/os/licensing.
-# 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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include		../Makefile.com
-
-.KEEP_STATE:
-
-all:		$(OBJDIR) .WAIT $(PROG)
-
-test:		$(TESTS)
-
-# DEMO DELETE START
-
-install:	all $(ROOTONLDBINPROG)
-
-lint:		$(LINTOUT)
-
-# DEMO DELETE END
-
-include		../Makefile.targ
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/m_utils.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-
-#include "rdb.h"
-
-
-void
-print_mach_varstring(struct ps_prochandle * ph, const char * varname)
-{
-	if (strcmp(varname, "ins") == 0) {
-		display_in_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "globs") == 0) {
-		display_global_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "outs") == 0) {
-		display_out_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "locs") == 0) {
-		display_local_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "specs") == 0) {
-		display_special_regs(ph, 0);
-		return;
-	}
-	printf("print: unknown variable given ($%s)\n", varname);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/rdb_mach.h	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2000 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-
-#ifndef _RDB_MACH_H
-#define	_RDB_MACH_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/psw.h>
-#include <procfs.h>
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#define	ERRBIT	PSR_C
-
-struct ps_prochandle;
-
-/*
- * BreakPoint instruction
- */
-typedef	unsigned	bptinstr_t;
-
-#define	BPINSTR		0x91d02001	/* ta   ST_BREAKPOINT */
-
-/*
- * PLT section type
- */
-#define	PLTSECTT	SHT_PROGBITS
-
-extern void		display_in_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_local_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_out_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_special_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_global_regs(struct ps_prochandle *,
-				pstatus_t *);
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif /* _RDB_MACH_H */
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparc/regs.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2000 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/param.h>
-
-#include "rdb.h"
-
-
-static void
-disp_reg_line(struct ps_prochandle * ph, pstatus_t * prst,
-	char * r1, int ind1, char * r2, int ind2)
-{
-	char 		str1[MAXPATHLEN];
-	char 		str2[MAXPATHLEN];
-
-	strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
-		FLG_PAP_NOHEXNAME));
-
-	strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
-		FLG_PAP_NOHEXNAME));
-
-	printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n",
-		r1, prst->pr_lwp.pr_reg[ind1], str1,
-		r2, prst->pr_lwp.pr_reg[ind2], str2);
-}
-
-
-void
-display_local_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dlr: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("locals:\n");
-	disp_reg_line(ph, prst, "l0", R_L0, "l4", R_L4);
-	disp_reg_line(ph, prst, "l1", R_L1, "l5", R_L5);
-	disp_reg_line(ph, prst, "l2", R_L2, "l6", R_L6);
-	disp_reg_line(ph, prst, "l3", R_L3, "l7", R_L7);
-}
-
-void
-display_out_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dor: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("outs:\n");
-	disp_reg_line(ph, prst, "o0", R_O0, "o4", R_O4);
-	disp_reg_line(ph, prst, "o1", R_O1, "o5", R_O5);
-	disp_reg_line(ph, prst, "o2", R_O2, "o6(sp)", R_O6);
-	disp_reg_line(ph, prst, "o3", R_O3, "o7", R_O7);
-}
-
-void
-display_special_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dsr: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("specials:\n");
-	disp_reg_line(ph, prst, "psr", R_PSR, "pc", R_PC);
-	disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y);
-	disp_reg_line(ph, prst, "wim", R_WIM, "TBR", R_TBR);
-}
-
-void
-display_global_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dgr: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("globals:\n");
-	disp_reg_line(ph, prst, "g0", R_G0, "g4", R_G4);
-	disp_reg_line(ph, prst, "g1", R_G1, "g5", R_G5);
-	disp_reg_line(ph, prst, "g2", R_G2, "g6", R_G6);
-	disp_reg_line(ph, prst, "g3", R_G3, "g7", R_G7);
-}
-
-void
-display_in_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dir: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("ins:\n");
-	disp_reg_line(ph, prst, "i0", R_I0, "i4", R_I4);
-	disp_reg_line(ph, prst, "i1", R_I1, "i5", R_I5);
-	disp_reg_line(ph, prst, "i2", R_I2, "i6(fp)", R_I6);
-	disp_reg_line(ph, prst, "i3", R_I3, "i7", R_I7);
-
-}
-
-
-retc_t
-display_all_regs(struct ps_prochandle * ph)
-{
-	pstatus_t	pstatus;
-
-	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-	    0) == -1) {
-		perror("dar: reading status");
-		return (RET_FAILED);
-	}
-	display_global_regs(ph, &pstatus);
-	display_in_regs(ph, &pstatus);
-	display_local_regs(ph, &pstatus);
-	display_out_regs(ph, &pstatus);
-	display_special_regs(ph, &pstatus);
-
-	return (RET_OK);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# 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
-# or http://www.opensolaris.org/os/licensing.
-# 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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include		../Makefile.com
-
-CPPFLAGS +=	-D_SYSCALL32
-
-# DEMO DELETE START
-CCVERBOSE=
-
-LDFLAGS=	-L ../../$(MACH64) \
-		-L ../../../libelf/$(MACH64)
-
-LINTFLAGS64 +=	$(VAR_LIBRTLD_DB_LINTFLAGS64)
-# DEMO DELETE END
-
-# Change -m64 to -xarch=generic64 for use with older Sun compilers.
-DEMOCFLAGS=	-m64
-
-.KEEP_STATE:
-
-all:		$(OBJDIR) .WAIT $(PROG)
-
-test:		$(TESTS)
-
-# DEMO DELETE START
-DEMOCFLAGS=
-
-install:	all $(ROOTONLDBINPROG64)
-
-lint:		$(LINTOUT)
-# DEMO DELETE END
-
-include		../Makefile.targ
-
-# DEMO DELETE START
-include		../../../../../Makefile.master.64
-# DEMO DELETE END
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/m_utils.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1996 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-
-#include "rdb.h"
-
-
-void
-print_mach_varstring(struct ps_prochandle * ph, const char * varname)
-{
-	if (strcmp(varname, "ins") == 0) {
-		display_in_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "globs") == 0) {
-		display_global_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "outs") == 0) {
-		display_out_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "locs") == 0) {
-		display_local_regs(ph, 0);
-		return;
-	}
-	if (strcmp(varname, "specs") == 0) {
-		display_special_regs(ph, 0);
-		return;
-	}
-	printf("print: unknown variable given ($%s)\n", varname);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/rdb_mach.h	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2000 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-
-#ifndef _RDB_MACH_H
-#define	_RDB_MACH_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/psw.h>
-#include <procfs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define	ERRBIT	PSR_C
-
-struct ps_prochandle;
-
-/*
- * BreakPoint instruction
- */
-typedef	unsigned	bptinstr_t;
-
-#define	BPINSTR		0x91d02001U	/* ta   ST_BREAKPOINT */
-
-/*
- * PLT section type
- */
-#define	PLTSECTT	SHT_PROGBITS
-
-extern void		display_in_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_local_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_out_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_special_regs(struct ps_prochandle *,
-				pstatus_t *);
-extern void		display_global_regs(struct ps_prochandle *,
-				pstatus_t *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _RDB_MACH_H */
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/regs.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,194 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 2000 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/param.h>
-
-#include "rdb.h"
-
-
-static void
-disp_reg_line(struct ps_prochandle * ph, pstatus_t * prst,
-	char * r1, int ind1, char * r2, int ind2)
-{
-	char 		str1[MAXPATHLEN];
-	char 		str2[MAXPATHLEN];
-
-	strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
-		FLG_PAP_NOHEXNAME));
-
-	strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
-		FLG_PAP_NOHEXNAME));
-
-	if (ph->pp_dmodel == PR_MODEL_LP64) {
-		/*
-		 *  In 64-bits, the display gets too wide when
-		 *  you have both a 64-bit address and a symbol
-		 *  name, e.g. _GLOBAL_OFFSET_TABLE;  therefore,
-		 *  each is put on a separate line.  This isn't
-		 *  as convenient as the 32-bit display.
-		 */
-		printf("%8s: 0x%08lx %-16s\n",
-			r1, prst->pr_lwp.pr_reg[ind1], str1);
-		printf("%8s: 0x%08lx %-16s\n",
-			r2, prst->pr_lwp.pr_reg[ind2], str2);
-	} else
-		printf("%8s: 0x%08lx %-16s %8s: 0x%08lx %-16s\n",
-			r1, prst->pr_lwp.pr_reg[ind1], str1,
-			r2, prst->pr_lwp.pr_reg[ind2], str2);
-}
-
-
-void
-display_local_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dar: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("locals:\n");
-	disp_reg_line(ph, prst, "l0", R_L0, "l4", R_L4);
-	disp_reg_line(ph, prst, "l1", R_L1, "l5", R_L5);
-	disp_reg_line(ph, prst, "l2", R_L2, "l6", R_L6);
-	disp_reg_line(ph, prst, "l3", R_L3, "l7", R_L7);
-}
-
-void
-display_out_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dar: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("outs:\n");
-	disp_reg_line(ph, prst, "o0", R_O0, "o4", R_O4);
-	disp_reg_line(ph, prst, "o1", R_O1, "o5", R_O5);
-	disp_reg_line(ph, prst, "o2", R_O2, "o6(sp)", R_O6);
-	disp_reg_line(ph, prst, "o3", R_O3, "o7", R_O7);
-}
-
-void
-display_special_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dar: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("specials:\n");
-
-	if (ph->pp_dmodel == PR_MODEL_LP64) {
-		disp_reg_line(ph, prst, "ccr", R_CCR, "pc", R_PC);
-		disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y);
-		disp_reg_line(ph, prst, "asi", R_ASI, "FPRS", R_FPRS);
-	} else {
-		disp_reg_line(ph, prst, "psr", R_PSR, "pc", R_PC);
-		disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y);
-		disp_reg_line(ph, prst, "wim", R_WIM, "TBR", R_TBR);
-	}
-}
-
-void
-display_global_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dar: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("globals:\n");
-	disp_reg_line(ph, prst, "g0", R_G0, "g4", R_G4);
-	disp_reg_line(ph, prst, "g1", R_G1, "g5", R_G5);
-	disp_reg_line(ph, prst, "g2", R_G2, "g6", R_G6);
-	disp_reg_line(ph, prst, "g3", R_G3, "g7", R_G7);
-}
-
-void
-display_in_regs(struct ps_prochandle * ph, pstatus_t * prst)
-{
-	pstatus_t	pstatus;
-
-	if (prst == 0) {
-		if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-		    0) == -1) {
-			perror("dar: reading status");
-			return;
-		}
-		prst = &pstatus;
-	}
-	printf("ins:\n");
-	disp_reg_line(ph, prst, "i0", R_I0, "i4", R_I4);
-	disp_reg_line(ph, prst, "i1", R_I1, "i5", R_I5);
-	disp_reg_line(ph, prst, "i2", R_I2, "i6(fp)", R_I6);
-	disp_reg_line(ph, prst, "i3", R_I3, "i7", R_I7);
-
-}
-
-
-retc_t
-display_all_regs(struct ps_prochandle * ph)
-{
-	pstatus_t	pstatus;
-
-	if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
-	    0) == -1) {
-		perror("dar: reading status");
-		return (RET_FAILED);
-	}
-	display_global_regs(ph, &pstatus);
-	display_in_regs(ph, &pstatus);
-	display_local_regs(ph, &pstatus);
-	display_out_regs(ph, &pstatus);
-	display_special_regs(ph, &pstatus);
-
-	return (RET_OK);
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/breaks	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-break
-break _start
-break
-delete _start
-break
-break main
-cont
-break
-break printf
-cont
-delete printf
-cont
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/loadmaps	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-echo "==============================================================="
-echo "Display maps before any link-maps are available."
-echo "==============================================================="
-maps
-break main
-cont
-echo "==============================================================="
-echo "Now that link-maps are available display both memory maps and "
-echo "link-maps"
-echo "==============================================================="
-maps
-linkmaps
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/object_padding_maps	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-echo "==============================================================="
-echo "Enable object padding with a padd of 0x90000"
-echo "==============================================================="
-objpad 0x90000
-break main
-cont
-echo "==============================================================="
-echo "Now display both mapping and link-maps to show results of"
-echo "object paddings."
-echo "==============================================================="
-maps
-linkmaps
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/plt_skip	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-break main
-cont
-#
-# First it does several steps over the call to small_sub
-echo "==============================================================="
-echo "The following step will step over the PLT's and directly"
-echo "into the functions."
-echo "==============================================================="
-step 30
-#
-# Disable the pltskip routine to see it step through
-# PLT's
-#
-pltskip
-echo "==============================================================="
-echo "Plt skipping has now been disabled and we should see the PLT's"
-echo "as we call into small_sub()"
-echo "==============================================================="
-step 30
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/simp.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1998 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include	<stdio.h>
-
-extern void small_sub(void);
-
-main()
-{
-	int i;
-	for (i = 0; i < 10; i++)
-		small_sub();
-
-	printf("simple run.\n");
-	return 0;
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/steps	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-break main
-cont
-step 10
-break printf
-cont
-step
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/sub.c	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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
- * or http://www.opensolaris.org/os/licensing.
- * 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 1995 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-void
-small_sub(void)
-{
-}
--- a/usr/src/cmd/sgs/librtld_db/rdb_demo/tests/test-sparc-regs	Tue Jul 27 20:35:25 2010 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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
-# or http://www.opensolaris.org/os/licensing.
-# 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
-#
-break main
-cont
-#
-#
-echo "===================================================="
-echo "Display all registers"
-echo "===================================================="
-print $regs
-echo "===================================================="
-echo "Display IN registers"
-echo "===================================================="
-print $ins
-echo "===================================================="
-echo "Display OUT registers"
-echo "===================================================="
-print $outs
-echo "===================================================="
-echo "Display LOCAL registers"
-echo "===================================================="
-print $locs
-echo "===================================================="
-echo "Display SPECIAL registers"
-echo "===================================================="
-print $specs
-echo "===================================================="
-echo "Display GLOBAL registers"
-echo "===================================================="
-print $globs
--- a/usr/src/cmd/sgs/link_audit/common/00README	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/00README	Tue Jul 27 22:49:34 2010 -0700
@@ -1,14 +1,9 @@
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
 #
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -23,13 +18,16 @@
 #
 # CDDL HEADER END
 #
+#
+# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+#
 
 This directory contains sample code on how to use the Link-Auditing
 interface of the runtime linker (ld.so.1(1)).  The Link-Auditing interface
 permits a user supplied shared object to audit objects that are loaded,
 and symbols that are bound, by the runtime linker.  A full description
-of the Link-Auditing interface can be found in the 'Linker & Libraries
-Guide' which is part of the Solaris AnswerBook.
+of the Link-Auditing interface can be found in the "Linker & Libraries
+Guide", which is part of the "Software Developer Collection".
 
 The following is an overview of the directory structure and highlights
 some of the important files contained within:
@@ -38,5 +36,8 @@
 src/*		- source code
 man/*		- Man pages for the examples
 
-To build these examples, copy this directory structure to a directory
-where you have write permissions.  Then type 'make'.
+
+Building the demos
+------------------
+
+  % make all
--- a/usr/src/cmd/sgs/link_audit/common/Makefile.demo	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/Makefile.demo	Tue Jul 27 22:49:34 2010 -0700
@@ -20,8 +20,7 @@
 #
 
 #
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 MACH:sh=	uname -p
--- a/usr/src/cmd/sgs/link_audit/common/bindings.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/bindings.c	Tue Jul 27 22:49:34 2010 -0700
@@ -20,13 +20,8 @@
  */
 
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
 #include	<link.h>
 #include	<stdlib.h>
 #include	<unistd.h>
@@ -46,8 +41,8 @@
 #include	"bindings.h"
 #include	"env.h"
 
-static Elist		*bindto_list = 0;
-static Elist		*bindfrom_list = 0;
+static Elist		*bindto_list = NULL;
+static Elist		*bindfrom_list = NULL;
 
 static bindhead		*bhp = NULL;
 static unsigned int	current_map_len = 0;
@@ -61,8 +56,8 @@
 static unsigned long
 ehash(const char *name)
 {
-	register unsigned int		g, h = 0;
-	register const unsigned char	*nm = (unsigned char *)name;
+	unsigned int		g, h = 0;
+	const unsigned char	*nm = (unsigned char *)name;
 
 	while (*nm != '\0') {
 		h = (h << 4) + *nm++;
@@ -145,8 +140,7 @@
 	int	fd;
 	if ((fd = open(buffer_name, O_RDWR)) == -1) {
 		(void) fprintf(stderr,
-			"bidings: grow_buffer: open failed: %s\n",
-			buffer_name);
+		    "bidings: grow_buffer: open failed: %s\n", buffer_name);
 		perror("open");
 		bt_unlock(&bhp->bh_lock);
 		exit(1);
@@ -236,8 +230,8 @@
 
 	if (version < LAV_CURRENT) {
 		(void) fprintf(stderr,
-			"bindings.so: unexpected link_audit version: %d\n",
-			version);
+		    "bindings.so: unexpected link_audit version: %d\n",
+		    version);
 		return (0);
 	}
 
@@ -250,6 +244,7 @@
 	(void) sigprocmask(SIG_BLOCK, &iset, &omask);
 	if ((fd = open(buffer_name, O_RDWR | O_CREAT | O_EXCL, 0666)) != -1) {
 		int	init_size = sizeof (bindhead) + BLKSIZE;
+
 		if (ftruncate(fd, init_size) == -1) {
 			perror("ftruncate");
 			return (0);
@@ -296,7 +291,7 @@
 			    PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) ==
 			    MAP_FAILED) {
 				(void) fprintf(stderr,
-					"bindings: mmap failed\n");
+				    "bindings: mmap failed\n");
 				perror("mmap");
 				return (0);
 			}
@@ -306,7 +301,7 @@
 		}
 		if (bhp == NULL) {
 			(void) fprintf(stderr,
-				"bindings: buffer mapping timed out\n");
+			    "bindings: buffer mapping timed out\n");
 			return (0);
 		}
 		for (i = 0; i < 4; i++) {
@@ -317,7 +312,7 @@
 		}
 		if (bhp->bh_vers == 0) {
 			(void) fprintf(stderr,
-				"bindings: %s not initialized\n", buffer_name);
+			    "bindings: %s not initialized\n", buffer_name);
 			return (0);
 		}
 
@@ -328,7 +323,7 @@
 		(void) close(fd);
 	} else {
 		(void) fprintf(stderr, "bindings: unable to open %s\n",
-			buffer_name);
+		    buffer_name);
 		perror("open");
 		return (0);
 	}
@@ -345,13 +340,13 @@
 {
 	uint_t	flags;
 
-	if ((bindto_list == 0) ||
+	if ((bindto_list == NULL) ||
 	    (check_list(bindto_list, lmp->l_name)))
 		flags = LA_FLG_BINDTO;
 	else
 		flags = 0;
 
-	if ((bindfrom_list == 0) ||
+	if ((bindfrom_list == NULL) ||
 	    (check_list(bindfrom_list, lmp->l_name)))
 		flags |= LA_FLG_BINDFROM;
 
@@ -392,7 +387,7 @@
 	lib_name = dlmp->l_name;
 
 	(void) sigprocmask(SIG_BLOCK, &iset, &omask);
-	if (sym_name == 0) {
+	if (sym_name == NULL) {
 		output_err_message("null symname\n");
 		return (symp->st_value);
 	}
@@ -440,9 +435,9 @@
 	} else {
 		int		strcmp_res;
 		unsigned int	prev_off = 0;
-		binding_entry *	prev_bep = NULL;
+		binding_entry	*prev_bep = NULL;
 		unsigned int	cur_off;
-		binding_entry *	cur_bep;
+		binding_entry	*cur_bep;
 		unsigned int	lib_off = 0;
 
 		/*
--- a/usr/src/cmd/sgs/link_audit/common/bindings.h	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/bindings.h	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,12 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef	_BINDINGS_H
 #define	_BINDINGS_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/lwp.h>
 
 #ifdef	__cplusplus
--- a/usr/src/cmd/sgs/link_audit/common/dumpbind.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/dumpbind.c	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,13 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include	<stdlib.h>
 #include	<unistd.h>
 #include	<sys/types.h>
@@ -205,13 +201,14 @@
 	if (pflag)
 		format_string = "%s|%s|%8d\n";
 	else {
-		if (!bflag)
-		    (void) printf(
-			"                           Bindings Summary Report\n\n"
-			"Library                             Symbol"
-			"                   Call Count\n"
-			"----------------------------------------------"
-			"--------------------------\n");
+		if (!bflag) {
+			(void) printf("                           "
+			    "Bindings Summary Report\n\n"
+			    "Library                             Symbol"
+			    "                   Call Count\n"
+			    "----------------------------------------------"
+			    "--------------------------\n");
+		}
 		format_string = "%-35s %-25s %5d\n";
 	}
 
@@ -241,12 +238,11 @@
 			(void) printf("bkt[%d] - %d entries\n", i, ent_cnt);
 	}
 
-	if (!bflag && !pflag)
-		(void) printf(
-			"----------------------------------------------"
-			"--------------------------\n"
-			"Symbol Count: %lu    Call Count: %lu\n\n",
-			symcount, callcount);
-
+	if (!bflag && !pflag) {
+		(void) printf("----------------------------------------------"
+		    "--------------------------\n"
+		    "Symbol Count: %lu    Call Count: %lu\n\n",
+		    symcount, callcount);
+	}
 	return (0);
 }
--- a/usr/src/cmd/sgs/link_audit/common/env.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/env.c	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,13 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -47,7 +43,7 @@
 	tok = strtok_r(envstr, token, &lasts);
 	while (tok) {
 		Elist	*lp;
-		if ((lp = (Elist *)malloc(sizeof (Elist))) == 0) {
+		if ((lp = (Elist *)malloc(sizeof (Elist))) == NULL) {
 			(void) printf("build_list: malloc failed\n");
 			exit(1);
 		}
@@ -69,16 +65,16 @@
 		return (NULL);
 
 	/*
-	 * Is this a basename or a relativepath name
+	 * Is this a basename or a relative path name
 	 */
-	if ((basestr = strrchr(str, '/')) != 0)
+	if ((basestr = strrchr(str, '/')) != NULL)
 		basestr++;
 	else
 		basestr = str;
 
 
 	for (; list; list = list->l_next) {
-		if (strchr(list->l_libname, '/') == 0) {
+		if (strchr(list->l_libname, '/') == NULL) {
 			if (strcmp(basestr, list->l_libname) == 0)
 				return (list);
 		} else {
--- a/usr/src/cmd/sgs/link_audit/common/env.h	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/env.h	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,19 +18,21 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright (c) 1997 by Sun Microsystems, Inc.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  * All rights reserved.
  */
-
-#pragma	ident	"%Z%%M%	%I%	%E% SMI"
-
+#ifndef	_ENV_H
+#define	_ENV_H
 
 typedef	struct elist {
-	char *			l_libname;
-	struct elist *		l_next;
+	char		*l_libname;
+	struct elist	*l_next;
 } Elist;
 
-extern void		build_env_list(Elist **, const char *);
-extern Elist *		check_list(Elist *, const char *);
-extern char *		checkenv(const char *);
+extern void	build_env_list(Elist **, const char *);
+extern Elist	*check_list(Elist *, const char *);
+extern char	*checkenv(const char *);
+
+#endif	/* _ENV_H */
--- a/usr/src/cmd/sgs/link_audit/common/hash.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/hash.c	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,13 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -38,14 +34,12 @@
 hash *
 make_hash(size_t size)
 {
-	hash *ptr;
+	hash	*ptr;
 
-	ptr = (hash *) malloc(sizeof (*ptr));
+	ptr = malloc(sizeof (*ptr));
 	ptr->size = size;
-	ptr->table = (hash_entry **)
-	    malloc((size_t) (sizeof (hash_entry *) * size));
-	(void) memset((char *) ptr->table, (char) 0,
-	    sizeof (hash_entry *)*size);
+	ptr->table = malloc((size_t)(sizeof (hash_entry *) * size));
+	(void) memset((char *)ptr->table, 0, sizeof (hash_entry *) * size);
 	ptr->start = NULL;
 	ptr->hash_type = String_Key;
 	return (ptr);
@@ -54,25 +48,22 @@
 hash *
 make_ihash(size_t size)
 {
-	hash * ptr;
+	hash	*ptr;
 
-	ptr = (hash *) malloc(sizeof (*ptr));
+	ptr = malloc(sizeof (*ptr));
 	ptr->size = size;
-	ptr->table = (hash_entry **) malloc(sizeof (hash_entry *) * size);
-	(void) memset((char *) ptr->table, (char) 0,
-	    sizeof (hash_entry *) * size);
+	ptr->table = malloc(sizeof (hash_entry *) * size);
+	(void) memset((char *)ptr->table, 0, sizeof (hash_entry *) * size);
 	ptr->start = NULL;
 	ptr->hash_type = Integer_Key;
 	return (ptr);
 }
 
-
 char **
 get_hash(hash *tbl, char *key)
 {
-	long bucket;
-	hash_entry *tmp;
-	hash_entry *new;
+	long		bucket;
+	hash_entry	*tmp, *new;
 
 	if (tbl->hash_type == String_Key) {
 		tmp = tbl->table[bucket = hash_string(key, tbl->size)];
@@ -100,21 +91,22 @@
 	 * not found....
 	 * insert new entry into bucket...
 	 */
+	new = malloc(sizeof (*new));
+	new->key = ((tbl->hash_type == String_Key)?strdup(key):key);
 
-	new = (hash_entry *) malloc(sizeof (*new));
-	new->key = ((tbl->hash_type == String_Key)?strdup(key):key);
 	/*
 	 * hook into chain from tbl...
 	 */
 	new->right_entry = NULL;
 	new->left_entry = tbl->start;
 	tbl->start = new;
+
 	/*
 	 * hook into bucket chain
 	 */
 	new->next_entry = tbl->table[bucket];
 	tbl->table[bucket] = new;
-	new->data = NULL;   /* so we know that it is new */
+	new->data = NULL;		/* so we know that it is new */
 	return (&new->data);
 }
 
@@ -138,7 +130,6 @@
 			}
 		}
 	}
-
 	return (NULL);
 }
 
@@ -178,9 +169,10 @@
 			return (NULL); /* not found */
 		}
 	}
+
 	/*
 	 * tmp now points to entry marked for deletion, prev to
-	 * item preceeding in bucket chain or NULL if tmp is first.
+	 * item preceding in bucket chain or NULL if tmp is first.
 	 * remove from bucket chain first....
 	 */
 	if (tbl->hash_type == String_Key) {
@@ -191,6 +183,7 @@
 	} else {
 		tbl->table[bucket] = tmp->next_entry;
 	}
+
 	/*
 	 * now remove from tbl chain....
 	 */
@@ -207,8 +200,8 @@
 size_t
 operate_hash(hash *tbl, void (*ptr)(), const char *usr_arg)
 {
-	hash_entry * tmp = tbl->start;
-	size_t c = 0;
+	hash_entry	*tmp = tbl->start;
+	size_t		c = 0;
 
 	while (tmp) {
 		(*ptr)(tmp->data, usr_arg, tmp->key);
@@ -221,8 +214,8 @@
 size_t
 operate_hash_addr(hash *tbl, void (*ptr)(), const char *usr_arg)
 {
-	hash_entry * tmp = tbl->start;
-	size_t c = 0;
+	hash_entry	*tmp = tbl->start;
+	size_t		c = 0;
 
 	while (tmp) {
 		(*ptr)(&(tmp->data), usr_arg, tmp->key);
@@ -256,10 +249,10 @@
 static int
 hash_string(const char *s, long modulo)
 {
-	unsigned result = 0;
-	int i = 1;
+	unsigned int	result = 0;
+	int		i = 1;
 
-	while (*s != 0) {
+	while (*s != NULL) {
 		result += (*s++ << i++);
 	}
 
--- a/usr/src/cmd/sgs/link_audit/common/hash.h	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/hash.h	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,67 +18,37 @@
  *
  * CDDL HEADER END
  */
-/*
- * Copyright (c) 1996 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma	ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
-  @(#)SSM2 hash.h 1.2 90/11/13 
-*/
 
 /*
- * File: hash.h
- *
- * Copyright (C) 1990 Sun Microsystems Inc.
- * All Rights Reserved.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-
-/*
- *    Change Log
- * ============================================================================
- * Author      Date       Change 
- * barts     13 Nov 90	  Created.
- *
- */
-
-#ifndef _hash_h
-#define _hash_h
+#ifndef _HASH_H
+#define	_HASH_H
 
 typedef struct hash_entry {
-  struct hash_entry 
-    * next_entry,
-    * right_entry,
-    * left_entry;
-  char *       	key;
-  char * 	data;
+	struct hash_entry	*next_entry;
+	struct hash_entry	*right_entry;
+	struct hash_entry	*left_entry;
+	char			*key;
+	char			*data;
 } hash_entry;
 
 typedef struct hash {
-  size_t	size;
-  hash_entry ** table;
-  hash_entry * 	start;   
-  enum hash_type { String_Key = 0 , Integer_Key = 1} hash_type;
+	size_t			size;
+	hash_entry		**table;
+	hash_entry		*start;
+	enum hash_type {
+		String_Key = 0,
+		Integer_Key = 1
+	} hash_type;
 } hash;
 
-hash * 		make_hash(size_t size);
-hash * 		make_ihash(size_t size);
-char ** 	get_hash(hash * tbl, char * key);
-char **		find_hash(hash * tbl, const char * key);
-char *		del_hash(hash * tbl, const char * key);
-size_t 		operate_hash(hash * tbl, void (*ptr)(), const char * usr_arg);
-void 		destroy_hash(hash * tbl, int (*ptr)(), const char * usr_arg);
+extern hash	*make_hash(size_t);
+extern hash	*make_ihash(size_t);
+extern char	**get_hash(hash *, char *);
+extern char	**find_hash(hash *, const char *);
+extern char	*del_hash(hash *, const char *);
+extern size_t 	operate_hash(hash *, void (*)(), const char *);
+extern void 	destroy_hash(hash *, int (*)(), const char *);
 
-#endif /* _hash_h */
-
-
-
-
-
-
-
-
-
+#endif /* _HASH_H */
--- a/usr/src/cmd/sgs/link_audit/common/mach.h	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/mach.h	Tue Jul 27 22:49:34 2010 -0700
@@ -18,16 +18,13 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
 #ifndef _MACH_DOT_H
 #define	_MACH_DOT_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/reg.h>
 #include <sys/types.h>
 
--- a/usr/src/cmd/sgs/link_audit/common/perfcnt.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/perfcnt.c	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,13 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -54,8 +50,8 @@
 } List;
 
 
-static Elist	    *bindto_list = 0;
-static Elist	    *bindfrom_list = 0;
+static Elist	    *bindto_list = NULL;
+static Elist	    *bindfrom_list = NULL;
 
 static int  initialized;
 extern long long gethrvtime();
@@ -66,7 +62,7 @@
 static int  counter = 0;
 
 static float	total_time = 0.0;
-static List	*list_head = 0;
+static List	*list_head = NULL;
 
 static hash	*tbl;
 
@@ -79,26 +75,26 @@
 	List *cur;
 	List *prev;
 
-	if ((new_list = malloc(sizeof (List))) == 0) {
+	if ((new_list = malloc(sizeof (List))) == NULL) {
 		(void) printf("libperfcnt.so: malloc failed - "
-			"can't print summary\n");
+		    "can't print summary\n");
 		exit(1);
 	}
 	new_list->l_dep = dep;
 
-	if (list_head == 0) {
+	if (list_head == NULL) {
 		list_head = new_list;
-		new_list->l_next = 0;
+		new_list->l_next = NULL;
 		return;
 	}
-	for (cur = list_head, prev = 0;
+	for (cur = list_head, prev = NULL;
 	    (cur && (cur->l_dep->d_time < dep->d_time));
 	    prev = cur, cur = cur->l_next)
 		;
 	/*
 	 * insert at head of list
 	 */
-	if (prev == 0) {
+	if (prev == NULL) {
 		new_list->l_next = list_head;
 		list_head = new_list;
 		return;
@@ -115,7 +111,7 @@
 
 	if (version > LAV_CURRENT)
 		(void) fprintf(stderr, "perfcnt.so.1: unexpected version: %d\n",
-			version);
+		    version);
 
 	(void) sprintf(buffer, "/proc/%d", (int)getpid());
 	if ((fd = open(buffer, O_RDWR)) >= 0) {
@@ -153,13 +149,13 @@
 		first = 0;
 	}
 
-	if (bindto_list == 0)
+	if (bindto_list == NULL)
 		flags = LA_FLG_BINDTO;
 	else {
 		if (check_list(bindto_list, lmp->l_name))
 			flags = LA_FLG_BINDTO;
 	}
-	if (bindfrom_list == 0)
+	if (bindfrom_list == NULL)
 		flags |= LA_FLG_BINDFROM;
 	else {
 		if (check_list(bindfrom_list, lmp->l_name))
@@ -259,19 +255,19 @@
 	(void) operate_hash(tbl, scanlist, NULL);
 	(void) printf("\n\nPerf Counts for: %s\n\n", progname);
 	(void) printf("%20s\tc_count\t    tim\t\tavg. tim\ttot. %%\n",
-		"SYMBOL");
+	    "SYMBOL");
 	(void) printf("--------------------------------------------------"
-		"-------------------\n");
+	    "-------------------\n");
 	for (cur = list_head; cur; cur = cur->l_next) {
 		d_entry		*dep = cur->l_dep;
 		float		tim = dep->d_time * 1000000;
 
 		(void) printf("%20s\t%d\t%8.2f\t%8.2f\t%2.2f%%\n",
-			dep->d_symname, dep->d_count, tim, tim / dep->d_count,
-			((dep->d_time / total_time) * 100.0));
+		    dep->d_symname, dep->d_count, tim, tim / dep->d_count,
+		    ((dep->d_time / total_time) * 100.0));
 	}
 	(void) printf("--------------------------------------------------"
-		"-------------------\n");
+	    "-------------------\n");
 	(void) printf("\t\t\t\t\t\tTotal Time: %8.2f\n",
-		total_time * 1000000);
+	    total_time * 1000000);
 }
--- a/usr/src/cmd/sgs/link_audit/common/perfcnt.ksh	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/perfcnt.ksh	Tue Jul 27 22:49:34 2010 -0700
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,10 @@
 #
 # CDDL HEADER END
 #
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
+
 #
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+#
 
 usage() {
 	echo "usage: perfcnt -[$optlet] utility [utility arguments]"
--- a/usr/src/cmd/sgs/link_audit/common/sotruss.ksh	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/sotruss.ksh	Tue Jul 27 22:49:34 2010 -0700
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,7 @@
 #
 # CDDL HEADER END
 #
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 
 usage() {
 	echo "usage: sotruss [-F:-T:-o:-f] utility [utility arguments]"
--- a/usr/src/cmd/sgs/link_audit/common/symbindrep.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/symbindrep.c	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,22 +18,18 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright (c) 1997-2001 by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <link.h>
 
 #include "env.h"
 
-static Elist	*bindto_list = 0;
-static Elist	*bindfrom_list = 0;
+static Elist	*bindto_list = NULL;
+static Elist	*bindfrom_list = NULL;
 static FILE	*output = stdout;
 
 
@@ -43,44 +38,44 @@
 {
 	if (version < LAV_CURRENT) {
 		(void) fprintf(stderr,
-			"symbindrep.so: unexpected version: %d\n",
-			version);
+		    "symbindrep.so: unexpected version: %d\n", version);
 		return (0);
 	}
 
 	build_env_list(&bindto_list, (const char *)"SYMBINDREP_BINDTO");
 	build_env_list(&bindfrom_list, (const char *)"SYMBINDREP_BINDFROM");
 
+#ifdef _LP64
 	(void) fprintf(output,
-#ifdef _LP64
-	"                            Symbol Bindings\n\n"
-	"Referencing                  Defining\n"
-	"Object                       Object                       Symbol\n"
-	/* CSTYLED */
-	"----------------------------------------------------------------------------------\n");
+	    "                            Symbol Bindings\n\n"
+	    "Referencing                  Defining\n"
+	    "Object                       Object                       Symbol\n"
+	    "---------------------------------------------------------------"
+	    "-------------------\n");
 #else
-	"                    Symbol Bindings\n\n"
-	"Referencing          Defining\n"
-	"Object               Object               Symbol\n"
-	"------------------------------------------------------------------\n");
+	(void) fprintf(output,
+	    "                    Symbol Bindings\n\n"
+	    "Referencing          Defining\n"
+	    "Object               Object               Symbol\n"
+	    "---------------------------------------------------------------"
+	    "---\n");
 #endif
 	return (LAV_CURRENT);
 }
 
-
 /* ARGSUSED1 */
 uint_t
 la_objopen(Link_map *lmp, Lmid_t lmid, uintptr_t *cookie)
 {
 	uint_t		flags;
 
-	if ((bindto_list == 0) ||
+	if ((bindto_list == NULL) ||
 	    (check_list(bindto_list, lmp->l_name)))
 		flags = LA_FLG_BINDTO;
 	else
 		flags = 0;
 
-	if ((bindfrom_list == 0) ||
+	if ((bindfrom_list == NULL) ||
 	    (check_list(bindfrom_list, lmp->l_name)))
 		flags |= LA_FLG_BINDFROM;
 
--- a/usr/src/cmd/sgs/link_audit/common/symbindrep.ksh	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/symbindrep.ksh	Tue Jul 27 22:49:34 2010 -0700
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,7 @@
 #
 # CDDL HEADER END
 #
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 
 usage() {
 	echo "usage: symbindrep -[$optlet] utility"
--- a/usr/src/cmd/sgs/link_audit/common/truss.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/truss.c	Tue Jul 27 22:49:34 2010 -0700
@@ -18,13 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <link.h>
 #include <sys/types.h>
 #include <sys/param.h>
@@ -37,8 +34,8 @@
 #include "env.h"
 #include "mach.h"
 
-static Elist		*bindto_list = 0;
-static Elist		*bindfrom_list = 0;
+static Elist		*bindto_list = NULL;
+static Elist		*bindfrom_list = NULL;
 
 static uint_t		pidout = 0;
 static pid_t		pid;
@@ -49,7 +46,6 @@
 static uint_t		noexit = 0;
 static sigset_t		iset;
 
-
 /*
  * It's not possible to gather the return code on routines
  * which actually have a dependence on the 'stack frame structure'.
@@ -89,14 +85,14 @@
 	(char *)0
 };
 
-
 uint_t
 la_version(uint_t version)
 {
 	char	*str;
+
 	if (version > LAV_CURRENT)
 		(void) fprintf(stderr, "truss.so: unexpected version: %d\n",
-			version);
+		    version);
 
 	build_env_list(&bindto_list, (const char *)"TRUSS_BINDTO");
 	build_env_list(&bindfrom_list, (const char *)"TRUSS_BINDFROM");
@@ -151,7 +147,6 @@
 	return (LAV_CURRENT);
 }
 
-
 /* ARGSUSED1 */
 uint_t
 la_objopen(Link_map *lmp, Lmid_t lmid, uintptr_t *cookie)
@@ -160,21 +155,21 @@
 	char	*basename;
 	static int	first = 1;
 
-	if ((bindto_list == 0) || (trussall))
+	if ((bindto_list == NULL) || (trussall))
 		flags = LA_FLG_BINDTO;
 	else if (check_list(bindto_list, lmp->l_name))
 		flags = LA_FLG_BINDTO;
 	else
 		flags = 0;
 
-	if (((bindfrom_list == 0) && first) || trussall ||
+	if (((bindfrom_list == NULL) && first) || trussall ||
 	    (check_list(bindfrom_list, lmp->l_name)))
 		flags |= LA_FLG_BINDFROM;
 
 	first = 0;
 
 	if (flags) {
-		if ((basename = strrchr(lmp->l_name, '/')) != 0)
+		if ((basename = strrchr(lmp->l_name, '/')) != NULL)
 			basename++;
 		else
 			basename = lmp->l_name;
@@ -225,8 +220,6 @@
 	return (symp->st_value);
 }
 
-
-
 /* ARGSUSED1 */
 #if	defined(__sparcv9)
 uintptr_t
@@ -278,7 +271,6 @@
 	return (symp->st_value);
 }
 
-
 /* ARGSUSED1 */
 #if	defined(_LP64)
 /* ARGSUSED */
--- a/usr/src/cmd/sgs/link_audit/common/who.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/who.c	Tue Jul 27 22:49:34 2010 -0700
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * 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
  * or http://www.opensolaris.org/os/licensing.
@@ -19,13 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <stdio.h>
 #include <fcntl.h>
 #include <link.h>
@@ -42,22 +38,21 @@
 #include "who.h"
 
 
-static int		detail_syms = 0; /* display detail symbol information */
-static Objinfo *	objhead = 0;	/* head of object list */
-static Elist *		funclist = 0;
-static sigset_t		iset;
-
+static int	detail_syms = 0;	/* display detail symbol information */
+static Objinfo	*objhead = NULL;	/* head of object list */
+static Elist	*funclist = NULL;
+static sigset_t	iset;
 
 static void
-add_object(Objinfo ** objlist, Link_map * lmp)
+add_object(Objinfo **objlist, Link_map *lmp)
 {
-	Objinfo *	op, * cur, * prev;
-	Elf_Ehdr *	ehdr;
-	Elf_Phdr *	phdr;
+	Objinfo		*op, *cur, *prev;
+	Elf_Ehdr	*ehdr;
+	Elf_Phdr	*phdr;
 	caddr_t		lpc, hpc;
 	int		i;
 
-	if ((op = calloc(1, sizeof (Objinfo))) == 0) {
+	if ((op = calloc(1, sizeof (Objinfo))) == NULL) {
 		(void) fprintf(stderr, "who.so.1: calloc failed\n");
 		exit(1);
 	}
@@ -78,11 +73,10 @@
 	op->o_hpc = hpc;
 	op->o_lmp = lmp;
 
-
 	if (ehdr->e_type == ET_EXEC)
 		op->o_flags |= FLG_OB_FIXED;
 
-	if (*objlist == 0) {
+	if (*objlist == NULL) {
 		*objlist = op;
 		return;
 	}
@@ -96,11 +90,11 @@
 		return;
 	}
 
-	for (prev = 0, cur = *objlist; cur; prev = cur, cur = cur->o_next) {
+	for (prev = NULL, cur = *objlist; cur; prev = cur, cur = cur->o_next) {
 		if (lpc < cur->o_lpc)
 			break;
 	}
-	if (prev == 0) {
+	if (prev == NULL) {
 		op->o_next = *objlist;
 		*objlist = op;
 		return;
@@ -110,14 +104,15 @@
 }
 
 static void
-remove_object(Objinfo ** objlist, Link_map * lmp)
+remove_object(Objinfo **objlist, Link_map *lmp)
 {
-	Objinfo *	cur, * prev;
+	Objinfo	*cur, *prev;
 
-	for (prev = 0, cur = *objlist; cur; prev = cur, cur = cur->o_next) {
+	for (prev = NULL, cur = *objlist; cur; prev = cur, cur = cur->o_next) {
 		if (cur->o_lmp == lmp)
 			break;
 	}
+
 	/*
 	 * Did we find it?
 	 */
@@ -137,27 +132,27 @@
 }
 
 static void
-print_simple_address(void * pc)
+print_simple_address(void *pc)
 {
 	Dl_info		info;
 
 	if (dladdr(pc, &info) == 0) {
 		(void) fprintf(stderr,
-			"\t<unknown>: 0x%lx\n", (unsigned long)pc);
+		    "\t<unknown>: 0x%lx\n", (unsigned long)pc);
 		return;
 	}
 
-	(void) fprintf(stderr, "\t%s:%s+0x%lx\n",
-		info.dli_fname, info.dli_sname,
-		(ulong_t)((uintptr_t)pc - (uintptr_t)info.dli_saddr));
+	(void) fprintf(stderr, "\t%s:%s+0x%lx\n", info.dli_fname,
+	    info.dli_sname,
+	    (ulong_t)((uintptr_t)pc - (uintptr_t)info.dli_saddr));
 }
 
 static void
-load_syms(Objinfo * op)
+load_syms(Objinfo *op)
 {
-	int		fd;
-	Elf *		elf;
-	Elf_Scn *	scn;
+	int	fd;
+	Elf	*elf;
+	Elf_Scn	*scn;
 
 	if (elf_version(EV_CURRENT) == EV_NONE) {
 		op->o_flags |= FLG_OB_NOSYMS;
@@ -169,15 +164,16 @@
 		return;
 	}
 
-	if ((elf = elf_begin(fd, ELF_C_READ, 0)) == 0) {
+	if ((elf = elf_begin(fd, ELF_C_READ, 0)) == NULL) {
 		op->o_flags |= FLG_OB_NOSYMS;
 		(void) close(fd);
 		return;
 	}
-	scn = 0;
-	while ((scn = elf_nextscn(elf, scn)) != 0) {
-		Elf_Shdr *	shdr;
-		Elf_Data *	data;
+	scn = NULL;
+	while ((scn = elf_nextscn(elf, scn)) != NULL) {
+		Elf_Shdr	*shdr;
+		Elf_Data	*data;
+
 		shdr = elf_getshdr(scn);
 		if (shdr->sh_type != SHT_SYMTAB)
 			continue;
@@ -200,9 +196,9 @@
 static void
 print_address(caddr_t pc)
 {
-	Elf_Sym *	sym, * _sym;
-	Objinfo *	op;
-	int		i;
+	Elf_Sym	*sym, *_sym;
+	Objinfo	*op;
+	int	i;
 
 	if (!detail_syms) {
 		print_simple_address(pc);
@@ -212,7 +208,7 @@
 		if ((pc >= op->o_lpc) && (pc <= op->o_hpc))
 			break;
 	}
-	if (op && (op->o_syms == 0))
+	if (op && (op->o_syms == NULL))
 		load_syms(op);
 
 	if (!op || (op->o_flags & FLG_OB_NOSYMS)) {
@@ -228,9 +224,9 @@
 		    (_sym->st_value > sym->st_value))
 			sym = _sym;
 	}
-	(void) fprintf(stderr, "\t%s:%s+0x%lx\n",
-		op->o_lmp->l_name, sym->st_name + op->o_strs,
-		(ulong_t)((uintptr_t)pc - (uintptr_t)sym->st_value));
+	(void) fprintf(stderr, "\t%s:%s+0x%lx\n", op->o_lmp->l_name,
+	    sym->st_name + op->o_strs,
+	    (ulong_t)((uintptr_t)pc - (uintptr_t)sym->st_value));
 }
 
 static void
@@ -249,7 +245,7 @@
 {
 	if (version > LAV_CURRENT)
 		(void) fprintf(stderr, "who.so: unexpected version: %d\n",
-			version);
+		    version);
 
 	if (checkenv((const char *)"WHO_DETAIL"))
 		detail_syms++;
@@ -273,7 +269,6 @@
 	return (LA_FLG_BINDTO | LA_FLG_BINDFROM);
 }
 
-
 uint_t
 la_objclose(uintptr_t *cookie)
 {
@@ -281,7 +276,6 @@
 	return (1);
 }
 
-
 /* ARGSUSED1 */
 #if	defined(__sparcv9)
 uintptr_t
@@ -313,8 +307,8 @@
 		struct frame	*frame_p;
 
 		(void) fprintf(stderr, "%s(0x%lx, 0x%lx, 0x%lx)\n", sym_name,
-			(long)GETARG0(regset), (long)GETARG1(regset),
-			(long)GETARG2(regset));
+		    (long)GETARG0(regset), (long)GETARG1(regset),
+		    (long)GETARG2(regset));
 
 		print_address((caddr_t)GETPREVPC(regset));
 
--- a/usr/src/cmd/sgs/link_audit/common/who.h	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/who.h	Tue Jul 27 22:49:34 2010 -0700
@@ -18,13 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #ifndef WHO_DOT_H
 #define	WHO_DOT_H
 
--- a/usr/src/cmd/sgs/link_audit/common/whocalls.ksh	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/common/whocalls.ksh	Tue Jul 27 22:49:34 2010 -0700
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# 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
 # or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,7 @@
 #
 # CDDL HEADER END
 #
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 
 usage() {
 	cat 1>&2 << 'EOF'
--- a/usr/src/cmd/sgs/link_audit/man/dumpbind.man	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/man/dumpbind.man	Tue Jul 27 22:49:34 2010 -0700
@@ -1,13 +1,10 @@
-.\" ident	"%Z%%M%	%I%	%E% SMI"
-.\" Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-.\" Use is subject to license terms.
+.\" Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 .\"
 .\" CDDL HEADER START
 .\"
 .\" The contents of this file are subject to the terms of the
-.\" Common Development and Distribution License, Version 1.0 only
-.\" (the "License").  You may not use this file except in compliance
-.\" with the License.
+.\" 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
 .\" or http://www.opensolaris.org/os/licensing.
@@ -73,16 +70,16 @@
 .TP
 .B BT_OUTPUT
 set this to the name of the common output buffer which will be maintained
-durring the data gathering periode.  If this is not set the
+during the data gathering period.  If this is not set the
 output buffer will default to
 .I /tmp/bindings.data.
 .TP
 .B BT_BINDFROM
-a colon seperated list of libraries that are to be traced.  Only calls from
+a colon separated list of libraries that are to be traced.  Only calls from
 these libraries will be traced.  The default is to trace all calls.
 .TP
 .B BT_BINDTO
-a colon seperated list of libraries that are to be traced.  Only calls to
+a colon separated list of libraries that are to be traced.  Only calls to
 these libraries will be traced.  The default is to trace all calls.
 .SH OPTIONS
 .TP 10
@@ -163,7 +160,7 @@
 .ft
 .fi
 .LP
-The unseting of LD_AUDIT has turned off the bindings data gathering
+Unsetting LD_AUDIT has turned off the bindings data gathering
 and the output can now safely be examined by dumpbind.
 .LP
 .nf
--- a/usr/src/cmd/sgs/link_audit/man/perfcnt.man	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/man/perfcnt.man	Tue Jul 27 22:49:34 2010 -0700
@@ -1,13 +1,10 @@
-.\" ident	"%Z%%M%	%I%	%E% SMI"
-.\" Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-.\" Use is subject to license terms.
+.\" Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 .\"
 .\" CDDL HEADER START
 .\"
 .\" The contents of this file are subject to the terms of the
-.\" Common Development and Distribution License, Version 1.0 only
-.\" (the "License").  You may not use this file except in compliance
-.\" with the License.
+.\" 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
 .\" or http://www.opensolaris.org/os/licensing.
@@ -62,12 +59,12 @@
 .SH OPTIONS
 .TP 10
 .BI \-f " bindfromlist"
-A colon seperated list of libraries that are to be
+A colon separated list of libraries that are to be
 traced.  Only calls from these libraries will be traced.  The default
 is to trace all calls.
 .TP
 .BI \-t " bindtolist"
-A colon seperated list of libraries taht are to be traced.
+A colon separated list of libraries taht are to be traced.
 Only calls to these libraries will be traced.  The default is
 to trace all calls.
 .TP
@@ -126,7 +123,7 @@
 .I Link-Auditing
 interface of the run-time linker (which is documented in
 .TZ LLM
-\), and it is not usefull in all environments.  This program
+\), and it is not useful in all environments.  This program
 will not work with a threaded application and should not be
 used with one.  Also, in order to track the
 time spent in a procedure both the
--- a/usr/src/cmd/sgs/link_audit/man/symbindrep.man	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/link_audit/man/symbindrep.man	Tue Jul 27 22:49:34 2010 -0700
@@ -1,13 +1,10 @@
-.\" ident	"%Z%%M%	%I%	%E% SMI"
-.\" Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-.\" Use is subject to license terms.
+.\" Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
 .\"
 .\" CDDL HEADER START
 .\"
 .\" The contents of this file are subject to the terms of the
-.\" Common Development and Distribution License, Version 1.0 only
-.\" (the "License").  You may not use this file except in compliance
-.\" with the License.
+.\" 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
 .\" or http://www.opensolaris.org/os/licensing.
@@ -58,11 +55,11 @@
 .SH OPTIONS
 .TP 10
 .BI \-f " bindfromlist"
-A colon seperated list of libraries that are to be traced.  Only symbol
+A colon separated list of libraries that are to be traced.  Only symbol
 bindings from these libraries will be traced.  The default is
 to report on all symbol bindings.
 .BI \-t " bindtolib"
-A colon seperated list of libraries that are to be traced.  Only symbol
+A colon separated list of libraries that are to be traced.  Only symbol
 bindings to these libraries will be reported.  The default is to trace
 all libraries.
 .BI \-l " symbindrep"
--- a/usr/src/cmd/sgs/packages/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/packages/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -35,10 +35,9 @@
 		else echo "unknown"; \
 		fi
 
-RDBDIRS=	$(MACHS:%=../librtld_db/rdb_demo/%)
+RDBDIRS=	$(MACHS:%=../librtld_db/demo/%)
 LDMAKEDIRS=	$(MACHS:%=../libldmake/%)
 
-
 SUBDIRS1=	../libconv \
 		.WAIT \
 	 	../libdl \
@@ -62,7 +61,6 @@
 		../tools \
 		$(RDBDIRS)
 
-
 #
 # Package dirs are directories which specifically
 # have a 'package' target.  This target is used to key
--- a/usr/src/cmd/sgs/packages/common/SUNWonld-README	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/packages/common/SUNWonld-README	Tue Jul 27 22:49:34 2010 -0700
@@ -57,7 +57,7 @@
 
     If the patch has been made official, you'll find it in:
 
-	http://sunsolve.Ebay.Sun.COM/cgi/show.pl?target=patches/os-patches
+	http://sunsolve.east/cgi/show.pl?target=patches/os-patches
 
     If it hasn't been released, the patch will be in:
 
@@ -1617,3 +1617,4 @@
 6956152 dlclose() from an auditor can be fatal. Preinit/activity events should
 	be more flexible. (D)
 6971440 moe can core dump while processing libc.
+6972234 sgs demo's could use some cleanup
--- a/usr/src/cmd/sgs/packages/common/pkginfo.tmpl	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/packages/common/pkginfo.tmpl	Tue Jul 27 22:49:34 2010 -0700
@@ -1,6 +1,4 @@
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 # CDDL HEADER START
 #
@@ -22,7 +20,6 @@
 # CDDL HEADER END
 #
 #
-#
 # This required package information file describes characteristics of the
 # package, such as package abbreviation, full package name, package version,
 # and package architecture.
@@ -40,8 +37,8 @@
 MAXINST="1000"
 CATEGORY="internal"
 DESC="OS-Net Static/Dynamic linker package"
-VENDOR="Sun Microsystems, Inc."
+VENDOR="Oracle Corporation"
 HOTLINE="see email"
-EMAIL="Rod.Evans@Sun.COM Ali.Bahrami@Sun.COM"
+EMAIL="Rod.Evans@Oracle.COM Ali.Bahrami@Oracle.COM"
 CLASSES="none"
 BASEDIR=/
--- a/usr/src/cmd/sgs/packages/common/prototype_com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/packages/common/prototype_com	Tue Jul 27 22:49:34 2010 -0700
@@ -137,7 +137,7 @@
 d none $SGSDIR/usr/demo 755 root bin
 d none $SGSDIR/usr/demo/ELF 755 root bin
 f none $SGSDIR/usr/demo/ELF/Makefile=usr/demo/ELF/Makefile 644 root bin
-f none $SGSDIR/usr/demo/ELF/README=usr/demo/ELF/README 644 root bin
+f none $SGSDIR/usr/demo/ELF/00README=usr/demo/ELF/00README 644 root bin
 f none $SGSDIR/usr/demo/ELF/acom.c=usr/demo/ELF/acom.c 644 root bin
 f none $SGSDIR/usr/demo/ELF/dcom.c=usr/demo/ELF/dcom.c 644 root bin
 f none $SGSDIR/usr/demo/ELF/dispsyms.c=usr/demo/ELF/dispsyms.c 644 root bin
--- a/usr/src/cmd/sgs/rtld/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/rtld/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -24,5 +24,7 @@
 #
 
 include		$(SRC)/cmd/sgs/Makefile.com
-EXTRASUBDIRS=	$(VAR_RTLD_EXTRASUBDIRS)
+
+EXTRASUBDIRS =	mdbmod
+
 include		$(SRC)/cmd/sgs/Makefile.sub
--- a/usr/src/cmd/sgs/rtld/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/rtld/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -73,8 +73,6 @@
 
 FILEMODE =	755
 
-CPPFEATUREMACROS= $(VAR_RTLD_CPPFEATUREMACROS)
-
 CPPFLAGS +=	-I$(SRCBASE)/lib/libc/inc \
 		-I$(SRCBASE)/uts/common/krtld \
 		-I$(SRCBASE)/uts/$(PLAT) \
--- a/usr/src/cmd/sgs/rtld/common/a.out.c	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/rtld/common/a.out.c	Tue Jul 27 22:49:34 2010 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*
@@ -248,7 +248,7 @@
 
 				for (pdp = get_next_dir(&sd, clmp, 0); pdp;
 				    pdp = get_next_dir(&sd, clmp, 0)) {
-					if (pdp->pd_pname == 0)
+					if (pdp->pd_pname == NULL)
 						continue;
 
 					if (path = aout_get_so(pdp->pd_pname,
@@ -282,7 +282,8 @@
 		nlmp = load_one(lml, lmco, palp, clmp, MODE(clmp), 0, 0,
 		    in_nfavl);
 		remove_alist(&palp, 1);
-		if (((nlmp == 0) || (bind_one(clmp, nlmp, BND_NEEDED) == 0)) &&
+		if (((nlmp == NULL) ||
+		    (bind_one(clmp, nlmp, BND_NEEDED) == 0)) &&
 		    ((lml->lm_flags & LML_FLG_TRC_ENABLE) == 0))
 			return (0);
 	}
@@ -322,7 +323,7 @@
 static struct nlist *
 aout_find_com(struct nlist *sp, const char *name)
 {
-	static struct rtc_symb	*rtcp = 0;
+	static struct rtc_symb	*rtcp = NULL;
 	struct rtc_symb		*rs, *trs;
 	const char		*sl;
 	char			*cp;
@@ -419,11 +420,11 @@
 				if (*name++ == '\0')
 					return (sp);	/* found */
 			}
-			if (p->next == 0)
+			if (p->next == NULL)
 				return (NULL);		/* not found */
 			else
 				continue;
-		} while ((p = &LM2LP(lmp)->lp_hash[p->next]) != 0);
+		} while ((p = &LM2LP(lmp)->lp_hash[p->next]) != NULL);
 	}
 	return (NULL);
 }
@@ -483,7 +484,7 @@
 			 * is it a common?
 			 */
 			if (sp->n_type == (N_EXT + N_UNDF)) {
-				if ((sp = aout_find_com(sp, name)) == 0)
+				if ((sp = aout_find_com(sp, name)) == NULL)
 					return (0);
 			}
 			srp->sr_dmap = ilmp;
@@ -542,7 +543,7 @@
 	/*
 	 * Specific settings for a.out format.
 	 */
-	if (lml->lm_head == 0) {
+	if (lml->lm_head == NULL) {
 		base = (caddr_t)MAIN_BASE;
 		FLAGS(lmp) |= FLG_RT_FIXED;
 	} else
@@ -569,7 +570,7 @@
 	AOUTDYN(lmp) = ld;
 
 	if ((RPATH(lmp) = (char *)&base[ld->v2->ld_rules]) == base)
-		RPATH(lmp) = 0;
+		RPATH(lmp) = NULL;
 	LM2LP(lmp)->lp_symbol_base = caddr;
 	/* LINTED */
 	LM2LP(lmp)->lp_plt = (struct jbind *)(&caddr[JMPOFF(ld)]);
@@ -630,7 +631,7 @@
 	else
 		base = ADDR(lmp);
 
-	for (_sym = 0, _value = 0, ndx = 0; ndx < cnt; ndx++, sym++) {
+	for (_sym = NULL, _value = 0, ndx = 0; ndx < cnt; ndx++, sym++) {
 		ulong_t	value;
 
 		if (sym->n_type == (N_EXT + N_UNDF))
@@ -661,7 +662,7 @@
 		 * a symbol entry for AOUT's.
 		 */
 		if (_flags == RTLD_DL_SYMENT)
-			*info = 0;
+			*info = NULL;
 		else if (_flags == RTLD_DL_LINKMAP)
 			*info = (void *)lmp;
 
@@ -718,14 +719,17 @@
  * we don't care, as this can't be relocated, and we're never going to try
  * unmapping the a.out.
  */
+#define	PROCSIZE	20
+
 int
 aout_get_mmap(Lm_list *lml, mmapobj_result_t *mpp)
 {
 	prmap_t	*maps;
-	char	proc[16];
+	char	proc[PROCSIZE];
 	int	num, err, fd;
 
-	(void) snprintf(proc, 16, MSG_ORIG(MSG_FMT_PROC), (int)getpid());
+	(void) snprintf(proc, PROCSIZE, MSG_ORIG(MSG_FMT_PROC),
+	    EC_SWORD(getpid()));
 	if ((fd = open(proc, O_RDONLY)) == -1) {
 		err = errno;
 		eprintf(lml, ERR_FATAL, MSG_INTL(MSG_SYS_OPEN), proc,
--- a/usr/src/cmd/sgs/rtld/i386/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/rtld/i386/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -66,7 +66,7 @@
 ADBGENCFLAGS +=	-erroff=%all
 ADBGENFLAGS +=	-milp32
 ADBSUB=		$(ADBSUB32)
-SONAME=		$(VAR_RTLD_SONAME)
+SONAME=		/lib/ld.so.1
 
 SGSMSGTARG +=	$(SGSMSGINTEL) $(SGSMSGINTEL32) $(SGSMSG32)
 
@@ -74,7 +74,7 @@
 
 all:		$(RTLD)
 
-install:	all $(ROOTDYNLIB) $(VAR_RTLD_ETCDYNLIB)
+install:	all $(ROOTDYNLIB)
 
 lint:		$(LINTOUT32)
 
--- a/usr/src/cmd/sgs/rtld/mdbmod/Makefile.com	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/rtld/mdbmod/Makefile.com	Tue Jul 27 22:49:34 2010 -0700
@@ -19,8 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
+# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
 LIBRARY=	rtld.a
@@ -58,7 +57,6 @@
 DYNLIB=		ld.so
 
 LIBS =		$(DYNLIB) $(LINTLIB)
-$(VAR_POUND_2)LIBS += $(LIBRARY)
 
 # definitions for lint
 
--- a/usr/src/cmd/sgs/rtld/sparc/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/rtld/sparc/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -73,7 +73,7 @@
 ADBGENCFLAGS +=	-erroff=%all
 ADBGENFLAGS +=	-milp32
 ADBSUB=		$(ADBSUB32)
-SONAME=		$(VAR_RTLD_SONAME)
+SONAME=		/lib/ld.so.1
 
 SGSMSGTARG +=	$(SGSMSGSPARC) $(SGSMSGSPARC32) $(SGSMSG32)
 
@@ -81,7 +81,7 @@
 
 all:		$(RTLD)
 
-install:	all $(ROOTDYNLIB) $(VAR_RTLD_ETCDYNLIB)
+install:	all $(ROOTDYNLIB)
 
 lint:		$(LINTOUT32)
 
--- a/usr/src/cmd/sgs/rtld/sparcv9/Makefile	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/cmd/sgs/rtld/sparcv9/Makefile	Tue Jul 27 22:49:34 2010 -0700
@@ -74,7 +74,7 @@
 ADBSUB=		$(ADBSUB64)
 CPPFLAGS +=	-D_ELF64
 LINTFLAGS64 +=	$(VAR_LINTFLAGS64)
-SONAME=		$(VAR_RTLD_V9_SONAME)
+SONAME=		/lib/sparcv9/ld.so.1
 
 SGSMSGTARG +=	$(SGSMSGSPARC) $(SGSMSGSPARC64) $(SGSMSG64)
 
--- a/usr/src/pkg/manifests/source-demo-system.mf	Tue Jul 27 20:35:25 2010 -0400
+++ b/usr/src/pkg/manifests/source-demo-system.mf	Tue Jul 27 22:49:34 2010 -0700
@@ -49,7 +49,7 @@
 dir path=usr/demo/link_audit/man
 dir path=usr/demo/link_audit/src
 file path=usr/demo/ELF/Makefile
-file path=usr/demo/ELF/README
+file path=usr/demo/ELF/00README
 file path=usr/demo/ELF/acom.c
 file path=usr/demo/ELF/dcom.c
 file path=usr/demo/ELF/dispsyms.c