From: Philippe Waroquiers Date: Sun, 30 Jun 2024 10:07:11 +0000 (+0200) Subject: Bug 489040 massif trace change to show the location increasing the stack X-Git-Tag: VALGRIND_3_24_0~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7881706947507968772ccef67ebdc7ac7451abc9;p=thirdparty%2Fvalgrind.git Bug 489040 massif trace change to show the location increasing the stack Massif verbose output showing the code location that increases the stack. --- diff --git a/NEWS b/NEWS index 7100b216ee..9583c26e7e 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 488026 Use of `sizeof` instead of `strlen 488379 --track-fds=yes errors that cannot be suppressed with --xml-file= 488441 Add tests for --track-fds=yes --xml=yes and fd suppression tests +489040 massif trace change to show the location increasing the stack To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h index 7631ff67a6..bd03956957 100644 --- a/include/pub_tool_debuginfo.h +++ b/include/pub_tool_debuginfo.h @@ -182,13 +182,13 @@ typedef struct _InlIPCursor InlIPCursor; be done: InlIPCursor *iipc = VG_(new_IIPC)(ep, eip); do { - buf = VG_(describe_IP)(eip, iipc); + buf = VG_(describe_IP)(ep, eip, iipc); ... use buf ... } while (VG_(next_IIPC)(iipc)); VG_(delete_IIPC)(iipc); - To only describe eip, without the inlined calls at eip, give a NULL iipc: - buf = VG_(describe_IP)(eip, NULL); + To only describe eip, without the inlined calls at eip, give a NULL iipc, e.g.: + buf = VG_(describe_IP)(VG_(current_DiEpoch)(), eip, NULL); Note, that the returned string is allocated in a static buffer local to VG_(describe_IP). That buffer will be overwritten with every invocation. diff --git a/massif/docs/ms-manual.xml b/massif/docs/ms-manual.xml index 3dff259952..22941fa522 100644 --- a/massif/docs/ms-manual.xml +++ b/massif/docs/ms-manual.xml @@ -703,6 +703,13 @@ various places online. true, but doing otherwise accurately is difficult. Furthermore, starting at zero better indicates the size of the part of the main stack that a user program actually has control over. + If you give at least 4 verbosity arguments, + then massif produces a trace for each stack increase and decrease. + The stack increase trace contains the IP address that increased the stack. + Note that to get fully precise IP address, you must specify the options + . + diff --git a/massif/ms_main.c b/massif/ms_main.c index f4df6eb16b..0aed0890d2 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -1644,7 +1644,13 @@ static void update_stack_stats(SSizeT stack_szB_delta) static INLINE void new_mem_stack_2(SizeT len, const HChar* what) { if (have_started_executing_code) { - VERB(3, "<<< new_mem_stack (%lu)\n", len); + if (UNLIKELY(VG_(clo_verbosity) > 3)) { + const ThreadId cur_tid = VG_(get_running_tid) (); + const Addr cur_IP = VG_(get_IP) (cur_tid); + VERB(3, "<<< new_mem_stack (%lu) tid %u IP %s\n", + len, cur_tid, + VG_(describe_IP)(VG_(current_DiEpoch)(), cur_IP, NULL)); + } n_stack_allocs++; update_stack_stats(len); maybe_take_snapshot(Normal, what);