From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 009D81FC0C for ; Tue, 5 Oct 2021 12:48:05 +0000 (UTC) From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 7/7] psgi: show address column Date: Tue, 5 Oct 2021 12:48:03 +0000 Message-Id: <20211005124803.7215-8-e@80x24.org> In-Reply-To: <20211005124803.7215-1-e@80x24.org> References: <20211005124803.7215-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: These addresses are useful for plugging into gdb while gdb is hooked up to a live process. For example: echo 'print (char *)(0xdeadbeef+48)' | gdb -p $PID Will show the pointer part of an SV --- Mwrap.xs | 5 ++--- lib/Devel/Mwrap/PSGI.pm | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Mwrap.xs b/Mwrap.xs index 43d1ed6..bb51930 100644 --- a/Mwrap.xs +++ b/Mwrap.xs @@ -1049,9 +1049,7 @@ CODE: ++locating; rcu_read_lock(); cds_list_for_each_entry_rcu(h, &self->allocs, anode) { - size_t gen = uatomic_read(&h->as.live.gen); size_t size = uatomic_read(&h->size); - if (size > min) { dSP; ENTER; @@ -1065,7 +1063,8 @@ CODE: */ XPUSHs(arg); XPUSHs(sv_2mortal(newSVuv(size))); - XPUSHs(sv_2mortal(newSVuv(gen))); + XPUSHs(sv_2mortal(newSVuv(h->as.live.gen))); + XPUSHs(sv_2mortal(newSVuv((uintptr_t)h->real))); PUTBACK; call_sv(cb, G_DISCARD|G_EVAL); diff --git a/lib/Devel/Mwrap/PSGI.pm b/lib/Devel/Mwrap/PSGI.pm index 52dbebe..12bb929 100644 --- a/lib/Devel/Mwrap/PSGI.pm +++ b/lib/Devel/Mwrap/PSGI.pm @@ -121,8 +121,9 @@ EOM } sub each_at_i { - my ($fh, $size, $gen) = @_; - print $fh "$size$gen\n"; + my ($fh, $size, $gen, $addr) = @_; + print $fh "$size$gen"; + printf $fh "0x%lx\n", $addr; } sub each_at { @@ -134,7 +135,7 @@ sub each_at { print $fh <$t

live allocations at $t

Current age: $age (live: $live)\n - + EOM $src_loc->each(0, \&each_at_i, $fh); print $fh "
sizegeneration
sizegenerationaddress
\n";