public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "tpzker at thepuzzlemaker dot info" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug rust/29735] Can't have multiple breakpoints - crash otherwise
Date: Sat, 28 Oct 2023 18:55:13 +0000	[thread overview]
Message-ID: <bug-29735-4717-WUUD1hQtZK@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29735-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=29735

--- Comment #9 from The Puzzlemaker <tpzker at thepuzzlemaker dot info> ---
Comment on attachment 15198
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15198
Patch for this issue, or an issue similar to it

>From 07bb370168aab780c4780435ad3d9257ad8a474b Mon Sep 17 00:00:00 2001
>From: ThePuzzlemaker <tpzker@thepuzzlemaker.info>
>Date: Sat, 28 Oct 2023 13:28:33 -0500
>Subject: [PATCH] Fix assertion fail from `rust_lang::print_enum`
>
>This commit fixes an assertion fail in `rust_lang::print_enum` related
>to the handling of field numbers for variant types.
>---
> gdb/rust-lang.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
>diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
>index 74808ad0716..9acd2e1d2fa 100644
>--- a/gdb/rust-lang.c
>+++ b/gdb/rust-lang.c
>@@ -470,8 +470,18 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
>     }
> 
>   int variant_fieldno = rust_enum_variant (type);
>-  val = value_field (val, variant_fieldno);
>   struct type *variant_type = type->field (variant_fieldno).type ();
>+  /* HACK: variant_fieldno is indexed in 'type', which has the field
>+     disabled for other variants. The type of 'val' does not. Thus,
>+     iterate through the fields and find the one that matches. */
>+  for (int i = 0; i < value_type (val)->num_fields (); i++) {
>+    value* new_val = value_field (val, i);
>+    if (types_equal (value_type (new_val), variant_type)) {
>+      val = new_val;
>+      break;
>+    }
>+  }
>+  gdb_assert(types_equal(value_type (val), variant_type));
> 
>   int nfields = variant_type->num_fields ();
> 
>-- 
>2.42.0

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-10-28 18:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 13:25 [Bug gdb/29735] New: " amab8901 at protonmail dot com
2022-10-31 20:21 ` [Bug rust/29735] " tromey at sourceware dot org
2022-11-01  3:37 ` amab8901 at protonmail dot com
2022-11-01 13:38 ` tromey at sourceware dot org
2022-11-01 14:27 ` amab8901 at protonmail dot com
2022-11-02 19:47 ` tromey at sourceware dot org
2023-03-08  0:28 ` tromey at sourceware dot org
2023-10-28 18:34 ` tpzker at thepuzzlemaker dot info
2023-10-28 18:51 ` tpzker at thepuzzlemaker dot info
2023-10-28 18:55 ` tpzker at thepuzzlemaker dot info [this message]
2023-10-28 20:46 ` tromey at sourceware dot org
2023-10-28 20:48 ` tromey at sourceware dot org
2023-10-28 20:56 ` tpzker at thepuzzlemaker dot info
2023-10-28 20:57 ` tpzker at thepuzzlemaker dot info
2023-10-28 21:08 ` tpzker at thepuzzlemaker dot info
2023-10-29 10:06 ` sam at gentoo dot org
2023-11-24 16:30 ` tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29735-4717-WUUD1hQtZK@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).