From: jose.marchesi@oracle.com (Jose E. Marchesi)
To: Pedro Alves <palves@redhat.com>
Cc: Steve Ellcey <sellcey@imgtec.com>,
Sergio Durigan Junior <sergiodj@redhat.com>,
gdb-patches@sourceware.org
Subject: Re: Build failure with probe patch
Date: Thu, 19 Feb 2015 17:32:00 -0000 [thread overview]
Message-ID: <87vbix3iqm.fsf@oracle.com> (raw)
In-Reply-To: <54E6150B.9060808@redhat.com> (Pedro Alves's message of "Thu, 19 Feb 2015 16:53:31 +0000")
> > According to:
> >
> > <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874>
> >
> > This warning has been removed from GCC. And by looking at the code
> > referenced by it, I don't see anything wrong there. So I'd say you can
> > ignore this (and probably update your GCC).
> >
>
> I would like to avoid updating GCC if possible. I build on old systems
> because some of our customers use old systems. I don't know if gdb has
> a 'minimal GCC' that it can be compiled with like GCC and some other
> projects have. I tried changing the definition of 'dof' to be '
> bfd_byte *' instead of 'struct dtrace_dof_hdr *' and then casting it on
> the call to dtrace_process_dof instead of the call to
> bfd_malloc_and_get_section.
>
> I think that version would still break the strict aliasing rules, since
> `struct dtrace_dof_hdr' does not alias bfd_byte, even if the latter is a
> character type.
Hmm, I thought that for aliasing, a typedef to char could
alias anything, as typedefs don't really create new types?
Yes, but not the other way around... it is not allowed to alias a
character type with a non-character type like in the following call to
dtrace_process_dof:
gdb_byte *buf;
[...]
dtrace_process_dof (sect, objfile, probesp, (struct dtrace_dof_hdr *) buf);
> As nothing guarantees that some future GCC version will not be bitching
> about it, what about using something like this instead?
>
> if (elf_section_data (sect)->this_hdr.sh_type == SHT_SUNW_dof)
> {
> /* Read the contents of the DOF section and then process it to
> extract the information of any probe defined into it. */
>
> bfd_size_type size;
> const void *buf = gdb_bfd_map_section (sect, &size);
> dtrace_process_dof (sect, objfile, probesp, (struct dtrace_dof_hdr *) buf);
> }
>
> AFAIU anything can alias a void pointer, as void pointers can't be
> dereferenced...
>
gdb_bfd_map_section may be better for making use of mmap if possible, but
note that even though that might shut up some versions of some compilers,
WRT to strict aliasing, that ends up being no different from Steve's
suggestion, plus with an intermediate void* cast. gdb_bfd_map_section
also returns a gdb_byte *. (And with C++, that'll end up needing
an explicit '(void *)' cast.).
I see, void is not allowed to alias a char... we are doomed! :D
Oh well, I guess we will have to use an union to avoid any possible
strict-aliasing warning... Can we assume C99 in GDB?
next prev parent reply other threads:[~2015-02-19 17:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-18 17:51 Steve Ellcey
2015-02-18 23:58 ` Sergio Durigan Junior
2015-02-19 0:48 ` Steve Ellcey
2015-02-19 4:39 ` Sergio Durigan Junior
2015-02-19 15:55 ` Jose E. Marchesi
2015-02-19 16:53 ` Pedro Alves
2015-02-19 17:32 ` Jose E. Marchesi [this message]
2015-02-19 17:48 ` Steve Ellcey
2015-02-19 20:41 ` Jose E. Marchesi
2015-02-19 21:18 ` Sergio Durigan Junior
2015-02-19 21:48 ` Steve Ellcey
2015-02-19 21:52 ` Sergio Durigan Junior
2015-02-19 21:59 ` Steve Ellcey
2015-02-19 18:30 ` Pedro Alves
2015-02-19 20:11 ` Jose E. Marchesi
2015-02-19 10:43 ` Pedro Alves
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=87vbix3iqm.fsf@oracle.com \
--to=jose.marchesi@oracle.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=sellcey@imgtec.com \
--cc=sergiodj@redhat.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