--- /dev/null	Mon Aug 26 23:30:17 2013
+++ new/usr/src/cmd/mdb/common/mdb/mdb_gcore.h	Mon Aug 26 23:30:17 2013
@@ -0,0 +1,277 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+/*
+ * Copyright (c) 2013 by Delphix. All rights reserved.
+ */
+
+#ifndef	_MDB_GCORE_H
+#define	_MDB_GCORE_H
+
+/*
+ * The kernel has its own definition of exit which has a different signature
+ * than the user space definition.  This seems to be the standard way to deal
+ * with this.
+ */
+#define	exit kern_exit
+
+#include <sys/cpuvar.h>
+#include <sys/cred_impl.h>
+#include <sys/procfs.h>
+#include <vm/anon.h>
+
+#undef exit
+
+/* mdb versions of kernel structures used for ctf read calls */
+typedef struct mdb_proc {
+	uintptr_t	p_as;
+	uintptr_t	p_brkbase;
+	size_t		p_brksize;
+	uintptr_t	p_usrstack;
+	size_t		p_stksize;
+	user_t		p_user;
+	uintptr_t	p_agenttp;
+	uintptr_t	p_tlist;
+	uintptr_t	p_zone;
+	uintptr_t	p_ldt;
+	kcondvar_t	p_holdlwps;
+	int		p_lwpcnt;
+	uintptr_t	p_lwpdir;
+	uint_t		p_lwpdir_sz;
+	uintptr_t	p_cred;
+	uint_t		p_flag;
+	int		p_zombcnt;
+	uintptr_t	p_pidp;
+	pid_t		p_ppid;
+	uintptr_t	p_pgidp;
+	uintptr_t	p_sessp;
+	uintptr_t	p_task;
+	uintptr_t	p_pool;
+	model_t		p_model;
+	char		p_wcode;
+	ushort_t	p_ldtlimit;
+	uintptr_t	p_exec;
+	uint_t		p_proc_flag;
+	ushort_t	p_pidflag;
+	k_sigset_t	p_ignore;
+	k_sigset_t	p_siginfo;
+	k_sigset_t	p_sig;
+	k_sigset_t	p_sigmask;
+	k_fltset_t	p_fltmask;
+	int		p_wdata;
+} mdb_proc_t;
+
+typedef struct mdb_kthread {
+	ushort_t	t_proc_flag;
+	uint_t		t_state;
+	lwpchan_t	t_lwpchan;
+	ushort_t	t_whystop;
+	uint8_t		t_dtrace_stop;
+	uintptr_t	t_forw;
+	uintptr_t	t_lwp;
+	id_t		t_tid;
+	short		t_sysnum;
+	pri_t		t_pri;
+	time_t		t_start;
+	id_t		t_cid;
+	uintptr_t	t_cpu;
+	int		t_bind_pset;
+	short		t_bind_cpu;
+	uintptr_t	t_lpl;
+	ushort_t	t_schedflag;
+	ushort_t	t_whatstop;
+	k_sigset_t	t_sig;
+	uintptr_t	t_schedctl;
+	k_sigset_t	t_hold;
+	hrtime_t	t_stoptime;
+} mdb_kthread_t;
+
+typedef struct mdb_seg {
+	uintptr_t	s_base;
+	size_t		s_size;
+	uintptr_t	s_ops;
+	uintptr_t	s_data;
+	uintptr_t	s_as;
+} mdb_seg_t;
+
+typedef struct mdb_as {
+	uintptr_t	a_proc;
+} mdb_as_t;
+
+typedef struct mdb_segvn_data {
+	uintptr_t	vp;
+	uint64_t	offset;
+	uint16_t	flags;
+	uint8_t		pageprot;
+	uint8_t		prot;
+	uintptr_t	amp;
+	struct vpage	*vpage;
+	uint64_t	anon_index;
+	uint8_t		type;
+} mdb_segvn_data_t;
+
+typedef struct mdb_vnode {
+	enum vtype	v_type;
+	uintptr_t	v_data;
+	uintptr_t	v_op;
+	uintptr_t	v_path;
+} mdb_vnode_t;
+
+typedef struct mdb_znode {
+	uint64_t	z_size;
+} mdb_znode_t;
+
+typedef struct mdb_tmpnode {
+	vattr_t		tn_attr;
+} mdb_tmpnode_t;
+
+typedef struct mdb_vnodeops {
+	uintptr_t	vnop_name;
+} mdb_vnodeops_t;
+
+typedef struct mdb_shm_data {
+	uintptr_t	shm_sptseg;
+} mdb_shm_data_t;
+
+typedef struct mdb_watched_page {
+	uintptr_t	wp_vaddr;
+	uint8_t		wp_oprot;
+} mdb_watched_page_t;
+
+typedef struct mdb_pid {
+	pid_t		pid_id;
+} mdb_pid_t;
+
+typedef struct mdb_sess {
+	uintptr_t	s_sidp;
+} mdb_sess_t;
+
+typedef struct mdb_task {
+	taskid_t	tk_tkid;
+	uintptr_t	tk_proj;
+} mdb_task_t;
+
+typedef struct mdb_kproject {
+	projid_t	kpj_id;
+} mdb_kproject_t;
+
+typedef struct mdb_zone {
+	zoneid_t	zone_id;
+	uintptr_t	zone_name;
+} mdb_zone_t;
+
+typedef struct mdb_sc_shared {
+	char		sc_sigblock;
+} mdb_sc_shared_t;
+
+typedef struct mdb_klwp {
+	uintptr_t	lwp_regs;
+	struct pcb	lwp_pcb;
+	uchar_t		lwp_asleep;
+	uchar_t		lwp_cursig;
+	uintptr_t	lwp_curinfo;
+	k_siginfo_t	lwp_siginfo;
+	stack_t		lwp_sigaltstack;
+	uintptr_t	lwp_oldcontext;
+	short		lwp_badpriv;
+	uintptr_t	lwp_ustack;
+	char		lwp_eosys;
+} mdb_klwp_t;
+
+typedef struct mdb_cpu {
+	processorid_t	cpu_id;
+} mdb_cpu_t;
+
+typedef struct mdb_lpl {
+	lgrp_id_t	lpl_lgrpid;
+} mdb_lpl_t;
+
+typedef struct mdb_sigqueue {
+	k_siginfo_t	sq_info;
+} mdb_sigqueue_t;
+
+typedef struct mdb_pool {
+	poolid_t	pool_id;
+} mdb_pool_t;
+
+typedef struct mdb_amp {
+	uintptr_t	ahp;
+} mdb_amp_t;
+
+typedef struct mdb_anon_hdr {
+	pgcnt_t		size;
+	uintptr_t	array_chunk;
+	int		flags;
+} mdb_anon_hdr_t;
+
+typedef struct mdb_anon {
+	uintptr_t	an_vp;
+	anoff_t		an_off;
+} mdb_anon_t;
+
+/* Used to construct a linked list of prmap_ts */
+typedef struct prmap_node {
+	struct prmap_node *next;
+	prmap_t		m;
+} prmap_node_t;
+
+/* Fields common to psinfo_t and pstatus_t */
+typedef struct pcommon {
+	int		pc_nlwp;
+	int		pc_nzomb;
+	pid_t		pc_pid;
+	pid_t		pc_ppid;
+	pid_t		pc_pgid;
+	pid_t		pc_sid;
+	taskid_t	pc_taskid;
+	projid_t	pc_projid;
+	zoneid_t	pc_zoneid;
+	char		pc_dmodel;
+} pcommon_t;
+
+/* AVL walk callback structures */
+typedef struct read_maps_cbarg {
+	mdb_proc_t	*p;
+	uintptr_t	brkseg;
+	uintptr_t	stkseg;
+	prmap_node_t	*map_head;
+	prmap_node_t	*map_tail;
+	int		map_len;
+} read_maps_cbarg_t;
+
+typedef struct as_segat_cbarg {
+	uintptr_t	addr;
+	uintptr_t	res;
+} as_segat_cbarg_t;
+
+typedef struct getwatchprot_cbarg {
+	uintptr_t	wp_vaddr;
+	mdb_watched_page_t wp;
+	boolean_t	found;
+} getwatchprot_cbarg_t;
+
+struct gcore_segops;
+typedef struct gcore_seg {
+	mdb_seg_t	*gs_seg;
+	void		*gs_data;
+	struct gcore_segops *gs_ops;
+} gcore_seg_t;
+
+/*
+ * These are the ISA-dependent functions that need to be
+ * implemented for ::gcore.
+ */
+extern uintptr_t gcore_prgetstackbase(mdb_proc_t *);
+extern int gcore_prfetchinstr(mdb_klwp_t *, ulong_t *);
+extern int gcore_prisstep(mdb_klwp_t *);
+extern void gcore_getgregs(mdb_klwp_t *, gregset_t);
+extern int gcore_prgetrvals(mdb_klwp_t *, long *, long *);
+
+#endif	/* _MDB_GCORE_H */
--- old/usr/src/cmd/mdb/common/modules/genunix/Makefile.files	Mon Aug 26 23:30:18 2013
+++ new/usr/src/cmd/mdb/common/modules/genunix/Makefile.files	Mon Aug 26 23:30:18 2013
@@ -48,6 +48,7 @@
 	findstack_subr.c \
 	fm.c		\
 	gcore.c		\
