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.129.124]) by sourceware.org (Postfix) with ESMTPS id 7D62F3858C60 for ; Wed, 8 Feb 2023 15:16:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D62F3858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m3ITgZPLostgYabN73l65NsmmyZyV0Akq3kySWLGyGY=; b=QD9E2Vn072apaQQJQP7vDfhq7ttI0yBDJOzRVHu+dgRjsvMR9chEM4Ta5IUrQIH7KJUPsu 907+pmM2bKMx9Y7LOJ+tzE3I1UFpJOhmKWQAt0a+qut/epzLkrzdYFOUPrFd4osPHhS7aL Pny6vBF0S+r68vLpyRtcFPxMkEUB16U= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-247-oDLPsFLEOquQP3TJ_cqDNw-1; Wed, 08 Feb 2023 10:16:31 -0500 X-MC-Unique: oDLPsFLEOquQP3TJ_cqDNw-1 Received: by mail-qk1-f197.google.com with SMTP id u10-20020a05620a0c4a00b00705e77d6207so12140905qki.5 for ; Wed, 08 Feb 2023 07:16:30 -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: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=m3ITgZPLostgYabN73l65NsmmyZyV0Akq3kySWLGyGY=; b=7qN/JIESTKHqJEAYtp+JuZqZwJ18Mx/AMAjDw4CTGcfOimk+atCY2laPchS95tfRpP FJdIT6imdyLSfVTOW8YGLqWqMpf/gzBOF9NwWhy5nfbqs0hV7s52ia8dQiTXOyf9RDR+ K0nrAPiiecM0374RcZolf9Qpk01ZNTGZA+mOLHboNclMY+xpwLMk/E9YTstcZ4BKAzTI sLSRmfogrNQAXbX/u9sKLBLCo3fMaMOdUb02LOL04HtX5JcOKUFQQwfXuL4T7xZz0Phx VrbgJj6ggGGlhrVIvwgrA7jiFWoquKpkNYc0dDNdQ7GVSs5rd23jotLtMclb+iuhiHTG Zu+Q== X-Gm-Message-State: AO0yUKXM3J/4qFMHiyMDzJYEaN6NWPuw7H7AtDg3UZ6kJqJW9giGxHY+ AHv0m7zcUvshpQTABC9t1ELrTKgxzeke3UUVKe5kGwUDQArt7ezAvdwT6xPOmd9cjiy5ulW2f45 BFc5Q6VjOMKGCdhCLTUoZXCKquJnjkUodNTKGZmWCYJlY9AOhJgjpc4z/1We3MfAGCwZSbo446F ya+uw= X-Received: by 2002:a05:6214:c25:b0:56b:eca6:fa25 with SMTP id a5-20020a0562140c2500b0056beca6fa25mr12036862qvd.10.1675869389957; Wed, 08 Feb 2023 07:16:29 -0800 (PST) X-Google-Smtp-Source: AK7set8DspqtDG545LSD2hi3GQHoXXkkzJAKu/rJzrN2+w5Sd5H0kWk+VdDD1YG+INK/HELDEJHD/w== X-Received: by 2002:a05:6214:c25:b0:56b:eca6:fa25 with SMTP id a5-20020a0562140c2500b0056beca6fa25mr12036804qvd.10.1675869389442; Wed, 08 Feb 2023 07:16:29 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id l12-20020a05622a050c00b003b960aad697sm12002514qtx.9.2023.02.08.07.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 07:16:29 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/2] gdb: use -1 for breakpoint::task default value Date: Wed, 8 Feb 2023 15:16:17 +0000 Message-Id: <6ab8502906e90c53dbb2a758f2e02acab05da4ee.1675869267.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: 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=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: Within the breakpoint struct we have two fields ::thread and ::task which are used for thread or task specific breakpoints. When a breakpoint doesn't have a specific thread or task then these fields have the values -1 and 0 respectively. There's no particular reason (as far as I can tell) why these two "default" values are different, and I find the difference a little confusing. Long term I'd like to potentially fold these two fields into a single field, but that isn't what this commit does. What this commit does is switch to using -1 as the "default" value for both fields, this means that the default for breakpoint::task has changed from 0 to -1. I've updated all the code I can find that relied on the value of 0, and I see no test regressions, especially in gdb.ada/tasks.exp, which still fully passes. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 36 ++++++++++++++++++------------------ gdb/breakpoint.h | 10 +++++----- gdb/guile/scm-breakpoint.c | 6 +++--- gdb/python/py-breakpoint.c | 6 +++--- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8963b10d516..4792bc8263d 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1462,7 +1462,7 @@ breakpoint_set_thread (struct breakpoint *b, int thread) /* It is invalid to set the thread field to anything other than -1 (which means no thread restriction) if a task restriction is already in place. */ - gdb_assert (thread == -1 || b->task == 0); + gdb_assert (thread == -1 || b->task == -1); int old_thread = b->thread; @@ -1476,10 +1476,10 @@ breakpoint_set_thread (struct breakpoint *b, int thread) void breakpoint_set_task (struct breakpoint *b, int task) { - /* It is invalid to set the task field to anything other than 0 (which + /* It is invalid to set the task field to anything other than -1 (which means no task restriction) if a thread restriction is already in place. */ - gdb_assert (task == 0 || b->thread == -1); + gdb_assert (task == -1 || b->thread == -1); int old_task = b->task; @@ -5473,7 +5473,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) evaluating the condition if this isn't the specified thread/task. */ if ((b->thread != -1 && b->thread != thread->global_num) - || (b->task != 0 && b->task != ada_get_task_number (thread))) + || (b->task != -1 && b->task != ada_get_task_number (thread))) { infrun_debug_printf ("incorrect thread or task, not stopping"); bs->stop = false; @@ -6487,7 +6487,7 @@ print_one_breakpoint_location (struct breakpoint *b, { if (b->thread != -1) uiout->field_signed ("thread", b->thread); - else if (b->task != 0) + else if (b->task != -1) uiout->field_signed ("task", b->task); } @@ -6544,7 +6544,7 @@ print_one_breakpoint_location (struct breakpoint *b, uiout->text ("\n"); } - if (!part_of_multiple && b->task != 0) + if (!part_of_multiple && b->task != -1) { uiout->text ("\tstop only in task "); uiout->field_signed ("task", b->task); @@ -8447,7 +8447,7 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, gdb_assert (!sals.empty ()); /* At most one of thread or task can be set on any breakpoint. */ - gdb_assert (thread == -1 || task == 0); + gdb_assert (thread == -1 || task == -1); thread = thread_; task = task_; @@ -8763,7 +8763,7 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, { cond_string->reset (); *thread = -1; - *task = 0; + *task = -1; rest->reset (); bool force = false; @@ -8816,7 +8816,7 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, if (*thread != -1) error(_("You can specify only one thread.")); - if (*task != 0) + if (*task != -1) error (_("You can specify only one of thread or task.")); tok = end_tok + 1; @@ -8830,7 +8830,7 @@ find_condition_and_thread (const char *tok, CORE_ADDR pc, { char *tmptok; - if (*task != 0) + if (*task != -1) error(_("You can specify only one task.")); if (*thread != -1) @@ -8871,7 +8871,7 @@ find_condition_and_thread_for_sals (const std::vector &sals, { gdb::unique_xmalloc_ptr cond; int thread_id = -1; - int task_id = 0; + int task_id = -1; gdb::unique_xmalloc_ptr remaining; /* Here we want to parse 'arg' to separate condition from thread @@ -8886,7 +8886,7 @@ find_condition_and_thread_for_sals (const std::vector &sals, &task_id, &remaining); *cond_string = std::move (cond); /* At most one of thread or task can be set. */ - gdb_assert (thread_id == -1 || task_id == 0); + gdb_assert (thread_id == -1 || task_id == -1); *thread = thread_id; *task = task_id; *rest = std::move (remaining); @@ -8988,7 +8988,7 @@ create_breakpoint (struct gdbarch *gdbarch, { struct linespec_result canonical; bool pending = false; - int task = 0; + int task = -1; int prev_bkpt_count = breakpoint_count; gdb_assert (ops != NULL); @@ -10060,7 +10060,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, the hardware watchpoint. */ bool use_mask = false; CORE_ADDR mask = 0; - int task = 0; + int task = -1; /* Make sure that we actually have parameters to parse. */ if (arg != NULL && arg[0] != '\0') @@ -10107,7 +10107,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, if (thread != -1) error(_("You can specify only one thread.")); - if (task != 0) + if (task != -1) error (_("You can specify only one of thread or task.")); /* Extract the thread ID from the next token. */ @@ -10123,7 +10123,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, { char *tmp; - if (task != 0) + if (task != -1) error(_("You can specify only one task.")); if (thread != -1) @@ -10305,7 +10305,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, w.reset (new watchpoint (nullptr, bp_type)); /* At most one of thread or task can be set on a watchpoint. */ - gdb_assert (thread == -1 || task == 0); + gdb_assert (thread == -1 || task == -1); w->thread = thread; w->task = task; w->disposition = disp_donttouch; @@ -14143,7 +14143,7 @@ breakpoint::print_recreate_thread (struct ui_file *fp) const if (thread != -1) gdb_printf (fp, " thread %d", thread); - if (task != 0) + if (task != -1) gdb_printf (fp, " task %d", task); gdb_printf (fp, "\n"); diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 5228c38fe02..03aecd15eff 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -802,9 +802,9 @@ struct breakpoint care. */ int thread = -1; - /* Ada task number for task-specific breakpoint, or 0 if don't + /* Ada task number for task-specific breakpoint, or -1 if don't care. */ - int task = 0; + int task = -1; /* Count of the number of times this breakpoint was taken, dumped with the info, but not used for anything else. Useful for seeing @@ -1680,9 +1680,9 @@ extern void breakpoint_set_silent (struct breakpoint *b, int silent); extern void breakpoint_set_thread (struct breakpoint *b, int thread); -/* Set the task for this breakpoint. If TASK is 0, make the breakpoint - work for any task. Passing a value other than 0 for TASK should only be - done if b->thread is -1; it is not valid to try and set both a thread +/* Set the task for this breakpoint. If TASK is -1, make the breakpoint + work for any task. Passing a value other than -1 for TASK should only + be done if b->thread is -1; it is not valid to try and set both a thread and task restriction on a breakpoint. */ extern void breakpoint_set_task (struct breakpoint *b, int task); diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index d4f2b7310bd..2931df265d7 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -774,7 +774,7 @@ gdbscm_set_breakpoint_thread_x (SCM self, SCM newvalue) _("invalid thread id")); } - if (bp_smob->bp->task != 0) + if (bp_smob->bp->task != -1) scm_misc_error (FUNC_NAME, _("cannot set both task and thread attributes"), SCM_EOL); @@ -797,7 +797,7 @@ gdbscm_breakpoint_task (SCM self) breakpoint_smob *bp_smob = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - if (bp_smob->bp->task == 0) + if (bp_smob->bp->task == -1) return SCM_BOOL_F; return scm_from_long (bp_smob->bp->task); @@ -840,7 +840,7 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue) SCM_EOL); } else if (gdbscm_is_false (newvalue)) - id = 0; + id = -1; else SCM_ASSERT_TYPE (0, newvalue, SCM_ARG2, FUNC_NAME, _("integer or #f")); diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 52298935242..ecf52a4637c 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -271,7 +271,7 @@ bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure) return -1; } - if (self_bp->bp->task != 0) + if (self_bp->bp->task != -1) { PyErr_SetString (PyExc_RuntimeError, _("Cannot set both task and thread attributes.")); @@ -337,7 +337,7 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) } } else if (newvalue == Py_None) - id = 0; + id = -1; else { PyErr_SetString (PyExc_TypeError, @@ -711,7 +711,7 @@ bppy_get_task (PyObject *self, void *closure) BPPY_REQUIRE_VALID (self_bp); - if (self_bp->bp->task == 0) + if (self_bp->bp->task == -1) Py_RETURN_NONE; return gdb_py_object_from_longest (self_bp->bp->task).release (); -- 2.25.4