From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by sourceware.org (Postfix) with ESMTPS id C57EE3856DDE for ; Mon, 16 May 2022 18:40:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C57EE3856DDE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f52.google.com with SMTP id v191-20020a1cacc8000000b00397001398c0so84934wme.5 for ; Mon, 16 May 2022 11:40:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=glgjV8+cda34kDj03Givj1i70O7OAxEFnxW5G3fgWSY=; b=IrGrZB9rFbF89ljXsSzmJMY6SH3Y6dWSN4iVpE2lz9/KXjFkGTpNXvSpQvkPqYQoQh 3TliPh6BIxXeI7fC2y5rcy9EX38s7LkwxBGQcbsz+UgE24RMa8PuKA3jKAWr4+mA2ozM 2zr/wKFQXxJaZRFzASOVnDyfxYrNJwhkbxM/PzSR5xPi/m9Oc7YIyyJXa8xu8qmNSUb7 SvMAZg17oaNG+Pr1vG3WB3Swgp6dOHZr3U0PqQA9MmnlNAG6pIvucXjLkBqg9ZKf8TP8 Xx766yViweeaiQCLF3zwg5+dJvIlWI39d9FtySs6Jsh9OKdcAZnKkGBJvGRAC5/ANzRV 6Dpg== X-Gm-Message-State: AOAM533kNJEvRlNvDrr9SSStczPH58k0/c0i/xZRxcOyaA/mc2XtnbX7 PAAyIMWtoWrqmSSEf0Nkr6tLRbwv6P0= X-Google-Smtp-Source: ABdhPJyTRKxJsxqFgwi7Ii+24pn2CUzjqFw85ivVzqXeuPtFegIqcplc6QRlAwhQzZHrZv5MNZ+AuA== X-Received: by 2002:a05:600c:4e4f:b0:397:2ca:2363 with SMTP id e15-20020a05600c4e4f00b0039702ca2363mr6966824wmq.38.1652726456116; Mon, 16 May 2022 11:40:56 -0700 (PDT) Received: from localhost ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c1c0800b003958af7d0c8sm8459wms.45.2022.05.16.11.40.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 May 2022 11:40:55 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 11/23] Convert init_ada_exception_catchpoint to a ctor Date: Mon, 16 May 2022 19:40:18 +0100 Message-Id: <20220516184030.665489-12-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220516184030.665489-1-pedro@palves.net> References: <20220516184030.665489-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 18:41:00 -0000 Currently, init_ada_exception_catchpoint is defined in breakpoint.c, I presume so it can call the static describe_other_breakpoints function. I think this is a dependency inversion. init_ada_exception_catchpoint, being code specific to Ada catchpoints, should be in ada-lang.c, and describe_other_breakpoints, a core function, should be exported. And then, we can convert init_ada_exception_catchpoint to an ada_catchpoint ctor. Change-Id: I07695572dabc5a75d3d3740fd9b95db1529406a1 --- gdb/ada-lang.c | 43 +++++++++++++++++++++++++++++++++++++++---- gdb/breakpoint.c | 46 ++-------------------------------------------- gdb/breakpoint.h | 19 ++++++++----------- 3 files changed, 49 insertions(+), 59 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 1c70f4178d0..5ddca104dc3 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12107,10 +12107,45 @@ static std::string ada_exception_catchpoint_cond_string struct ada_catchpoint : public base_breakpoint { ada_catchpoint (struct gdbarch *gdbarch_, - enum ada_exception_catchpoint_kind kind) + enum ada_exception_catchpoint_kind kind, + struct symtab_and_line sal, + const char *addr_string_, + bool tempflag, + bool enabled, + bool from_tty) : base_breakpoint (gdbarch_, bp_catchpoint), m_kind (kind) { + add_location (sal); + + /* Unlike most base_breakpoint types, Ada catchpoints are + pspace-specific. */ + gdb_assert (sal.pspace != nullptr); + this->pspace = sal.pspace; + + if (from_tty) + { + struct gdbarch *loc_gdbarch = get_sal_arch (sal); + if (!loc_gdbarch) + loc_gdbarch = gdbarch; + + describe_other_breakpoints (loc_gdbarch, + sal.pspace, sal.pc, sal.section, -1); + /* FIXME: brobecker/2006-12-28: Actually, re-implement a special + version for exception catchpoints, because two catchpoints + used for different exception names will use the same address. + In this case, a "breakpoint ... also set at..." warning is + unproductive. Besides, the warning phrasing is also a bit + inappropriate, we should use the word catchpoint, and tell + the user what type of catchpoint it is. The above is good + enough for now, though. */ + } + + enable_state = enabled ? bp_enabled : bp_disabled; + disposition = tempflag ? disp_del : disp_donttouch; + location = string_to_event_location (&addr_string_, + language_def (language_ada)); + language = language_ada; } struct bp_location *allocate_location () override; @@ -12759,9 +12794,9 @@ create_ada_exception_catchpoint (struct gdbarch *gdbarch, std::string addr_string; struct symtab_and_line sal = ada_exception_sal (ex_kind, &addr_string); - std::unique_ptr c (new ada_catchpoint (gdbarch, ex_kind)); - init_ada_exception_breakpoint (c.get (), gdbarch, sal, addr_string.c_str (), - tempflag, disabled, from_tty); + std::unique_ptr c + (new ada_catchpoint (gdbarch, ex_kind, sal, addr_string.c_str (), + tempflag, disabled, from_tty)); c->excep_string = excep_string; create_excep_cond_exprs (c.get (), ex_kind); if (!cond_string.empty ()) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ce742b97fd5..3773f317bfe 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -130,10 +130,6 @@ static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr, enum bptype bptype); -static void describe_other_breakpoints (struct gdbarch *, - struct program_space *, CORE_ADDR, - struct obj_section *, int); - static int watchpoint_locations_match (struct bp_location *loc1, struct bp_location *loc2); @@ -6862,11 +6858,9 @@ breakpoint_has_pc (struct breakpoint *b, return 0; } -/* Print a message describing any user-breakpoints set at PC. This - concerns with logical breakpoints, so we match program spaces, not - address spaces. */ +/* See breakpoint.h. */ -static void +void describe_other_breakpoints (struct gdbarch *gdbarch, struct program_space *pspace, CORE_ADDR pc, struct obj_section *section, int thread) @@ -10594,42 +10588,6 @@ until_break_command (const char *arg, int from_tty, int anywhere) proceed (-1, GDB_SIGNAL_DEFAULT); } -void -init_ada_exception_breakpoint (struct breakpoint *b, - struct gdbarch *gdbarch, - struct symtab_and_line sal, - const char *addr_string, - int tempflag, - int enabled, - int from_tty) -{ - if (from_tty) - { - struct gdbarch *loc_gdbarch = get_sal_arch (sal); - if (!loc_gdbarch) - loc_gdbarch = gdbarch; - - describe_other_breakpoints (loc_gdbarch, - sal.pspace, sal.pc, sal.section, -1); - /* FIXME: brobecker/2006-12-28: Actually, re-implement a special - version for exception catchpoints, because two catchpoints - used for different exception names will use the same address. - In this case, a "breakpoint ... also set at..." warning is - unproductive. Besides, the warning phrasing is also a bit - inappropriate, we should use the word catchpoint, and tell - the user what type of catchpoint it is. The above is good - enough for now, though. */ - } - - init_raw_breakpoint (b, sal, bp_catchpoint); - - b->enable_state = enabled ? bp_enabled : bp_disabled; - b->disposition = tempflag ? disp_del : disp_donttouch; - b->location = string_to_event_location (&addr_string, - language_def (language_ada)); - b->language = language_ada; -} - /* Compare two breakpoints and return a strcmp-like result. */ diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 40ba98b7496..a4ead8b4d4e 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1460,17 +1460,6 @@ extern void void *user_data_catch, void *user_data_tcatch); -/* Initialize a breakpoint struct for Ada exception catchpoints. */ - -extern void - init_ada_exception_breakpoint (struct breakpoint *b, - struct gdbarch *gdbarch, - struct symtab_and_line sal, - const char *addr_string, - int tempflag, - int enabled, - int from_tty); - /* Add breakpoint B on the breakpoint list, and notify the user, the target and breakpoint_created observers of its existence. If INTERNAL is non-zero, the breakpoint number will be allocated from @@ -1905,4 +1894,12 @@ extern void catch_exception_event (enum exception_event_kind ex_event, extern void print_solib_event (bool is_catchpoint); +/* Print a message describing any user-breakpoints set at PC. This + concerns with logical breakpoints, so we match program spaces, not + address spaces. */ + +extern void describe_other_breakpoints (struct gdbarch *, + struct program_space *, CORE_ADDR, + struct obj_section *, int); + #endif /* !defined (BREAKPOINT_H) */ -- 2.36.0