Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Hannes Domani <ssbssa@yahoo.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Use enums for human-readable exception information.
Date: Fri, 07 Feb 2020 22:02:00 -0000	[thread overview]
Message-ID: <854a3dec-e7db-4ccd-eb63-bdebb6af5281@simark.ca> (raw)
In-Reply-To: <20200117153140.2231-2-ssbssa@yahoo.de>

On 2020-01-17 10:31 a.m., Hannes Domani via gdb-patches wrote:
> Changes to $_siginfo type to this:
> 
> (gdb) pt $_siginfo
> type = struct EXCEPTION_RECORD {
>     enum ExceptionCode ExceptionCode;
>     unsigned int ExceptionFlags;
>     struct EXCEPTION_RECORD *ExceptionRecord;
>     void *ExceptionAddress;
>     unsigned int NumberParameters;
>     union {
>         void *ExceptionInformation[15];
>         struct {...} AccessViolationInformation;
>     };
> }
> (gdb) pt $_siginfo.ExceptionCode
> type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
>     DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
>     DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
>     ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
>     ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
>     INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
>     FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
>     FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
>     FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
>     PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
> (gdb) pt $_siginfo.AccessViolationInformation
> type = struct {
>     enum ViolationType Type;
>     void *Address;
> }
> (gdb) pt $_siginfo.AccessViolationInformation.Type
> type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
>     DATA_EXECUTION_PREVENTION_VIOLATION = 8}
> 
> Which makes it easier to understand the reason of the exception:
> 
> (gdb) p $_siginfo
> $1 = {
>   ExceptionCode = ACCESS_VIOLATION,
>   ExceptionFlags = 0,
>   ExceptionRecord = 0x0,
>   ExceptionAddress = 0x401632 <main+18>,
>   NumberParameters = 2,
>   {
>     ExceptionInformation = {0x1, 0x123, 0x0 <repeats 13 times>},
>     AccessViolationInformation = {
>       Type = WRITE_ACCESS_VIOLATION,
>       Address = 0x123
>     }
>   }
> }

Well, this kind of goes against the last comment I left on patch 1 (to use the
actual types found in the real structure), but I think that what you are
suggesting here is quite convenient, so I wouldn't be against doing something
like that.

Please add a bit of comments to your code to explain what you are doing.  Since
you are inventing types that don't exist in the documentation, it's not obvious
to know what this is doing.

Simon


  reply	other threads:[~2020-02-07 22:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200117153140.2231-1-ssbssa.ref@yahoo.de>
2020-01-17 15:32 ` [PATCH 1/2] Display ExceptionRecord for $_siginfo Hannes Domani via gdb-patches
2020-01-17 15:36   ` [PATCH 2/2] Use enums for human-readable exception information Hannes Domani via gdb-patches
2020-02-07 22:02     ` Simon Marchi [this message]
2020-02-07 21:56   ` [PATCH 1/2] Display ExceptionRecord for $_siginfo Simon Marchi
2020-02-07 22:07     ` Simon Marchi
2020-02-07 22:17       ` Hannes Domani via gdb-patches
2020-02-07 22:14     ` Hannes Domani via gdb-patches
2020-02-11 15:28     ` Tom Tromey
2020-02-11 16:56       ` Hannes Domani via gdb-patches

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=854a3dec-e7db-4ccd-eb63-bdebb6af5281@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    /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