From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 21B673858038 for ; Sun, 10 Jan 2021 17:21:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 21B673858038 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-578-qNNG4X3jOAi1X8v0VgP3gQ-1; Sun, 10 Jan 2021 12:21:00 -0500 X-MC-Unique: qNNG4X3jOAi1X8v0VgP3gQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C099859; Sun, 10 Jan 2021 17:20:59 +0000 (UTC) Received: from redhat.com (ovpn-112-160.phx2.redhat.com [10.3.112.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2F2610013BD; Sun, 10 Jan 2021 17:20:59 +0000 (UTC) Received: from [127.0.0.1] (helo=vm-rhel7) by redhat.com with esmtp (Exim 4.94) (envelope-from ) id 1kyeOg-0004Sj-B1; Sun, 10 Jan 2021 12:20:58 -0500 From: fche@redhat.com (Frank Ch. Eigler) To: David McRay Cc: systemtap@sourceware.org Subject: Re: It's confused that local variable's value not change in function.return probe. Date: Sun, 10 Jan 2021 12:20:42 -0500 References: Message-ID: <87mtxgr9mu.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: systemtap@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Systemtap mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jan 2021 17:21:05 -0000 David McRay wrote: > It's confused that local variable's value not change in function.return > probe. [...] >>>>> running stap <<<< > gcc tests/TestStap.c -O0 -o build/TestStapC -ggdb -gdwarf > > # stap tracker.stp -c ./build/TestStapC > WARNING: confusing usage, consider @entry($a->$) in .return probe: > identifier '$a$' at scripts/track_cplusplus/track_c.stp:11:28 > source: printf("return a: %s\n", $a$) The warning message is on topic. If in a .return probe, you access a general $context variable, this refers to a saved snapshot of the variable as evaluated at function-entry time. See also [man stapprobes] If you wish to look at the fields of a->* -after- the function returns, you can use something like: @cast(@entry(&$a),"Co")$ instead of $a$ which works by saving only the address of $a, and dereferencing/pretty-printing it at return time. ... though we should be able to automate that, in the future, down to @entry(&$a)$ with a little better dwarf type inference. - FChE