From patchwork Fri Jan 10 21:29:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 104542 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC3C03857724 for ; Fri, 10 Jan 2025 21:44:11 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 221033858023 for ; Fri, 10 Jan 2025 21:29:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 221033858023 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 221033858023 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736544563; cv=none; b=A5TUHWVsWD316Hu2y+wv7eKIffRRofFOEz64RUe5YOjy2nZVPKNPpNbgG2r1946FVtE6L07QX8HSwaVBFdedUlqHBHyj/AxFu5v/HpCZy7c91dbGW4uHdHLKG4smjB8i+4v9igBtTUqX9/Mv7TeAFuUwe2V9FWRZPsWCdm0SryY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736544563; c=relaxed/simple; bh=MSJWxgFElM7u4qojWqnDrnRfVqjUkkmVeLxaDCDOQvE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=d9cK+UEsXzQNBqiEsp5tI9M6DJoK58B1h+HoQO4Klom8Cq9bZ8hZ3FwYuRJ5d+Fmp5joDN8DgdXvy9tFckPvA3+Wad135LK7IhpgznKxXVxlRm7jxlpbXLoTtCP4EyVY8StXLi26OsViJ8Z2f28xsVn3WO31bZhA3cN3GyiGBJ8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 221033858023 Authentication-Results: sourceware.org; dkim=policy reason="signing key too small" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=q/yd8+sN Received: from eig-obgw-6007a.ext.cloudfilter.net ([10.0.30.247]) by cmsmtp with ESMTPS id WKR3th5IDYpSZWMZGtSbUu; Fri, 10 Jan 2025 21:29:22 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id WMZFtmv5cbUGLWMZGtfOow; Fri, 10 Jan 2025 21:29:22 +0000 X-Authority-Analysis: v=2.4 cv=Lv2UyGdc c=1 sm=1 tr=0 ts=67819132 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=VdSt8ZQiCzkA:10 a=ItBw4LHWJt0A:10 a=7d_E57ReAAAA:8 a=yqVGEpWH_T9SaNXiONsA:9 a=QEXdDO2ut3YA:10 a=2l-XiW3A4bR-waBpo9cO:22 a=jhqOcbufqs7Y1TYCrUUU:22 a=6Ogn3jAGHLSNbaov7Orx:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zp5OzXchNSucQ8+3CBzyvdGih8G57I65EJv9+mtMWdU=; b=q/yd8+sNU+uCRcy3lasz0A3Pif qpMhVc/bTMF241ZjoOGaLZ+3lzfgusE1kZCpM0dudGOCFlo1yDuXwD274/aZlw4c71b2IiqpKZnhK E//SEhiC+GA5XqnQ5fOI2A1VU; Received: from 97-118-36-154.hlrn.qwest.net ([97.118.36.154]:40752 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1tWMZF-0042hb-1H; Fri, 10 Jan 2025 14:29:21 -0700 From: Tom Tromey Date: Fri, 10 Jan 2025 14:29:21 -0700 Subject: [PATCH v2 6/6] Use bool in linespec MIME-Version: 1.0 Message-Id: <20250110-linespec-state-cxx-v2-6-a17144fa5c36@tromey.com> References: <20250110-linespec-state-cxx-v2-0-a17144fa5c36@tromey.com> In-Reply-To: <20250110-linespec-state-cxx-v2-0-a17144fa5c36@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey , Simon Marchi X-Mailer: b4 0.14.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.36.154 X-Source-L: No X-Exim-ID: 1tWMZF-0042hb-1H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-36-154.hlrn.qwest.net (prentzel.local) [97.118.36.154]:40752 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfHBSLaQrtsTaHCYLYldRF6lSeRFwzwi2ZzCYI9LnYUVe7U64FdkXETgOxDlWVsbit8NuK69rvfo0MVFSXXUoiKA8+kYhOM5su45qUFEasGxquIKAaVqL uoZtga3DZ1wrjg2DUa28CsTEa0hoCpgMJtnH/rZeByQwQQBE3DrhDB3r2qnRPgWMMIPAce0yVQg+StzlU55ZbfXaJeLuMquC200= X-Spam-Status: No, score=-3015.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SOMETLD_ARE_BAD_TLD, PDS_OTHER_BAD_TLD, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org This changes various spots in linespec to use a bool rather than an int. Approved-By: Simon Marchi --- gdb/linespec.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index eb27cb7e2d6706122ac7ae8ab7bab4ad8a44b8aa..b58b4ce029a02d912e8fb8d3d76c179efb6da599 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -139,8 +139,8 @@ struct linespec_state search_pspace (search_pspace), default_symtab (default_symtab), default_line (default_line), - funfirstline ((flags & DECODE_LINE_FUNFIRSTLINE) ? 1 : 0), - list_mode ((flags & DECODE_LINE_LIST_MODE) ? 1 : 0), + funfirstline ((flags & DECODE_LINE_FUNFIRSTLINE) != 0), + list_mode ((flags & DECODE_LINE_LIST_MODE) != 0), canonical (canonical) { } @@ -177,10 +177,10 @@ struct linespec_state /* The 'funfirstline' value that was passed in to decode_line_1 or decode_line_full. */ - int funfirstline; + bool funfirstline; /* Nonzero if we are running in 'list' mode; see decode_line_list. */ - int list_mode; + bool list_mode; /* The 'canonical' value passed to decode_line_full, or NULL. */ struct linespec_result *canonical; @@ -189,7 +189,7 @@ struct linespec_state std::vector canonical_names; /* Are we building a linespec? */ - int is_linespec = 0; + bool is_linespec = false; private: @@ -328,7 +328,7 @@ struct linespec_parser } lexer {}; /* Is the entire linespec quote-enclosed? */ - int is_quote_enclosed = 0; + bool is_quote_enclosed = false; /* The state of the parse. */ linespec_state state; @@ -396,8 +396,8 @@ static struct line_offset linespec_parse_variable (struct linespec_state *self, const char *variable); -static int symbol_to_sal (struct symtab_and_line *result, - int funfirstline, struct symbol *sym); +static bool symbol_to_sal (struct symtab_and_line *result, + bool funfirstline, struct symbol *sym); static void add_matching_symbols_to_info (const char *name, symbol_name_match_type name_match_type, @@ -1986,7 +1986,7 @@ static std::vector create_sals_line_offset (struct linespec_state *self, linespec *ls) { - int use_default = 0; + bool use_default = false; /* This is where we need to make sure we have good defaults. We must guarantee that this section of code is never executed @@ -2005,7 +2005,7 @@ create_sals_line_offset (struct linespec_state *self, ls->file_symtabs = collect_symtabs_from_filename (self->default_symtab->filename, self->search_pspace); - use_default = 1; + use_default = true; } symtab_and_line val; @@ -2461,7 +2461,7 @@ parse_linespec (linespec_parser *parser, const char *arg, /* A special case to start. It has become quite popular for IDEs to work around bugs in the previous parser by quoting the entire linespec, so we attempt to deal with this nicely. */ - parser->is_quote_enclosed = 0; + parser->is_quote_enclosed = false; if (parser->completion_tracker == NULL && !is_ada_operator (arg) && *arg != '\0' @@ -2473,7 +2473,7 @@ parse_linespec (linespec_parser *parser, const char *arg, /* Here's the special case. Skip ARG past the initial quote. */ ++arg; - parser->is_quote_enclosed = 1; + parser->is_quote_enclosed = true; } } @@ -2843,7 +2843,7 @@ linespec_complete (completion_tracker &tracker, const char *text, parser.lexer.stream = text; parser.completion_tracker = &tracker; - parser.state.is_linespec = 1; + parser.state.is_linespec = true; /* Parse as much as possible. parser.completion_word will hold furthest completion point we managed to parse to. */ @@ -3034,7 +3034,7 @@ location_spec_to_sals (linespec_parser *parser, case LINESPEC_LOCATION_SPEC: { const linespec_location_spec *ls = as_linespec_location_spec (locspec); - parser->state.is_linespec = 1; + parser->state.is_linespec = true; result = parse_linespec (parser, ls->spec_string.get (), ls->match_type); } @@ -4104,7 +4104,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, static void add_minsym (struct minimal_symbol *minsym, struct objfile *objfile, - struct symtab *symtab, int list_mode, + struct symtab *symtab, bool list_mode, std::vector *msyms) { if (symtab != NULL) @@ -4292,14 +4292,14 @@ add_matching_symbols_to_info (const char *name, /* Now come some functions that are called from multiple places within decode_line_1. */ -static int +static bool symbol_to_sal (struct symtab_and_line *result, - int funfirstline, struct symbol *sym) + bool funfirstline, struct symbol *sym) { if (sym->aclass () == LOC_BLOCK) { *result = find_function_start_sal (sym, funfirstline); - return 1; + return true; } else { @@ -4312,7 +4312,7 @@ symbol_to_sal (struct symtab_and_line *result, result->pc = sym->value_address (); result->pspace = result->symtab->compunit ()->objfile ()->pspace (); result->explicit_pc = 1; - return 1; + return true; } else if (funfirstline) { @@ -4327,11 +4327,11 @@ symbol_to_sal (struct symtab_and_line *result, result->line = sym->line (); result->pc = sym->value_address (); result->pspace = result->symtab->compunit ()->objfile ()->pspace (); - return 1; + return true; } } - return 0; + return false; } linespec_result::~linespec_result ()