From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118096 invoked by alias); 24 Sep 2019 21:53:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 118084 invoked by uid 89); 24 Sep 2019 21:53:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=ind, advertise, H*MI:google X-HELO: mail-yb1-f201.google.com Received: from mail-yb1-f201.google.com (HELO mail-yb1-f201.google.com) (209.85.219.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Sep 2019 21:53:46 +0000 Received: by mail-yb1-f201.google.com with SMTP id y16so598187ybs.11 for ; Tue, 24 Sep 2019 14:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc :content-transfer-encoding; bh=ycxMtBz0D7ArXJtZpdkNm3T7uII2E/yOLjNfcFtmX8I=; b=iBdV34SWwfBxlt8UyLHt8FItwbZc3eCXuT4G0iiELzsvH/q/q8g3Hq1BHJKVNzOJ6z VuPrO1bw/SsqZLL7DzFXDTGs/rGxT5l1YCAwbZD6wvbS69Sxq6FDWERUprzPr2ZU4T0C Ip39J+54V0YX44qhptenuQnEMxD4V3arEsTFUlM+BM7UIOy1+cUylWS4mKvos/EkUK2A pOfjA6q/KZo7IHEZbcBauRjWZ0S0ZVsarChQcXl5gpMM+towr87qTMA7lnyVScECMGSi HWAB/OUV2KVvT/b84SG+Hnm/ZHel9PY+/TrV2RNspv0cPwL2mUUhJil4Og+W4V7zZOKL 4IDA== Date: Tue, 24 Sep 2019 21:53:00 -0000 Message-Id: <20190924215341.40236-1-cbiesinger@google.com> Mime-Version: 1.0 Subject: [PATCH] Convert symtab.h function signatures to use bool instead of int From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger To: gdb-patches@sourceware.org Cc: Christian Biesinger Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00471.txt.bz2 gdb/ChangeLog: 2019-09-24 Christian Biesinger * blockframe.c (find_pc_partial_function): Change return type to bool. * elfread.c (elf_gnu_ifunc_resolve_name): Likewise. * minsyms.c (in_gnu_ifunc_stub): Likewise. (stub_gnu_ifunc_resolve_name): Likewise. * symtab.c (compare_filenames_for_search): Likewise. (compare_glob_filenames_for_search): Likewise. (matching_obj_sections): Likewise. (symbol_matches_domain): Likewise. (find_line_symtab): Change out param EXACT_MATCH to bool *. (find_line_pc): Change return type to bool. (find_line_pc_range): Likewise. (producer_is_realview): Likewise. * symtab.h (symbol_matches_domain): Likewise. (find_pc_partial_function): Likewise. (find_pc_line_pc_range): Likewise. (in_gnu_ifunc_stub): Likewise. (struct gnu_ifunc_fns) : Likewise. (find_line_pc): Likewise. (find_line_pc_range): Likewise. (matching_obj_sections): Likewise. (find_line_symtab): Change out parameter to bool. (producer_is_realview): Change return type to bool. (compare_filenames_for_search): Likewise. (compare_glob_filenames_for_search): Likewise. --- gdb/blockframe.c | 6 ++-- gdb/elfread.c | 10 +++---- gdb/minsyms.c | 4 +-- gdb/symtab.c | 74 ++++++++++++++++++++++++------------------------ gdb/symtab.h | 42 +++++++++++++-------------- 5 files changed, 68 insertions(+), 68 deletions(-) diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 4462274f46..a3f82ef5a9 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -209,7 +209,7 @@ clear_pc_function_cache (void) =20 /* See symtab.h. */ =20 -int +bool find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *addr= ess, CORE_ADDR *endaddr, const struct block **block) { @@ -333,7 +333,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **na= me, CORE_ADDR *address, *endaddr =3D 0; if (block !=3D nullptr) *block =3D nullptr; - return 0; + return false; } =20 cache_pc_function_low =3D BMSYMBOL_VALUE_ADDRESS (msymbol); @@ -374,7 +374,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **na= me, CORE_ADDR *address, if (block !=3D nullptr) *block =3D cache_pc_function_block; =20 - return 1; + return true; } =20 /* See symtab.h. */ diff --git a/gdb/elfread.c b/gdb/elfread.c index 901710f283..a3d17e54a2 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -850,21 +850,21 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_= ADDR *addr_p) =20 /* Try to find the target resolved function entry address of a STT_GNU_IFU= NC function NAME. If the address is found it is stored to *ADDR_P (if ADD= R_P - is not NULL) and the function returns 1. It returns 0 otherwise. + is not NULL) and the function returns true. It returns false otherwise. =20 Both the elf_objfile_gnu_ifunc_cache_data hash table and SYMBOL_GOT_PLT_SUFFIX locations are searched by this function. */ =20 -static int +static bool elf_gnu_ifunc_resolve_name (const char *name, CORE_ADDR *addr_p) { if (elf_gnu_ifunc_resolve_by_cache (name, addr_p)) - return 1; + return true; =20 if (elf_gnu_ifunc_resolve_by_got (name, addr_p)) - return 1; + return true; =20 - return 0; + return false; } =20 /* Call STT_GNU_IFUNC - a function returning addresss of a real function to diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 0f734ebc76..f06de4d88e 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -895,7 +895,7 @@ lookup_minimal_symbol_by_pc (CORE_ADDR pc) =20 /* Return non-zero iff PC is in an STT_GNU_IFUNC function resolver. */ =20 -int +bool in_gnu_ifunc_stub (CORE_ADDR pc) { bound_minimal_symbol msymbol @@ -916,7 +916,7 @@ stub_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, C= ORE_ADDR pc) =20 /* See elf_gnu_ifunc_resolve_name for its real implementation. */ =20 -static int +static bool stub_gnu_ifunc_resolve_name (const char *function_name, CORE_ADDR *function_address_p) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 54c7ed9c7c..6ea9fc6971 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -355,18 +355,18 @@ minimal_symbol::text_p () const describes what we advertise). Returns true if they match, false otherwise. */ =20 -int +bool compare_filenames_for_search (const char *filename, const char *search_nam= e) { int len =3D strlen (filename); size_t search_len =3D strlen (search_name); =20 if (len < search_len) - return 0; + return false; =20 /* The tail of FILENAME must match. */ if (FILENAME_CMP (filename + len - search_len, search_name) !=3D 0) - return 0; + return false; =20 /* Either the names must completely match, or the character preceding the trailing SEARCH_NAME segment of FILENAME must be a @@ -393,7 +393,7 @@ compare_filenames_for_search (const char *filename, con= st char *search_name) compare_filenames_for_search, but it's the opposite of the order of arguments to gdb_filename_fnmatch. */ =20 -int +bool compare_glob_filenames_for_search (const char *filename, const char *search_name) { @@ -403,7 +403,7 @@ compare_glob_filenames_for_search (const char *filename, int search_path_elements =3D count_path_elements (search_name); =20 if (search_path_elements > file_path_elements) - return 0; + return false; =20 if (IS_ABSOLUTE_PATH (search_name)) { @@ -1002,11 +1002,11 @@ symbol_matches_search_name (const struct general_sy= mbol_info *gsymbol, =20 =0C =20 -/* Return 1 if the two sections are the same, or if they could +/* Return true if the two sections are the same, or if they could plausibly be copies of each other, one in an original object file and another in a separated debug file. */ =20 -int +bool matching_obj_sections (struct obj_section *obj_first, struct obj_section *obj_second) { @@ -1015,36 +1015,36 @@ matching_obj_sections (struct obj_section *obj_firs= t, =20 /* If they're the same section, then they match. */ if (first =3D=3D second) - return 1; + return true; =20 /* If either is NULL, give up. */ if (first =3D=3D NULL || second =3D=3D NULL) - return 0; + return false; =20 /* This doesn't apply to absolute symbols. */ if (first->owner =3D=3D NULL || second->owner =3D=3D NULL) - return 0; + return false; =20 /* If they're in the same object file, they must be different sections. = */ if (first->owner =3D=3D second->owner) - return 0; + return false; =20 /* Check whether the two sections are potentially corresponding. They m= ust have the same size, address, and name. We can't compare section inde= xes, which would be more reliable, because some sections may have been stripped. */ if (bfd_section_size (first) !=3D bfd_section_size (second)) - return 0; + return false; =20 /* In-memory addresses may start at a different offset, relativize them.= */ if (bfd_section_vma (first) - bfd_get_start_address (first->owner) !=3D bfd_section_vma (second) - bfd_get_start_address (second->owner= )) - return 0; + return false; =20 if (bfd_section_name (first) =3D=3D NULL || bfd_section_name (second) =3D=3D NULL || strcmp (bfd_section_name (first), bfd_section_name (second)) !=3D= 0) - return 0; + return false; =20 /* Otherwise check that they are in corresponding objfiles. */ =20 @@ -1059,12 +1059,12 @@ matching_obj_sections (struct obj_section *obj_firs= t, =20 if (obj->separate_debug_objfile !=3D NULL && obj->separate_debug_objfile->obfd =3D=3D second->owner) - return 1; + return true; if (obj->separate_debug_objfile_backlink !=3D NULL && obj->separate_debug_objfile_backlink->obfd =3D=3D second->owner) - return 1; + return true; =20 - return 0; + return false; } =20 /* See symtab.h. */ @@ -2674,7 +2674,7 @@ lookup_global_symbol (const char *name, return lookup_global_or_static_symbol (name, GLOBAL_BLOCK, objfile, doma= in); } =20 -int +bool symbol_matches_domain (enum language symbol_language, domain_enum symbol_domain, domain_enum domain) @@ -2688,7 +2688,7 @@ symbol_matches_domain (enum language symbol_language, { if ((domain =3D=3D VAR_DOMAIN || domain =3D=3D STRUCT_DOMAIN) && symbol_domain =3D=3D STRUCT_DOMAIN) - return 1; + return true; } /* For all other languages, strict match is required. */ return (symbol_domain =3D=3D domain); @@ -3297,14 +3297,14 @@ find_pc_line_symtab (CORE_ADDR pc) =20 If found, return the symtab that contains the linetable in which it was found, set *INDEX to the index in the linetable of the best entry - found, and set *EXACT_MATCH nonzero if the value returned is an + found, and set *EXACT_MATCH to true if the value returned is an exact match. =20 If not found, return NULL. */ =20 struct symtab * find_line_symtab (struct symtab *sym_tab, int line, - int *index, int *exact_match) + int *index, bool *exact_match) { int exact =3D 0; /* Initialized here to avoid a compiler warning. */ =20 @@ -3389,7 +3389,7 @@ done: if (index) *index =3D best_index; if (exact_match) - *exact_match =3D exact; + *exact_match =3D (exact !=3D 0); =20 return best_symtab; } @@ -3435,10 +3435,10 @@ find_pcs_for_symtab_line (struct symtab *symtab, in= t line, =20 =0C /* Set the PC value for a given source file and line number and return tru= e. - Returns zero for invalid line number (and sets the PC to 0). + Returns false for invalid line number (and sets the PC to 0). The source file is specified with a struct symtab. */ =20 -int +bool find_line_pc (struct symtab *symtab, int line, CORE_ADDR *pc) { struct linetable *l; @@ -3446,26 +3446,26 @@ find_line_pc (struct symtab *symtab, int line, CORE= _ADDR *pc) =20 *pc =3D 0; if (symtab =3D=3D 0) - return 0; + return false; =20 symtab =3D find_line_symtab (symtab, line, &ind, NULL); if (symtab !=3D NULL) { l =3D SYMTAB_LINETABLE (symtab); *pc =3D l->item[ind].pc; - return 1; + return true; } else - return 0; + return false; } =20 /* Find the range of pc values in a line. Store the starting pc of the line into *STARTPTR and the ending pc (start of next line) into *ENDPTR. - Returns 1 to indicate success. - Returns 0 if could not find the specified line. */ + Returns true to indicate success. + Returns false if could not find the specified line. */ =20 -int +bool find_line_pc_range (struct symtab_and_line sal, CORE_ADDR *startptr, CORE_ADDR *endptr) { @@ -3474,7 +3474,7 @@ find_line_pc_range (struct symtab_and_line sal, CORE_= ADDR *startptr, =20 startaddr =3D sal.pc; if (startaddr =3D=3D 0 && !find_line_pc (sal.symtab, sal.line, &startadd= r)) - return 0; + return false; =20 /* This whole function is based on address. For example, if line 10 has two parts, one from 0x100 to 0x200 and one from 0x300 to 0x400, then @@ -3495,7 +3495,7 @@ find_line_pc_range (struct symtab_and_line sal, CORE_= ADDR *startptr, *startptr =3D found_sal.pc; *endptr =3D found_sal.end; } - return 1; + return true; } =20 /* Given a line table and a line number, return the index into the line @@ -3549,7 +3549,7 @@ find_line_common (struct linetable *l, int lineno, return best_index; } =20 -int +bool find_pc_line_pc_range (CORE_ADDR pc, CORE_ADDR *startptr, CORE_ADDR *endpt= r) { struct symtab_and_line sal; @@ -6062,7 +6062,7 @@ symtab_observer_executable_changed (void) /* Return 1 if the supplied producer string matches the ARM RealView compiler (armcc). */ =20 -int +bool producer_is_realview (const char *producer) { static const char *const arm_idents[] =3D { @@ -6076,13 +6076,13 @@ producer_is_realview (const char *producer) int i; =20 if (producer =3D=3D NULL) - return 0; + return false; =20 for (i =3D 0; i < ARRAY_SIZE (arm_idents); i++) if (startswith (producer, arm_idents[i])) - return 1; + return true; =20 - return 0; + return false; } =20 =0C diff --git a/gdb/symtab.h b/gdb/symtab.h index d046598774..e73521d166 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1518,9 +1518,9 @@ extern const char multiple_symbols_cancel[]; =20 const char *multiple_symbols_select_mode (void); =20 -int symbol_matches_domain (enum language symbol_language,=20 - domain_enum symbol_domain, - domain_enum domain); +bool symbol_matches_domain (enum language symbol_language,=20 + domain_enum symbol_domain, + domain_enum domain); =20 /* lookup a symbol table by source file name. */ =20 @@ -1689,8 +1689,8 @@ extern struct symbol *find_symbol_at_address (CORE_AD= DR); nullptr is used as a return value for *BLOCK if no block is found.=20 This function either succeeds or fails (not halfway succeeds). If it succeeds, it sets *NAME, *ADDRESS, and *ENDADDR to real - information and returns 1. If it fails, it sets *NAME, *ADDRESS - and *ENDADDR to zero and returns 0. + information and returns true. If it fails, it sets *NAME, *ADDRESS + and *ENDADDR to zero and returns false. =20=20=20=20 If the function in question occupies non-contiguous ranges, *ADDRESS and *ENDADDR are (subject to the conditions noted above) set @@ -1716,9 +1716,9 @@ extern struct symbol *find_symbol_at_address (CORE_AD= DR); containing the entry pc should instead call find_function_entry_range_from_pc. */ =20 -extern int find_pc_partial_function (CORE_ADDR pc, const char **name, - CORE_ADDR *address, CORE_ADDR *endaddr, - const struct block **block =3D nullptr); +extern bool find_pc_partial_function (CORE_ADDR pc, const char **name, + CORE_ADDR *address, CORE_ADDR *endaddr, + const struct block **block =3D nullptr); =20 /* Like find_pc_partial_function, above, but *ADDRESS and *ENDADDR are set to start and end addresses of the range containing the entry pc. @@ -1764,7 +1764,7 @@ extern struct compunit_symtab *find_pc_compunit_symta= b (CORE_ADDR); extern struct compunit_symtab * find_pc_sect_compunit_symtab (CORE_ADDR, struct obj_section *); =20 -extern int find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *); +extern bool find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *); =20 extern void reread_symbols (void); =20 @@ -1786,7 +1786,7 @@ extern struct type *basic_lookup_transparent_type (co= nst char *); #define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled." #endif =20 -extern int in_gnu_ifunc_stub (CORE_ADDR pc); +extern bool in_gnu_ifunc_stub (CORE_ADDR pc); =20 /* Functions for resolving STT_GNU_IFUNC symbols which are implemented only for ELF symbol files. */ @@ -1797,7 +1797,7 @@ struct gnu_ifunc_fns CORE_ADDR (*gnu_ifunc_resolve_addr) (struct gdbarch *gdbarch, CORE_ADDR = pc); =20 /* See elf_gnu_ifunc_resolve_name for its real implementation. */ - int (*gnu_ifunc_resolve_name) (const char *function_name, + bool (*gnu_ifunc_resolve_name) (const char *function_name, CORE_ADDR *function_address_p); =20 /* See elf_gnu_ifunc_resolver_stop for its real implementation. */ @@ -1861,10 +1861,10 @@ extern struct symtab *find_pc_line_symtab (CORE_ADD= R); =20 /* Given a symtab and line number, return the pc there. */ =20 -extern int find_line_pc (struct symtab *, int, CORE_ADDR *); +extern bool find_line_pc (struct symtab *, int, CORE_ADDR *); =20 -extern int find_line_pc_range (struct symtab_and_line, CORE_ADDR *, - CORE_ADDR *); +extern bool find_line_pc_range (struct symtab_and_line, CORE_ADDR *, + CORE_ADDR *); =20 extern void resolve_sal_pc (struct symtab_and_line *); =20 @@ -1936,9 +1936,9 @@ completion_skip_symbol (complete_symbol_mode mode, Sy= mbol *sym) =20 /* symtab.c */ =20 -int matching_obj_sections (struct obj_section *, struct obj_section *); +bool matching_obj_sections (struct obj_section *, struct obj_section *); =20 -extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *= ); +extern struct symtab *find_line_symtab (struct symtab *, int, int *, bool = *); =20 /* Given a function symbol SYM, find the symtab and line for the start of the function. If FUNFIRSTLINE is true, we want the first line @@ -2051,7 +2051,7 @@ extern struct block_symbol =20 /* Return 1 if the supplied producer string matches the ARM RealView compiler (armcc). */ -int producer_is_realview (const char *producer); +bool producer_is_realview (const char *producer); =20 void fixup_section (struct general_symbol_info *ginfo, CORE_ADDR addr, struct objfile *objfile); @@ -2066,11 +2066,11 @@ extern unsigned int symbol_lookup_debug; =20 extern bool basenames_may_differ; =20 -int compare_filenames_for_search (const char *filename, - const char *search_name); +bool compare_filenames_for_search (const char *filename, + const char *search_name); =20 -int compare_glob_filenames_for_search (const char *filename, - const char *search_name); +bool compare_glob_filenames_for_search (const char *filename, + const char *search_name); =20 bool iterate_over_some_symtabs (const char *name, const char *real_path, --=20 2.23.0.351.gc4317032e6-goog