From: Andrew Burgess Date: Wed, 7 May 2025 09:09:43 +0000 (+0100) Subject: gdb: use bool more in linux-tdep.c X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6703aa6c7d60c9b24a475fdf52ea1ce1baf7ac19;p=thirdparty%2Fbinutils-gdb.git gdb: use bool more in linux-tdep.c Convert linux_dump_mapping_p_ftype to return a bool, and then update everything that is needed to handle the fallout from this change. There should be no user visible changes from this commit. Approved-By: Simon Marchi --- diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index bbffb3d1c90..c2667cf86bd 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -630,9 +630,9 @@ mapping_is_anonymous_p (const char *filename) return 0; } -/* Return 0 if the memory mapping (which is related to FILTERFLAGS, V, +/* Return false if the memory mapping (which is related to FILTERFLAGS, V, MAYBE_PRIVATE_P, MAPPING_ANONYMOUS_P, ADDR and OFFSET) should not - be dumped, or greater than 0 if it should. + be dumped, or true if it should. In a nutshell, this is the logic that we follow in order to decide if a mapping should be dumped or not. @@ -677,7 +677,7 @@ mapping_is_anonymous_p (const char *filename) header (of a DSO or an executable, for example). If it is, and if the user is interested in dump it, then we should dump it. */ -static int +static bool dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v, int maybe_private_p, int mapping_anon_p, int mapping_file_p, const char *filename, ULONGEST addr, ULONGEST offset) @@ -690,24 +690,23 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v, (assuming that the version of the Linux kernel being used supports it, of course). */ int private_p = maybe_private_p; - int dump_p; /* We always dump vDSO and vsyscall mappings, because it's likely that there'll be no file to read the contents from at core load time. The kernel does the same. */ if (strcmp ("[vdso]", filename) == 0 || strcmp ("[vsyscall]", filename) == 0) - return 1; + return true; if (v->initialized_p) { /* We never dump I/O mappings. */ if (v->io_page) - return 0; + return false; /* Check if we should exclude this mapping. */ if (!dump_excluded_mappings && v->exclude_coredump) - return 0; + return false; /* Update our notion of whether this mapping is shared or private based on a trustworthy value. */ @@ -718,12 +717,13 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v, { if ((private_p && (filterflags & COREFILTER_HUGETLB_PRIVATE)) || (!private_p && (filterflags & COREFILTER_HUGETLB_SHARED))) - return 1; + return true; - return 0; + return false; } } + bool dump_p; if (private_p) { if (mapping_anon_p && mapping_file_p) @@ -783,7 +783,7 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v, { /* This mapping contains an ELF header, so we should dump it. */ - dump_p = 1; + dump_p = true; } } } @@ -794,7 +794,7 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v, /* As above, but return true only when we should dump the NT_FILE entry. */ -static int +static bool dump_note_entry_p (filter_flags filterflags, const struct smaps_vmflags *v, int maybe_private_p, int mapping_anon_p, int mapping_file_p, const char *filename, ULONGEST addr, ULONGEST offset) @@ -803,11 +803,11 @@ dump_note_entry_p (filter_flags filterflags, const struct smaps_vmflags *v, put them in the NT_FILE note. */ if (strcmp ("[vdso]", filename) == 0 || strcmp ("[vsyscall]", filename) == 0) - return 0; + return false; /* Otherwise, any other file-based mapping should be placed in the note. */ - return 1; + return true; } /* Implement the "info proc" command. */ @@ -1321,14 +1321,14 @@ typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size, const char *filename, void *data); -typedef int linux_dump_mapping_p_ftype (filter_flags filterflags, - const struct smaps_vmflags *v, - int maybe_private_p, - int mapping_anon_p, - int mapping_file_p, - const char *filename, - ULONGEST addr, - ULONGEST offset); +typedef bool linux_dump_mapping_p_ftype (filter_flags filterflags, + const struct smaps_vmflags *v, + int maybe_private_p, + int mapping_anon_p, + int mapping_file_p, + const char *filename, + ULONGEST addr, + ULONGEST offset); /* Helper function to parse the contents of /proc//smaps into a data structure, for easy access. @@ -1590,7 +1590,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, for (const struct smaps_data &map : smaps) { - int should_dump_p = 0; + bool should_dump_p = false; if (map.has_anonymous) { @@ -1607,7 +1607,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, { /* Older Linux kernels did not support the "Anonymous:" counter. If it is missing, we can't be sure - dump all the pages. */ - should_dump_p = 1; + should_dump_p = true; } /* Invoke the callback function to create the corefile segment. */