Bug 479117

Summary: coregrind/m_debuginfo/readelf.c:1977: variable set but not used
Product: [Developer tools] valgrind Reporter: dcb314
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: minor CC: pjfloyd
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description dcb314 2023-12-28 12:16:10 UTC
A build of today's git head produces this:

m_debuginfo/readelf.c:1977:12: warning: variable ‘has_nonempty_rw’ set but not used [-Wunused-but-set-variable]

A quick check on the variable:

$ grep has_nonempty_rw coregrind/m_debuginfo/readelf.c
      Bool has_nonempty_rw = False;
            has_nonempty_rw = True;
$ 

Maybe some development work in progress or a candidate for deletion.
Comment 1 Paul Floyd 2023-12-29 08:59:27 UTC
I saw this on buildbot and fixed it soon after

commit 671b1082e33659926d4fff42767cdffb48ec103c
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Thu Dec 28 12:08:40 2023 +0100

    Fix unused variable warning

On macOS I see that mach-o binaries can be produced without a RW segment. The code assumed that there was always one (or more). The trigger for reading debuginfo and redirs is that the "right" number of RX and RW segments have been seen. Since the RW condition was wrong the trigger condition was not met.

Now that the RW segment count is correct I had to remove all that asserts that there are at least 1 RW segment.

In this case I put back the assert but modified it with the extra condition that di->fsm.rw_map_count can be zero.