From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by sourceware.org (Postfix) with ESMTPS id 1CCF9389C420 for ; Wed, 6 Jan 2021 06:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1CCF9389C420 Received: by mail-yb1-xb31.google.com with SMTP id f6so1854612ybq.13 for ; Tue, 05 Jan 2021 22:40:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=H+mYAjY41GooIbeFS9iJ5y9YbpmCbVhCcf20Up9mhOk=; b=epVM0LyLkOSuSqttcgeEneDe2Z//G/QblEMr6iPjzWRi8wQbSvZ+lbcPaPN66U3Xjl S3WcKjo1cTAncmhYzBBnssvcVYdSPrGQhmVpCTzyNGYm+K7ACNMIaxEtA/t/NZcyimBF SHKlFQDsYMEbBM7uKicArJR3heDLVRDNkxg6W2b/CU2S7xwRDhRmJDVGQFANrgXTBjFG RYebsYzNYC1tw/qGQxUoE4sR8GDjW8HqGsUjiJ8TqN7VaC1r7i3+vjmTlg/BtonzguC1 aIV7rvFzNPgKyyBZaTj8MrdE6TYgkRA5irUDG8odGbcfBncMI8Xrsm/1MHRtdbWWs1rh 3BtQ== X-Gm-Message-State: AOAM5308xTbeOU5RUdhPh42hidMuMt6QiyKQDuo2lULVtDyHj97Pb3tM fSoVtGb8XbVa+ehkYTHd/8P20WeiC/sZ0dSRokE6nTz9E8u7hdXs X-Google-Smtp-Source: ABdhPJxBRxFvEAvBY6vUYgNH6Pa4ZyvB852NfMGER47yQAqT1Lajx6XCCDRG861ccvYwc5PN9YxLkiEZDs6OwyR+uGc= X-Received: by 2002:a25:2cd6:: with SMTP id s205mr4195863ybs.279.1609915237491; Tue, 05 Jan 2021 22:40:37 -0800 (PST) MIME-Version: 1.0 From: David McRay Date: Wed, 6 Jan 2021 14:40:26 +0800 Message-ID: Subject: It's confused that local variable's value not change in function.return probe. To: systemtap@sourceware.org X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Wed, 06 Jan 2021 06:40:39 -0000 It's confused that local variable's value not change in function.return probe. I need to track a function behavior of my userspace program, so two probe (function.call and function.return) are setted up. In function I would change the value of a variable, but in function.call and function.return I found the value of the variable are just the same as it is before this function is called. BUT the value should be changed at return moment. Below is a sample demonstrate that. Is there something wrong or it's as expected ? >>>>> TestStap.c <<<< #include #include struct Co { int id_; char* data_; }; void setmbuf(const char *str); void Run (struct Co* a) { printf("before: %2d %s\n", a->id_, a->data_); a->id_ = -1; // change the value! setmbuf("kkkkkkk"); // change the value! printf("after : %2d %s\n", a->id_, a->data_); } char buf[100]; void setmbuf(const char *str) { int i = 0; int l = strlen(str) - 1; for (i = 0; i <= l; i++) { buf[i] = str[i]; } buf[i] = '\0'; } int main() { struct Co a; a.id_ = 0; a.data_ = buf; setmbuf("aaaaaa"); Run(&a); return 0; } >>> tracker.stp <<< probe begin { printf ("probe begin: pid is %d\n", pid()) } probe end { printf ("probe end\n") } probe process("build/TestStapC").function("Run@tests/TestStap.c").call { printf("call a: %s\n", $a$) } probe process("build/TestStapC").function("Run@tests/TestStap.c").return { printf("return a: %s\n", $a$) } >>>> 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$) ^ before: 0 aaaaaa after : -1 kkkkkkk probe begin: pid is 387944 call a: {.id_=0, .data_="aaaaaa"} return a: {.id_=0, .data_="aaaaaa"} probe end