public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/28104] Incorrect extraction of boolean fields in target description "struct" data type Date: Mon, 02 Aug 2021 11:07:32 +0000 [thread overview] Message-ID: <bug-28104-4717-GaaW4yGSNB@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-28104-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=28104 --- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> --- The gdb-11-branch branch has been updated by Shahab Vahedi <shahab@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e4c1aea498ff84bcb3086509d125ac8249f35db2 commit e4c1aea498ff84bcb3086509d125ac8249f35db2 Author: Shahab Vahedi <shahab@synopsys.com> Date: Mon Jul 19 16:13:47 2021 +0200 gdb: Make the builtin "boolean" type an unsigned type When printing the fields of a register that is of a custom struct type, the "unpack_bits_as_long ()" function is used: do_val_print (...) cp_print_value_fields (...) value_field_bitfield (...) unpack_value_bitfield (...) unpack_bits_as_long (...) This function may sign-extend the extracted field while returning it: val >>= lsbcount; if (...) { valmask = (((ULONGEST) 1) << bitsize) - 1; val &= valmask; if (!field_type->is_unsigned ()) if (val & (valmask ^ (valmask >> 1))) val |= ~valmask; } return val; lsbcount: Number of lower bits to get rid of. bitsize: The bit length of the field to be extracted. val: The register value. field_type: The type of field that is being handled. While the logic here is correct, there is a problem when it is handling "field_type"s of "boolean". Those types are NOT marked as "unsigned" and therefore they end up being sign extended. Although this is not a problem for "false" (0), it definitely causes trouble for "true". This patch constructs the builtin boolean type as such that it is marked as an "unsigned" entity. The issue tackled here was first encountered for arc-elf32 target running on an x86_64 machine. The unit-test introduced in this change has passed for all the targets (--enable-targets=all) running on the same x86_64 host. gdb/ChangeLog: PR gdb/28104 * gdbtypes.c (gdbtypes_post_init): Use "arch_boolean_type (..., unsigned=1, ...) to construct "boolean". cp-valprint.c (test_print_flags): New. (_initialize_cp_valprint): Run the "test_print_flags" unit-test. -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2021-08-02 11:07 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-19 14:41 [Bug gdb/28104] New: " shahab.vahedi at gmail dot com 2021-07-19 14:41 ` [Bug gdb/28104] " shahab.vahedi at gmail dot com 2021-07-26 13:55 ` shahab.vahedi at gmail dot com 2021-07-26 13:56 ` shahab.vahedi at gmail dot com 2021-08-02 11:03 ` andrew.burgess at embecosm dot com 2021-08-02 11:07 ` cvs-commit at gcc dot gnu.org [this message] 2021-08-02 11:20 ` shahab.vahedi at gmail dot com
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-28104-4717-GaaW4yGSNB@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: linkBe 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).