From patchwork Tue Jan 10 15:18:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 62896 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 2B0FB396D834 for ; Tue, 10 Jan 2023 15:18:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B0FB396D834 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673363938; bh=Sy+fRuVt+s8Pfa2zngfSb2M+ylIY1uA37xCBafnfPmA=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=i8vcdmvpRF7OqByRXGXe6+W0nUNMzh04GG55Wbtqaj32sf1CQXDrc5ImROuXsKltQ VHs62YPszvSaU2YLzqte2KLVNpyJZsCZqKjFWMlLVCw6+5jqU3JO5isZ22QRxhZs7z 2EoHq80X9RmSvAE2SbKnrFk+5Lk9OtYyVCXDkclw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by sourceware.org (Postfix) with ESMTPS id D148C395C41D for ; Tue, 10 Jan 2023 15:18:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D148C395C41D Received: by mail-io1-xd33.google.com with SMTP id g20so6278922iob.2 for ; Tue, 10 Jan 2023 07:18:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Sy+fRuVt+s8Pfa2zngfSb2M+ylIY1uA37xCBafnfPmA=; b=UNnfxw97LD5HRlW8sR3CYDarZMhNJPS56CYEAzzfrqyRXEyPD3/kOsZWrkl65YT1Ql mON2XW14TBSN3X7TAEtHBlUBUTxeaBIP30OOdimWdYncCCkCXPcr1S2M5pvu3+4BQaXM 5PvBj8GUNkONlioR1IgCklXphLHL3YgUg+BOkv2bfnNJ38HVyynyYTzlO8Tjqn9W5kM3 z189HGFDcHzOeKVrUsJoRT3lqHidAv3t6H0mx+9iA68MhHf+5jrtYGvhHasbep+hiE0z MgRSUaXmZooBWCHHNlgEU2W2t/w3hjmiNGinYy1JlFaafBAo1yoS1/wIFxO48HznfHmq F6Tw== X-Gm-Message-State: AFqh2kobFNm2u8Z67LB88XCl9C+fxDgIFGGV+FxfNTNUz/5a/d71YtUF 5XXz52/L9EIRXbTmDAzELO349KV/koLiZ/xP X-Google-Smtp-Source: AMrXdXtxJQ6PLdKrElw+60BAY5HTP6eAv4zvxInkbJgwtZzQpmYrjhck59dwCX3E2iCiBiBHqyb1Cg== X-Received: by 2002:a6b:d109:0:b0:6e3:187:f4ef with SMTP id l9-20020a6bd109000000b006e30187f4efmr45101982iob.19.1673363908975; Tue, 10 Jan 2023 07:18:28 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id 1-20020a056e0211a100b003024b62725dsm3308949ilj.22.2023.01.10.07.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 07:18:28 -0800 (PST) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Convert say_where to method on code_breakpoint Date: Tue, 10 Jan 2023 08:18:21 -0700 Message-Id: <20230110151821.2302229-1-tromey@adacore.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 'say_where' is only useful (and only called for) code breakpoints, so convert it to be a protected method on code_breakpoint. --- gdb/breakpoint.c | 49 ++++++++++++++++++++++++------------------------ gdb/breakpoint.h | 4 ++++ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8cfc46e0bed..6762fad5d2c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -11496,11 +11496,10 @@ bpstat_remove_breakpoint_callback (struct thread_info *th, void *data) return 0; } -/* Helper for breakpoint and tracepoint breakpoint->mention - callbacks. */ +/* See breakpoint.h. */ -static void -say_where (const breakpoint *b) +void +code_breakpoint::say_where () const { struct value_print_options opts; @@ -11508,58 +11507,58 @@ say_where (const breakpoint *b) /* i18n: cagney/2005-02-11: Below needs to be merged into a single string. */ - if (b->loc == NULL) + if (loc == NULL) { /* For pending locations, the output differs slightly based - on b->extra_string. If this is non-NULL, it contains either + on extra_string. If this is non-NULL, it contains either a condition or dprintf arguments. */ - if (b->extra_string == NULL) + if (extra_string == NULL) { - gdb_printf (_(" (%s) pending."), b->locspec->to_string ()); + gdb_printf (_(" (%s) pending."), locspec->to_string ()); } - else if (b->type == bp_dprintf) + else if (type == bp_dprintf) { gdb_printf (_(" (%s,%s) pending."), - b->locspec->to_string (), - b->extra_string.get ()); + locspec->to_string (), + extra_string.get ()); } else { gdb_printf (_(" (%s %s) pending."), - b->locspec->to_string (), - b->extra_string.get ()); + locspec->to_string (), + extra_string.get ()); } } else { - if (opts.addressprint || b->loc->symtab == NULL) + if (opts.addressprint || loc->symtab == NULL) gdb_printf (" at %ps", styled_string (address_style.style (), - paddress (b->loc->gdbarch, - b->loc->address))); - if (b->loc->symtab != NULL) + paddress (loc->gdbarch, + loc->address))); + if (loc->symtab != NULL) { /* If there is a single location, we can print the location more nicely. */ - if (b->loc->next == NULL) + if (loc->next == NULL) { const char *filename - = symtab_to_filename_for_display (b->loc->symtab); + = symtab_to_filename_for_display (loc->symtab); gdb_printf (": file %ps, line %d.", styled_string (file_name_style.style (), filename), - b->loc->line_number); + loc->line_number); } else /* This is not ideal, but each location may have a different file name, and this at least reflects the real situation somewhat. */ - gdb_printf (": %s.", b->locspec->to_string ()); + gdb_printf (": %s.", locspec->to_string ()); } - if (b->loc->next) + if (loc->next) { - struct bp_location *loc = b->loc; + struct bp_location *loc = loc; int n = 0; for (; loc; loc = loc->next) ++n; @@ -11794,7 +11793,7 @@ ordinary_breakpoint::print_mention () const break; } - say_where (this); + say_where (); } void @@ -12054,7 +12053,7 @@ tracepoint::print_mention () const internal_error (_("unhandled tracepoint type %d"), (int) type); } - say_where (this); + say_where (); } void diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 7289a09e95c..399bd037977 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -898,6 +898,10 @@ struct code_breakpoint : public breakpoint (location_spec *locspec, struct program_space *search_pspace, int *found); + + /* Helper for breakpoint and tracepoint breakpoint->mention + callbacks. */ + void say_where () const; }; /* An instance of this type is used to represent a watchpoint,