+	gcore_isadep.c	\
 	genunix.c	\
 	group.c		\
 	hotplug.c	\
--- old/usr/src/cmd/mdb/common/modules/genunix/gcore.c	Mon Aug 26 23:30:19 2013
+++ new/usr/src/cmd/mdb/common/modules/genunix/gcore.c	Mon Aug 26 23:30:19 2013
@@ -21,7 +21,8 @@
  * (missing data is documented in function headers) but there is enough
  * information to generate a core file that can be loaded into mdb.
  *
- * Currently only x86 is supported!
+ * Currently only x86 is supported. ISA-dependent functions are implemented
+ * in gcore_isadep.c.
  */
 
 #ifndef _KMDB
@@ -38,11 +39,11 @@
 #include <mdb/mdb_ks.h>
 #include <mdb/mdb_ctf.h>
 #include <mdb/mdb_debug.h>
+#include <mdb/mdb_gcore.h>
 
 #include <sys/class.h>
 #include <sys/cpuvar.h>
 #include <sys/proc.h>
-#include <sys/cred_impl.h>
 #include <sys/lgrp.h>
 #include <sys/pool.h>
 #include <sys/project.h>
@@ -53,9 +54,7 @@
 #include <sys/task.h>
 #include <sys/var.h>
 #include <sys/privregs.h>
