public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 09/10] Avoid undefined behavior in expression dumping
Date: Wed, 03 Oct 2018 17:48:00 -0000	[thread overview]
Message-ID: <bf1f2d52-9093-863f-ab7e-921042fd397d@redhat.com> (raw)
In-Reply-To: <20181002044420.17628-10-tom@tromey.com>

On 10/02/2018 05:44 AM, Tom Tromey wrote:
> -fsanitize=undefined pointed out undefined behavior in
> dump_raw_expression like:
> 
>     runtime error: load of value 2887952, which is not a valid value for type 'exp_opcode'
> 
> dump_raw_expression will try to print the opcode for each element of
> the expression, even when it is not valid.  To allow this, but have it
> avoid undefined behavior, this patch sets the underlying type of enum
> exp_opcode, and arranges for op_name to handle invalid opcodes more
> nicely.
> 
> Before this patch, debug-expr.exp shows:
> 
> Dump of expression @ 0x60f000007750, before conversion to prefix form:
> 	Language c, 8 elements, 16 bytes each.
> 	Index                Opcode         Hex Value  String Value
> 	    0               OP_TYPE  89  Y...............
>    <unknown 3851920>  107820862850704  ..:..b..........
> 	    2               OP_TYPE  89  Y...............
> 	    3          OP_VAR_VALUE  40  (...............
> 	    4     <unknown 2807568>  107820861806352  ..*..b..........
> 	    5     <unknown 2806368>  107820861805152  `.*..b..........
> 	    6          OP_VAR_VALUE  40  (...............
> 	    7      UNOP_MEMVAL_TYPE  57  9...............
> 
> Afterward, the output is:
> 
> Dump of expression @ 0x4820f90, before conversion to prefix form:
> 	Language c, 8 elements, 16 bytes each.
> 	Index                Opcode         Hex Value  String Value
> 	    0               OP_TYPE  89  Y...............
> 	    1   unknown opcode: 176  75444400  .0..............
> 	    2               OP_TYPE  89  Y...............
> 	    3          OP_VAR_VALUE  40  (...............
> 	    4               OP_BOOL  74616912  P.r.............
> 	    5   unknown opcode: 128  74615680  ..r.............
> 	    6          OP_VAR_VALUE  40  (...............
> 	    7      UNOP_MEMVAL_TYPE  57  9...............
> 

LGTM.  Thanks for adding the example.

Thanks,
Pedro Alves

  reply	other threads:[~2018-10-03 17:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02  4:44 [PATCH v2 00/10] Undefined Behavior Sanitizer, this time with docs Tom Tromey
2018-10-02  4:44 ` [PATCH v2 05/10] Avoid undefined behavior in read_subrange_type Tom Tromey
2018-10-02  4:44 ` [PATCH v2 03/10] Use unsigned as base type for some enums Tom Tromey
2018-10-03 17:33   ` Pedro Alves
2018-10-03 21:07     ` Tom Tromey
2018-10-02  4:44 ` [PATCH v2 01/10] Do not pass NULL to memcpy Tom Tromey
2018-10-02  4:44 ` [PATCH v2 06/10] Avoid undefined behavior in parse_number Tom Tromey
2018-10-02  4:44 ` [PATCH v2 02/10] Change dwarf2_frame_state_reg_info::reg to be std::vector Tom Tromey
2018-10-03 17:28   ` Pedro Alves
2018-10-03 21:05     ` Tom Tromey
2018-10-02  4:44 ` [PATCH v2 07/10] Avoid undefined behavior in read_signed_leb128 Tom Tromey
2018-10-02  4:44 ` [PATCH v2 04/10] Avoid undefined behavior in extract_integer Tom Tromey
2018-10-02  4:44 ` [PATCH v2 09/10] Avoid undefined behavior in expression dumping Tom Tromey
2018-10-03 17:48   ` Pedro Alves [this message]
2018-10-02  4:44 ` [PATCH v2 08/10] Avoid undefined behavior in ada_operator_length Tom Tromey
2018-10-02  4:44 ` [PATCH v2 10/10] Add --enable-ubsan Tom Tromey
2018-10-02 13:53   ` Eli Zaretskii
2018-10-02 21:26     ` Tom Tromey
2018-10-02 21:28       ` Tom Tromey
2018-10-03 17:31         ` Eli Zaretskii
2018-10-03 17:54   ` Pedro Alves
2018-10-03 21:09     ` Tom Tromey
2018-10-03 17:57 ` [PATCH v2 00/10] Undefined Behavior Sanitizer, this time with docs Pedro Alves
2018-10-03 21:09   ` Tom Tromey
2018-10-08 19:14 ` John Baldwin
2018-10-08 20:22   ` Joel Brobecker
2018-10-09 10:44     ` Pedro Alves
2018-10-12 21:07       ` Joel Brobecker
  -- strict thread matches above, loose matches on Subject: below --
2018-08-30  2:44 [PATCH v2 00/10] Enable undefined behavior sanitizer Tom Tromey
2018-08-30  2:44 ` [PATCH v2 09/10] Avoid undefined behavior in expression dumping Tom Tromey

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=bf1f2d52-9093-863f-ab7e-921042fd397d@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).