From owner-svn-src-all@FreeBSD.ORG Fri Aug 8 14:53:02 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12D523C4 for ; Fri, 8 Aug 2014 14:53:02 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CAEBA2D46 for ; Fri, 8 Aug 2014 14:53:01 +0000 (UTC) Received: from markj (uid 1309) (envelope-from markj@FreeBSD.org) id 241b by svn.freebsd.org (DragonFly Mail Agent v0.9+); Fri, 08 Aug 2014 14:53:01 +0000 From: Mark Johnston Date: Fri, 8 Aug 2014 14:53:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r269720 - stable/10/lib/librtld_db X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53e4e44d.241b.11631af2@svn.freebsd.org> X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Aug 2014 14:53:02 -0000 Author: markj Date: Fri Aug 8 14:53:01 2014 New Revision: 269720 URL: http://svnweb.freebsd.org/changeset/base/269720 Log: MFC r265629, r265630 MFC r265629: Handle the different event types properly in rd_event_addr(). In particular, with r265456 _r_debug_postinit can be used for RD_POSTINIT events. rtld(1) uses r_debug_state for dl state transitions, so we use its address for RD_DLACTIVITY events. MFC r265630: Fix the rd_event_addr prototype and slightly clarify the use of the "event" parameter. Modified: stable/10/lib/librtld_db/librtld_db.3 stable/10/lib/librtld_db/rtld_db.c stable/10/lib/librtld_db/rtld_db.h Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/librtld_db/librtld_db.3 ============================================================================== --- stable/10/lib/librtld_db/librtld_db.3 Fri Aug 8 14:52:59 2014 (r269719) +++ stable/10/lib/librtld_db/librtld_db.3 Fri Aug 8 14:53:01 2014 (r269720) @@ -48,7 +48,7 @@ .Fc .Ft rd_err_e .Fo rd_event_addr -.Fa "rd_agent_t *rdap, rd_notify_t *notify" +.Fa "rd_agent_t *rdap, rd_event_e event, rd_notify_t *notify" .Fc .Ft rd_err_e .Fo rd_event_enable @@ -142,10 +142,10 @@ enables reporting of events. This function always returns RD_OK. .Pp .Fn rd_event_addr -returns the event address in the +returns the event address corresponding to the .Ft event parameter. -At the moment we only report RD_NOTIFY_BPT events. +At the moment we only report events of type RD_NOTIFY_BPT. .Pp .Fn rd_event_getmsg returns the message associated with the latest event. Modified: stable/10/lib/librtld_db/rtld_db.c ============================================================================== --- stable/10/lib/librtld_db/rtld_db.c Fri Aug 8 14:52:59 2014 (r269719) +++ stable/10/lib/librtld_db/rtld_db.c Fri Aug 8 14:53:01 2014 (r269720) @@ -81,20 +81,40 @@ rd_errstr(rd_err_e rderr) } rd_err_e -rd_event_addr(rd_agent_t *rdap, rd_event_e event __unused, rd_notify_t *notify) +rd_event_addr(rd_agent_t *rdap, rd_event_e event, rd_notify_t *notify) { - DPRINTF("%s rdap %p notify %p\n", __func__, rdap, notify); + rd_err_e ret; - notify->type = RD_NOTIFY_BPT; - notify->u.bptaddr = rdap->rda_addr; + DPRINTF("%s rdap %p event %d notify %p\n", __func__, rdap, event, + notify); - return (RD_OK); + ret = RD_OK; + switch (event) { + case RD_NONE: + break; + case RD_PREINIT: + notify->type = RD_NOTIFY_BPT; + notify->u.bptaddr = rdap->rda_preinit_addr; + break; + case RD_POSTINIT: + notify->type = RD_NOTIFY_BPT; + notify->u.bptaddr = rdap->rda_postinit_addr; + break; + case RD_DLACTIVITY: + notify->type = RD_NOTIFY_BPT; + notify->u.bptaddr = rdap->rda_dlactivity_addr; + break; + default: + ret = RD_ERR; + break; + } + return (ret); } rd_err_e rd_event_enable(rd_agent_t *rdap __unused, int onoff) { - DPRINTF("%s onoff %d\n", __func__, onoff); + DPRINTF("%s onoff %d\n", __func__, onoff); return (RD_OK); } @@ -220,7 +240,15 @@ rd_reset(rd_agent_t *rdap) &sym) < 0) return (RD_ERR); DPRINTF("found r_debug_state at 0x%lx\n", (unsigned long)sym.st_value); - rdap->rda_addr = sym.st_value; + rdap->rda_preinit_addr = sym.st_value; + rdap->rda_dlactivity_addr = sym.st_value; + + if (proc_name2sym(rdap->rda_php, "ld-elf.so.1", "_r_debug_postinit", + &sym) < 0) + return (RD_ERR); + DPRINTF("found _r_debug_postinit at 0x%lx\n", + (unsigned long)sym.st_value); + rdap->rda_postinit_addr = sym.st_value; return (RD_OK); } Modified: stable/10/lib/librtld_db/rtld_db.h ============================================================================== --- stable/10/lib/librtld_db/rtld_db.h Fri Aug 8 14:52:59 2014 (r269719) +++ stable/10/lib/librtld_db/rtld_db.h Fri Aug 8 14:53:01 2014 (r269720) @@ -51,7 +51,9 @@ typedef enum { typedef struct rd_agent { struct proc_handle *rda_php; - uintptr_t rda_addr; /* address of r_debug_state */ + uintptr_t rda_dlactivity_addr; + uintptr_t rda_preinit_addr; + uintptr_t rda_postinit_addr; } rd_agent_t; typedef struct rd_loadobj {