-#include <sys/psw.h>
 #include <sys/fault.h>
-#include <sys/procfs.h>
 #include <sys/sysmacros.h>
 #include <sys/wait.h>
 #include <vm/seg.h>
@@ -101,241 +100,6 @@
 #define	dprintf(...)
 #endif
 
-/* mdb versions of kernel structures used for ctf read calls */
-typedef struct mdb_proc {
-	uintptr_t	p_as;
-	uintptr_t	p_brkbase;
-	size_t		p_brksize;
-	uintptr_t	p_usrstack;
-	size_t		p_stksize;
-	user_t		p_user;
-	uintptr_t	p_agenttp;
-	uintptr_t	p_tlist;
-	uintptr_t	p_zone;
-	uintptr_t	p_ldt;
-	kcondvar_t	p_holdlwps;
-	int		p_lwpcnt;
-	uintptr_t	p_lwpdir;
-	uint_t		p_lwpdir_sz;
-	uintptr_t	p_cred;
-	uint_t		p_flag;
-	int		p_zombcnt;
-	uintptr_t	p_pidp;
-	pid_t		p_ppid;
-	uintptr_t	p_pgidp;
-	uintptr_t	p_sessp;
-	uintptr_t	p_task;
-	uintptr_t	p_pool;
-	model_t		p_model;
-	char		p_wcode;
-	ushort_t	p_ldtlimit;
-	uintptr_t	p_exec;
-	uint_t		p_proc_flag;
-	ushort_t	p_pidflag;
-	k_sigset_t	p_ignore;
-	k_sigset_t	p_siginfo;
-	k_sigset_t	p_sig;
-	k_sigset_t	p_sigmask;
-	k_fltset_t	p_fltmask;
-	int		p_wdata;
-} mdb_proc_t;
-
-typedef struct mdb_kthread {
-	ushort_t	t_proc_flag;
-	uint_t		t_state;
-	lwpchan_t	t_lwpchan;
-	ushort_t	t_whystop;
-	uint8_t		t_dtrace_stop;
-	uintptr_t	t_forw;
-	uintptr_t	t_lwp;
-	id_t		t_tid;
-	short		t_sysnum;
-	pri_t		t_pri;
-	time_t		t_start;
-	id_t		t_cid;
-	uintptr_t	t_cpu;
-	int		t_bind_pset;
-	short		t_bind_cpu;
-	uintptr_t	t_lpl;
-	ushort_t	t_schedflag;
-	ushort_t	t_whatstop;
-	k_sigset_t	t_sig;
-	uintptr_t	t_schedctl;
-	k_sigset_t	t_hold;
-	hrtime_t	t_stoptime;
-} mdb_kthread_t;
-
-typedef struct mdb_seg {
-	uintptr_t	s_base;
-	size_t		s_size;
-	uintptr_t	s_ops;
-	uintptr_t	s_data;
-	uintptr_t	s_as;
-} mdb_seg_t;
-
-typedef struct mdb_as {
-	uintptr_t	a_proc;
-} mdb_as_t;
-
-typedef struct mdb_segvn_data {
-	uintptr_t	vp;
-	uint64_t	offset;
-	uint16_t	flags;
-	uint8_t		pageprot;
-	uint8_t		prot;
-	uintptr_t	amp;
-	struct vpage	*vpage;
-	uint64_t	anon_index;
-	uint8_t		type;
-} mdb_segvn_data_t;
-
-typedef struct mdb_vnode {
-	enum vtype	v_type;
-	uintptr_t	v_data;
-	uintptr_t	v_op;
-	uintptr_t	v_path;
-} mdb_vnode_t;
-
-typedef struct mdb_znode {
-	uint64_t	z_size;
-} mdb_znode_t;
-
-typedef struct mdb_tmpnode {
-	vattr_t		tn_attr;
-} mdb_tmpnode_t;
-
-typedef struct mdb_vnodeops {
-	uintptr_t	vnop_name;
-} mdb_vnodeops_t;
-
-typedef struct mdb_shm_data {
-	uintptr_t	shm_sptseg;
-} mdb_shm_data_t;
-
-typedef struct mdb_watched_page {
-	uintptr_t	wp_vaddr;
-	uint8_t		wp_oprot;
-} mdb_watched_page_t;
-
-typedef struct mdb_pid {
-	pid_t		pid_id;
-} mdb_pid_t;
-
-typedef struct mdb_sess {
-	uintptr_t	s_sidp;
-} mdb_sess_t;
-
-typedef struct mdb_task {
-	taskid_t	tk_tkid;
-	uintptr_t	tk_proj;
-} mdb_task_t;
-
-typedef struct mdb_kproject {
-	projid_t	kpj_id;
-} mdb_kproject_t;
-
-typedef struct mdb_zone {
-	zoneid_t	zone_id;
-	uintptr_t	zone_name;
-} mdb_zone_t;
-
-typedef struct mdb_sc_shared {
-	char		sc_sigblock;
-} mdb_sc_shared_t;
-
-typedef struct mdb_klwp {
-	uintptr_t	lwp_regs;
-	struct pcb	lwp_pcb;
-	uchar_t		lwp_asleep;
-	uchar_t		lwp_cursig;
-	uintptr_t	lwp_curinfo;
-	k_siginfo_t	lwp_siginfo;
-	stack_t		lwp_sigaltstack;
-	uintptr_t	lwp_oldcontext;
-	short		lwp_badpriv;
-	uintptr_t	lwp_ustack;
-	char		lwp_eosys;
-} mdb_klwp_t;
-
-typedef struct mdb_cpu {
-	processorid_t	cpu_id;
-} mdb_cpu_t;
-
-typedef struct mdb_lpl {
-	lgrp_id_t	lpl_lgrpid;
-} mdb_lpl_t;
-
-typedef struct mdb_sigqueue {
-	k_siginfo_t	sq_info;
-} mdb_sigqueue_t;
-
-typedef struct mdb_pool {
-	poolid_t	pool_id;
-} mdb_pool_t;
-
-typedef struct mdb_amp {
-	uintptr_t	ahp;
-} mdb_amp_t;
-
-typedef struct mdb_anon_hdr {
-	pgcnt_t		size;
-	uintptr_t	array_chunk;
-	int		flags;
-} mdb_anon_hdr_t;
-
-typedef struct mdb_anon {
-	uintptr_t	an_vp;
-	anoff_t		an_off;
-} mdb_anon_t;
-
-/* Used to construct a linked list of prmap_ts */
-typedef struct prmap_node {
-	struct prmap_node *next;
-	prmap_t		m;
-} prmap_node_t;
-
-/* Fields common to psinfo_t and pstatus_t */
-typedef struct pcommon {
-	int		pc_nlwp;
-	int		pc_nzomb;
-	pid_t		pc_pid;
-	pid_t		pc_ppid;
-	pid_t		pc_pgid;
-	pid_t		pc_sid;
-	taskid_t	pc_taskid;
-	projid_t	pc_projid;
-	zoneid_t	pc_zoneid;
-	char		pc_dmodel;
-} pcommon_t;
-
-/* AVL walk callback structures */
-typedef struct read_maps_cbarg {
-	mdb_proc_t	*p;
-	uintptr_t	brkseg;
-	uintptr_t	stkseg;
-	prmap_node_t	*map_head;
-	prmap_node_t	*map_tail;
-	int		map_len;
-} read_maps_cbarg_t;
-
-typedef struct as_segat_cbarg {
-	uintptr_t	addr;
-	uintptr_t	res;
-} as_segat_cbarg_t;
-
-typedef struct getwatchprot_cbarg {
-	uintptr_t	wp_vaddr;
-	mdb_watched_page_t wp;
-	boolean_t	found;
-} getwatchprot_cbarg_t;
-
-struct gcore_segops;
-typedef struct gcore_seg {
-	mdb_seg_t	*gs_seg;
-	void		*gs_data;
-	struct gcore_segops *gs_ops;
-} gcore_seg_t;
-
 /* Callback function type for processing lwp entries */
 typedef int (*lwp_callback_t)(mdb_proc_t *, lwpent_t *, void *);
 
