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 9DFD93857C4D for ; Thu, 20 Aug 2020 23:17:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9DFD93857C4D 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-476-6XVO1sHxO0yX8eQik275qg-1; Thu, 20 Aug 2020 19:17:39 -0400 X-MC-Unique: 6XVO1sHxO0yX8eQik275qg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A990C81F027; Thu, 20 Aug 2020 23:17:38 +0000 (UTC) Received: from redhat.com (ovpn-112-64.phx2.redhat.com [10.3.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CC8B5DA60; Thu, 20 Aug 2020 23:17:38 +0000 (UTC) Received: from [127.0.0.1] (helo=vm-rhel7) by redhat.com with esmtp (Exim 4.94) (envelope-from ) id 1k8toP-00035R-6n; Thu, 20 Aug 2020 19:17:37 -0400 From: fche@redhat.com (Frank Ch. Eigler) To: Craig Ringer Cc: systemtap@sourceware.org Subject: Re: Typed locals in functions and probes? Feasibility of language enhancement? Date: Thu, 20 Aug 2020 19:17:24 -0400 References: Message-ID: <87eeo07vqn.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.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, 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: Thu, 20 Aug 2020 23:17:45 -0000 craig wrote: > I find that I write things like this a lot: > > if (foo && (@cast(foo)->bar) > return @cast(foo)->bar->baz > > Because systemtap type-erases locals to long or string, code for member > access gets repetitive fast. I can @define macros for shorthand, but that > only goes so far, and it obfuscates the code a bit. > Is there an accepted pattern for this that I'm missing? Systemtap actually tries to associate some dwarf-based typing with local variables. For example, this works: probe kernel.function("work_busy") { f($work) } function f(w) { ww = & @cast(w,"work_struct"); println(ww->data->counter) } This is due to the "auto-casting" facility added to systemtap back in 2014. I ... can't seem to find the facility actually documented in the stap or stapprobes man page tho. See this bit of the systemtap 2.6 release notes: https://sourceware.org/legacy-ml/systemtap/2014-q3/msg00231.html We could probably start tracking these types across function call parameter-passing boundaries also. Via PR25841, functions called from a probe handler also have some connection to the dwarf context. - FChE