From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 86F5B384D1BE for ; Thu, 6 Oct 2022 09:37:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 86F5B384D1BE Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-540-U--4DnQ_NhKG2L7bc1WQGw-1; Thu, 06 Oct 2022 05:37:29 -0400 X-MC-Unique: U--4DnQ_NhKG2L7bc1WQGw-1 Received: by mail-wr1-f71.google.com with SMTP id i1-20020adfa501000000b0022cd1e1137bso314035wrb.0 for ; Thu, 06 Oct 2022 02:37:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZgsuSxK7qIwh8I0CZQj9Sf8reBHrVHB6SW7Y6IDGkJs=; b=Bc+Kelb+XRuKbCh7tlfXLnq9LH5PaWY/k8uxIxPnUSBQ4GJn8/7f9BUc5P/ycOVyMt GkU4U1Z3cen67GaBFcGoF7V5weaqMHMlREqX47ODd67Hkw+Gh2VzPJlc6k1+P4zSeMDh Lqik15vnhyZiRiRec/D++waZot45Xkcry0hzjHf/Kcxy/xubHkIeGcclUD3jqmISKQwk c7fhu8R0q4Fu5vYaleoo6hanfycwAHvGVnMbuPK2nMjguMCNl2g8/B8zk77BE8p6gabt w1MaLPWKqaH4JeLlj09SptwYlGNwH9KZvXPJEuwCLHdI8hh9AobmIJ7xJqFr0lJE/7xZ mf+w== X-Gm-Message-State: ACrzQf09lijxCm0TcuRs/YNEPy8Fss5i/GuOY3ZVd4EO/jHx2q1MAvzg HnprULnLU0krhzn41HYJXSMeazTlUjbPHQAnA8kRFPSq3+zjNMwlmOHnei3Yl8I3XnGJQQQ4tUQ 3ApORIw4kosfMXi5Ae9qAsxIAyaUf0xJpDZ8KywA9GKjeg1rlqQt+cEcZyHI9yjk0rXS5GQf2Fg == X-Received: by 2002:a05:600c:6d2:b0:3b4:8361:6154 with SMTP id b18-20020a05600c06d200b003b483616154mr2515941wmn.89.1665049047355; Thu, 06 Oct 2022 02:37:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6OKQQgXrOMTkVBYQwMAf6CFKiY07JlCE8pB4L5P3K8MM1qJxfUB0YvOFer60rhc8GG5eNW5Q== X-Received: by 2002:a05:600c:6d2:b0:3b4:8361:6154 with SMTP id b18-20020a05600c06d200b003b483616154mr2515920wmn.89.1665049047059; Thu, 06 Oct 2022 02:37:27 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c4e8f00b003b51a4c61aasm4840995wmq.40.2022.10.06.02.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 02:37:26 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PUSHED 2/3] gdb: more infrun debug from breakpoint.c Date: Thu, 6 Oct 2022 10:37:21 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: <87edvlfii0.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_NONE, 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-List-Received-Date: Thu, 06 Oct 2022 09:37:31 -0000 This commit adds additional infrun debug from the breakpoint.c file. The new debug output all relates to breakpoint condition evaluation. There is already some infrun debug emitted from the breakpoint.c file, so hopefully, adding more will not be contentious. I think the functions being instrumented make sense as part of the infrun process, the inferior stops, evaluates the condition, and then either stops or continues. This new debug gives more insight into that process. I had to make the bp_location* argument to find_loc_num_by_location const, and add a declaration for find_loc_num_by_location. There should be no user visible changes unless they turn on debug output. --- gdb/breakpoint.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c8c34120aa0..29a02945234 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -161,6 +161,8 @@ static std::vector bkpt_probe_decode_location_spec static bool bl_address_is_meaningful (bp_location *loc); +static int find_loc_num_by_location (const bp_location *loc); + /* update_global_location_list's modes of operation wrt to whether to insert locations now. */ enum ugll_insert_mode @@ -5298,6 +5300,8 @@ bpstat_check_watchpoint (bpstat *bs) static void bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) { + INFRUN_SCOPED_DEBUG_ENTER_EXIT; + const struct bp_location *bl; struct breakpoint *b; /* Assume stop. */ @@ -5312,6 +5316,10 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) b = bs->breakpoint_at; gdb_assert (b != NULL); + infrun_debug_printf ("thread = %s, breakpoint %d.%d", + thread->ptid.to_string ().c_str (), + b->number, find_loc_num_by_location (bl)); + /* Even if the target evaluated the condition on its end and notified GDB, we need to do so again since GDB does not know if we stopped due to a breakpoint or a single step breakpoint. */ @@ -5319,6 +5327,9 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) if (frame_id_p (b->frame_id) && !frame_id_eq (b->frame_id, get_stack_frame_id (get_current_frame ()))) { + infrun_debug_printf ("incorrect frame %s not %s, not stopping", + get_stack_frame_id (get_current_frame ()).to_string ().c_str (), + b->frame_id.to_string ().c_str ()); bs->stop = 0; return; } @@ -5329,6 +5340,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) if ((b->thread != -1 && b->thread != thread->global_num) || (b->task != 0 && b->task != ada_get_task_number (thread))) { + infrun_debug_printf ("incorrect thread or task, not stopping"); bs->stop = 0; return; } @@ -5420,16 +5432,26 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) if (cond && !condition_result) { + infrun_debug_printf ("condition_result = false, not stopping"); bs->stop = 0; + return; } else if (b->ignore_count > 0) { + infrun_debug_printf ("ignore count %d, not stopping", + b->ignore_count); b->ignore_count--; bs->stop = 0; /* Increase the hit count even though we don't stop. */ ++(b->hit_count); gdb::observers::breakpoint_modified.notify (b); - } + return; + } + + if (bs->stop) + infrun_debug_printf ("stopping at this breakpoint"); + else + infrun_debug_printf ("not stopping at this breakpoint"); } /* Returns true if we need to track moribund locations of LOC's type @@ -13142,7 +13164,7 @@ enable_disable_bp_num_loc (int bp_num, int loc_num, bool enable) owner. 1-based indexing. -1 signals NOT FOUND. */ static int -find_loc_num_by_location (bp_location *loc) +find_loc_num_by_location (const bp_location *loc) { if (loc != nullptr && loc->owner != nullptr) { -- 2.25.4