From owner-freebsd-dtrace@FreeBSD.ORG Wed Apr 16 02:36:10 2014 Return-Path: Delivered-To: freebsd-dtrace@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 B22F74C1; Wed, 16 Apr 2014 02:36:10 +0000 (UTC) Received: from mail-ie0-x22f.google.com (mail-ie0-x22f.google.com [IPv6:2607:f8b0:4001:c03::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 75C001C78; Wed, 16 Apr 2014 02:36:10 +0000 (UTC) Received: by mail-ie0-f175.google.com with SMTP id to1so9971656ieb.34 for ; Tue, 15 Apr 2014 19:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=eYjp1U+DC+peniCukKCI+KL/YUDlBTVmgudLpVtiFi0=; b=SIO+1SQSonbC8b/TkGLCWotRfmUn2a894XwNF37Fk9BpdpB1asXhvIJXCrmVGIst6f ejTosVPUPs36LgDzOHOZPp2hXU2QCZuYaWm+wnJj21zeFldmK4HQNBUEzIxjhM70N/e0 TjL2AnDHmwZ//rkqqH/wxlyj7FJCqfMMvWRdX6dd1OZ1maAk9WKl8unCvPnEnHS1rKkM F71oQKV5luPTZTNVZO8HaEQQ899VZ0hG8E4C0ncHrPgH2gqrN9YgtK0q58Gp6K9Feic4 D5kH7j+giLxWJfLiRhE4Fr6+PakF6JtnSdPLiNxyAvqUcNMmC/lELzraMFMpgVWIymgt +y0w== MIME-Version: 1.0 X-Received: by 10.50.30.170 with SMTP id t10mr1840254igh.7.1397615769825; Tue, 15 Apr 2014 19:36:09 -0700 (PDT) Sender: markjdb@gmail.com Received: by 10.64.19.241 with HTTP; Tue, 15 Apr 2014 19:36:09 -0700 (PDT) In-Reply-To: References: Date: Tue, 15 Apr 2014 22:36:09 -0400 X-Google-Sender-Auth: 3P0MVpeTjBxSn03kQPwUQoeGoiY Message-ID: Subject: Re: uaddr and friends From: Mark Johnston To: carlos antonio neira bustos Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-dtrace@freebsd.org" X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Apr 2014 02:36:10 -0000 On Tue, Apr 15, 2014 at 10:15 PM, carlos antonio neira bustos wrote: > Hi Mark, > > I was looking at this document > https://wikis.oracle.com/display/DTrace/Actions+and+Subroutines#ActionsandSubroutines-%7B%7Busym%7D%7D > currently looking at the code uaddr is the same as usym, but according to > this document > > usym will print the symbol for a specified address. This is analogous to how > uaddr works, but without the hexadecimal offsets. > > uaddr: date`clock_val+0x1 > usym: date`clock_val > > > here are my outputs from usym and uaddr : > > root@bsd:/home/cneira # dtrace -n 'pid$target::main:{usym(uregs[R_PC])}' -c > ./test > dtrace: description 'pid$target::main:' matched 2 probes > abCPU ID FUNCTION:NAME > 0 56282 main:entry test`main > 0 56281 main:return test`main > dtrace: pid 10588 has exited > > root@bsd:/home/cneira # dtrace -n 'pid$target::main:{uaddr(uregs[R_PC])}' -c > ./test > dtrace: description 'pid$target::main:' matched 2 probes > abCPU ID FUNCTION:NAME > 0 56282 main:entry > test`main+0x1 > > 0 56281 main:return > test`main+0x23 > > dtrace: pid 10591 has exited > > As current is only using dt_print_usym for uaddr the output should not have > the hexadecimal offset specified in that documentation. > So I'm somewhat lost about which is the correct behavior , Do you have a > uaddr and usym output example in current to check this?, all my changes > were done in 10 prod release. You're right, dt_print_usym handles both usym and uaddr. In the usym case, there's some special handling which looks up the symbol name corresponding to the given pc, and then sets the pc variable to the address of the symbol. Then dtrace_uaddr2str only prints the offset from the symbol if that offset is non-zero, so in the uaddr case you get "+0x1" and "+0x23" above. > > Bests > > > > > > > > On Tue, Apr 15, 2014 at 10:09 PM, Mark Johnston wrote: >> >> On Tue, Apr 15, 2014 at 8:35 PM, carlos antonio neira bustos >> wrote: >> > Hi All, >> > >> > I was looking at Dtrace todo list from >> > https://wiki.freebsd.org/DTraceTODO >> > and started to work on : Get uaddr(), ufunc(), umod(), and usym() action >> > funtions working. >> > I have the data recording action (uaddr) working now, here is an >> > example: >> >> Hi! >> >> Hm, these should have been (at least mostly) working since r258902: >> http://svnweb.freebsd.org/base?view=revision&revision=258902 >> >> > >> > root@bsd:/home/cneira # dtrace -n >> > 'pid$target::main:{uaddr(uregs[R_PC])}' >> > -c ./test >> > dtrace: description 'pid$target::main:' matched 2 probes >> > abCPU ID FUNCTION:NAME >> > 0 56282 main:entry >> > test`main+0x1 >> > >> > 0 56281 main:return >> > test`main+0x23 >> > >> > dtrace: pid 9687 has exited >> > >> > Here is the output of nm from the test binary I have used to check this >> > change. >> > >> > U _init_tls@@FBSD_1.0 >> > 08048380 T _start >> > 080483a0 t _start1 >> > 0804814c r abitag >> > U atexit@@FBSD_1.0 >> > 08048164 r crt_noinit_tag >> > 080485c0 T dosomething >> > 08049764 B environ >> > U exit@@FBSD_1.0 >> > 080484f0 t finalizer >> > 08048560 t frame_dummy >> > 08048590 T main >> > U putchar@@FBSD_1.0 >> > >> > >> > root@bsd:/home/cneira # dtrace -c ./test -n 'pid$target::main:entry{ >> > uaddr(0x080485c0); }' >> > dtrace: description 'pid$target::main:entry' matched 1 probe >> > abCPU ID FUNCTION:NAME >> > 0 56281 main:entry >> > test`dosomething >> > >> > dtrace: pid 9736 has exited >> > >> > I'll continue working on the rest, how do I submit a patch with these >> > changes ? >> >> Pasting it inline is generally fine if it's not too large. It's also >> ok to put it in a public directory somewhere and post a link to it. >> >> -Mark > >