Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Aug 2014 21:41:01 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r269532 - in stable/9/sys/cddl: contrib/opensolaris/uts/intel/dtrace dev/dtrace/amd64
Message-ID:  <53dffded.5d1d.70321ffb@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Mon Aug  4 21:41:01 2014
New Revision: 269532
URL: http://svnweb.freebsd.org/changeset/base/269532

Log:
  MFC r256822:
  When fetching function arguments out of a frame on amd64, explicitly select
  the register based on the argument index rather than relying on the fields
  in struct reg to be in the right order. This assumption is incorrect on
  FreeBSD and generally led to bogus argument values for the sixth argument
  of PID and USDT probes; the first five are passed directly to dtrace_probe()
  via the fasttrap trap handler and so were correctly handled.

Modified:
  stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
  stable/9/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)

Modified: stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Mon Aug  4 21:41:00 2014	(r269531)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Mon Aug  4 21:41:01 2014	(r269532)
@@ -273,7 +273,20 @@ fasttrap_anarg(struct reg *rp, int funct
 		 * registers.
 		 */
 		if (argno < 6)
-			return ((&rp->r_rdi)[argno]);
+			switch (argno) {
+			case 0:
+				return (rp->r_rdi);
+			case 1:
+				return (rp->r_rsi);
+			case 2:
+				return (rp->r_rdx);
+			case 3:
+				return (rp->r_rcx);
+			case 4:
+				return (rp->r_r8);
+			case 5:
+				return (rp->r_r9);
+			}
 
 		stack = (uintptr_t *)rp->r_rsp;
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);

Modified: stable/9/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
==============================================================================
--- stable/9/sys/cddl/dev/dtrace/amd64/dtrace_isa.c	Mon Aug  4 21:41:00 2014	(r269531)
+++ stable/9/sys/cddl/dev/dtrace/amd64/dtrace_isa.c	Mon Aug  4 21:41:01 2014	(r269532)
@@ -367,7 +367,27 @@ dtrace_getarg(int arg, int aframes)
 			    sizeof (uintptr_t));
 
 			if (arg <= inreg) {
-				stack = (uintptr_t *)&rp->r_rdi;
+				switch (arg) {
+				case 0:
+					stack = (uintptr_t *)&rp->r_rdi;
+					break;
+				case 1:
+					stack = (uintptr_t *)&rp->r_rsi;
+					break;
+				case 2:
+					stack = (uintptr_t *)&rp->r_rdx;
+					break;
+				case 3:
+					stack = (uintptr_t *)&rp->r_rcx;
+					break;
+				case 4:
+					stack = (uintptr_t *)&rp->r_r8;
+					break;
+				case 5:
+					stack = (uintptr_t *)&rp->r_r9;
+					break;
+				}
+				arg = 0;
 			} else {
 				stack = (uintptr_t *)(rp->r_rsp);
 				arg -= inreg;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53dffded.5d1d.70321ffb>