@@ -724,13 +488,6 @@
 	return (gcore_as_segat(p->p_as, addr));
 }
 
-/* ISA dependent function. */
-static uintptr_t
-gcore_prgetstackbase(mdb_proc_t *p)
-{
-	return (p->p_usrstack - p->p_stksize);
-}
-
 static u_offset_t
 gcore_vnode_size(uintptr_t vnode_addr)
 {
@@ -1385,96 +1142,6 @@
 	}
 }
 
-/* ISA dependent function. */
-static int
-gcore_prfetchinstr(mdb_klwp_t *lwp, ulong_t *ip)
-{
-	*ip = (ulong_t)(instr_t)lwp->lwp_pcb.pcb_instr;
-	return (lwp->lwp_pcb.pcb_flags & INSTR_VALID);
-}
-
-/* ISA dependent function. */
-static int
-gcore_prisstep(mdb_klwp_t *lwp)
-{
-	return ((lwp->lwp_pcb.pcb_flags &
-	    (NORMAL_STEP|WATCH_STEP|DEBUG_PENDING)) != 0);
-}
-
-/* ISA dependent function. */
-static void
-gcore_getgregs(mdb_klwp_t *lwp, gregset_t grp)
-{
-	struct regs rgs;
-	struct regs *rp;
-
-	if (mdb_vread(&rgs, sizeof (rgs), lwp->lwp_regs) != sizeof (rgs)) {
-		mdb_warn("Failed to read regs from %p\n", lwp->lwp_regs);
-		return;
-	}
-	rp = &rgs;
-
-#if defined(__amd64)
-	struct pcb *pcb = &lwp->lwp_pcb;
-
-	grp[REG_RDI] = rp->r_rdi;
-	grp[REG_RSI] = rp->r_rsi;
-	grp[REG_RDX] = rp->r_rdx;
-	grp[REG_RCX] = rp->r_rcx;
-	grp[REG_R8] = rp->r_r8;
-	grp[REG_R9] = rp->r_r9;
-	grp[REG_RAX] = rp->r_rax;
-	grp[REG_RBX] = rp->r_rbx;
-	grp[REG_RBP] = rp->r_rbp;
-	grp[REG_R10] = rp->r_r10;
-	grp[REG_R11] = rp->r_r11;
-	grp[REG_R12] = rp->r_r12;
-	grp[REG_R13] = rp->r_r13;
-	grp[REG_R14] = rp->r_r14;
-	grp[REG_R15] = rp->r_r15;
-	grp[REG_FSBASE] = pcb->pcb_fsbase;
-	grp[REG_GSBASE] = pcb->pcb_gsbase;
-	if (pcb->pcb_rupdate == 1) {
-		grp[REG_DS] = pcb->pcb_ds;
-		grp[REG_ES] = pcb->pcb_es;
-		grp[REG_FS] = pcb->pcb_fs;
-		grp[REG_GS] = pcb->pcb_gs;
-	} else {
-		grp[REG_DS] = rp->r_ds;
-		grp[REG_ES] = rp->r_es;
-		grp[REG_FS] = rp->r_fs;
-		grp[REG_GS] = rp->r_gs;
-	}
-	grp[REG_TRAPNO] = rp->r_trapno;
-	grp[REG_ERR] = rp->r_err;
-	grp[REG_RIP] = rp->r_rip;
-	grp[REG_CS] = rp->r_cs;
-	grp[REG_SS] = rp->r_ss;
-	grp[REG_RFL] = rp->r_rfl;
-	grp[REG_RSP] = rp->r_rsp;
-#else
-	bcopy(&rp->r_gs, grp, sizeof (gregset_t));
-#endif
-}
-
-/* ISA dependent functions. */
-static int
-gcore_prgetrvals(mdb_klwp_t *lwp, long *rval1, long *rval2)
-{
-	struct regs *r = lwptoregs(lwp);
-
-	if (r->r_ps & PS_C)
-		return (r->r_r0);
-	if (lwp->lwp_eosys == JUSTRETURN) {
-		*rval1 = 0;
-		*rval2 = 0;
-	} else {
-		*rval1 = r->r_r0;
-		*rval2 = r->r_r1;
-	}
-	return (0);
-}
-
 static void
 gcore_prgetprregs(mdb_klwp_t *lwp, prgregset_t prp)
 {
--- old/usr/src/cmd/mdb/intel/amd64/genunix/Makefile	Mon Aug 26 23:30:20 2013
+++ new/usr/src/cmd/mdb/intel/amd64/genunix/Makefile	Mon Aug 26 23:30:20 2013
@@ -76,3 +76,5 @@
 CERRWARN += -_gcc=-Wno-type-limits
 
 LINTFLAGS64 += -erroff=E_EMPTY_TRANSLATION_UNIT
+
+MODSRCS_DIR = ../../../intel/modules/genunix
--- old/usr/src/cmd/mdb/intel/ia32/genunix/Makefile	Mon Aug 26 23:30:22 2013
+++ new/usr/src/cmd/mdb/intel/ia32/genunix/Makefile	Mon Aug 26 23:30:22 2013
@@ -73,3 +73,5 @@
 CERRWARN += -_gcc=-Wno-type-limits
 
 LINTFLAGS += -erroff=E_EMPTY_TRANSLATION_UNIT
+
+MODSRCS_DIR = ../../../intel/modules/genunix
--- /dev/null	Mon Aug 26 23:30:23 2013
+++ new/usr/src/cmd/mdb/intel/modules/genunix/gcore_isadep.c	Mon Aug 26 23:30:23 2013
@@ -0,0 +1,112 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+/*
+ * Copyright (c) 2013 by Delphix. All rights reserved.
+ */
+
+#include <mdb/mdb_modapi.h>
+#include <mdb/mdb_gcore.h>
+#include <mdb/mdb_debug.h>
+
+#include <sys/psw.h>
+#include <sys/privregs.h>
+
+uintptr_t
+gcore_prgetstackbase(mdb_proc_t *p)
+{
+	return (p->p_usrstack - p->p_stksize);
+}
+
+int
+gcore_prfetchinstr(mdb_klwp_t *lwp, ulong_t *ip)
+{
+	*ip = (ulong_t)(instr_t)lwp->lwp_pcb.pcb_instr;
+	return (lwp->lwp_pcb.pcb_flags & INSTR_VALID);
+}
+
+int
+gcore_prisstep(mdb_klwp_t *lwp)
+{
+	return ((lwp->lwp_pcb.pcb_flags &
+	    (NORMAL_STEP|WATCH_STEP|DEBUG_PENDING)) != 0);
+}
+
+void
+gcore_getgregs(mdb_klwp_t *lwp, gregset_t grp)
+{
+	struct regs rgs;
+	struct regs *rp;
+
+	if (mdb_vread(&rgs, sizeof (rgs), lwp->lwp_regs) != sizeof (rgs)) {
+		mdb_warn("Failed to read regs from %p\n", lwp->lwp_regs);
+		return;
+	}
+	rp = &rgs;
+
+#if defined(__amd64)
+	struct pcb *pcb = &lwp->lwp_pcb;
+
+	grp[REG_RDI] = rp->r_rdi;
+	grp[REG_RSI] = rp->r_rsi;
+	grp[REG_RDX] = rp->r_rdx;
+	grp[REG_RCX] = rp->r_rcx;
+	grp[REG_R8] = rp->r_r8;
+	grp[REG_R9] = rp->r_r9;
+	grp[REG_RAX] = rp->r_rax;
+	grp[REG_RBX] = rp->r_rbx;
+	grp[REG_RBP] = rp->r_rbp;
+	grp[REG_R10] = rp->r_r10;
+	grp[REG_R11] = rp->r_r11;
+	grp[REG_R12] = rp->r_r12;
+	grp[REG_R13] = rp->r_r13;
+	grp[REG_R14] = rp->r_r14;
+	grp[REG_R15] = rp->r_r15;
+	grp[REG_FSBASE] = pcb->pcb_fsbase;
+	grp[REG_GSBASE] = pcb->pcb_gsbase;
+	if (pcb->pcb_rupdate == 1) {
+		grp[REG_DS] = pcb->pcb_ds;
+		grp[REG_ES] = pcb->pcb_es;
+		grp[REG_FS] = pcb->pcb_fs;
+		grp[REG_GS] = pcb->pcb_gs;
+	} else {
+		grp[REG_DS] = rp->r_ds;
+		grp[REG_ES] = rp->r_es;
+		grp[REG_FS] = rp->r_fs;
+		grp[REG_GS] = rp->r_gs;
+	}
+	grp[REG_TRAPNO] = rp->r_trapno;
+	grp[REG_ERR] = rp->r_err;
+	grp[REG_RIP] = rp->r_rip;
+	grp[REG_CS] = rp->r_cs;
+	grp[REG_SS] = rp->r_ss;
+	grp[REG_RFL] = rp->r_rfl;
+	grp[REG_RSP] = rp->r_rsp;
+#else
+	bcopy(&rp->r_gs, grp, sizeof (gregset_t));
+#endif
+}
+
+int
+gcore_prgetrvals(mdb_klwp_t *lwp, long *rval1, long *rval2)
+{
+	struct regs *r = lwptoregs(lwp);
+
+	if (r->r_ps & PS_C)
+		return (r->r_r0);
+	if (lwp->lwp_eosys == JUSTRETURN) {
+		*rval1 = 0;
+		*rval2 = 0;
+	} else {
+		*rval1 = r->r_r0;
+		*rval2 = r->r_r1;
+	}
+	return (0);
+}
--- /dev/null	Mon Aug 26 23:30:23 2013
+++ new/usr/src/cmd/mdb/sparc/modules/genunix/gcore_isadep.c	Mon Aug 26 23:30:23 2013
@@ -0,0 +1,49 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+/*
+ * Copyright (c) 2013 by Delphix. All rights reserved.
+ */
+
+/*
+ * ::gcore is not supported on sparc, so these functions are not
+ * implemented.
+ */
+
+#ifndef _KMDB
+
+#include <mdb/mdb_gcore.h>
+
+uintptr_t
+gcore_prgetstackbase(mdb_proc_t *p)
+{
+}
+
+int
+gcore_prfetchinstr(mdb_klwp_t *lwp, ulong_t *ip)
+{
+}
+
+int
+gcore_prisstep(mdb_klwp_t *lwp)
+{
+}
+
+void
+gcore_getgregs(mdb_klwp_t *lwp, gregset_t grp)
+{
+}
+
+int
+gcore_prgetrvals(mdb_klwp_t *lwp, long *rval1, long *rval2)
+{
+}
+
+#endif /* _KMDB */
--- old/usr/src/cmd/mdb/sparc/v9/genunix/Makefile	Mon Aug 26 23:30:24 2013
+++ new/usr/src/cmd/mdb/sparc/v9/genunix/Makefile	Mon Aug 26 23:30:24 2013
@@ -70,3 +70,5 @@
 CERRWARN += -_gcc=-Wno-uninitialized
 CERRWARN += -_gcc=-Wno-parentheses
 CERRWARN += -_gcc=-Wno-type-limits
+
+MODSRCS_DIR = ../../../sparc/modules/genunix
--- old/usr/src/lib/libproc/common/Pservice.c	Mon Aug 26 23:30:25 2013
+++ new/usr/src/lib/libproc/common/Pservice.c	Mon Aug 26 23:30:25 2013
@@ -176,10 +176,11 @@
 	struct stat statb;
 
 	if (P->state == PS_DEAD) {
-		lwp_info_t *lwp = list_next(&P->core->core_lwp_head);
+		core_info_t *core = P->data;
+		lwp_info_t *lwp = list_next(&core->core_lwp_head);
 		uint_t i;
 
-		for (i = 0; i < P->core->core_nlwp; i++, lwp = list_next(lwp)) {
+		for (i = 0; i < core->core_nlwp; i++, lwp = list_next(lwp)) {
 			if (lwp->lwp_id == lwpid) {
 				if (lwp->lwp_xregs != NULL)
 					*xrsize = sizeof (prxregset_t);
--- old/usr/src/lib/libproc/sparc/Pisadep.c	Mon Aug 26 23:30:26 2013
+++ new/usr/src/lib/libproc/sparc/Pisadep.c	Mon Aug 26 23:30:26 2013
@@ -187,11 +187,12 @@
 	gwin_query_t gq;
 
 	if (P->state == PS_DEAD) {
-		lwp_info_t *lwp = list_next(&P->core->core_lwp_head);
+		core_info_t *core = P->data;
+		lwp_info_t *lwp = list_next(&core->core_lwp_head);
 		uint_t n;
 		int i;
 
-		for (n = 0; n < P->core->core_nlwp; n++, lwp = list_next(lwp)) {
+		for (n = 0; n < core->core_nlwp; n++, lwp = list_next(lwp)) {
 			gwindows_t *gwin = lwp->lwp_gwins;
 
 			if (gwin == NULL)
--- old/usr/src/lib/libproc/sparcv9/Pisadep.c	Mon Aug 26 23:30:27 2013
+++ new/usr/src/lib/libproc/sparcv9/Pisadep.c	Mon Aug 26 23:30:27 2013
@@ -235,11 +235,12 @@
 	gwin_query_t gq;
 
 	if (P->state == PS_DEAD) {
-		lwp_info_t *lwp = list_next(&P->core->core_lwp_head);
+		core_info_t *core = P->data;
+		lwp_info_t *lwp = list_next(&core->core_lwp_head);
 		uint_t n;
 		int i;
 
-		for (n = 0; n < P->core->core_nlwp; n++, lwp = list_next(lwp)) {
+		for (n = 0; n < core->core_nlwp; n++, lwp = list_next(lwp)) {
 			gwindows_t *gwin = lwp->lwp_gwins;
 
 			if (gwin == NULL)
