From: "Thomas,Stephen" <stephen.thomas@superh.com>
To: "Andrew Cagney" <ac131313@redhat.com>,
"Rennecke,Joern" <joern.rennecke@superh.com>
Cc: <gdb@sources.redhat.com>, <newlib@sources.redhat.com>,
<bug-glibc@gnu.org>, "McGoogan,Sean" <sean.mcgoogan@superh.com>
Subject: RE: memset (0, 0, 0);
Date: Mon, 07 Apr 2003 09:22:00 -0000 [thread overview]
Message-ID: <9FF3133289A7A84E81E2ED8F5E56B379604384@sh-uk-ex01.uk.w2k.superh.com> (raw)
Hi,
gdb appears to call memset(0,0,0) from build_regcache() in gdb/regcache.c. I can't really claim to understand how this works, but this function appears to get called 3 times during gdb initialization:
static void build_regcache (void)
{
...
int sizeof_register_valid;
...
sizeof_register_valid = ((NUM_REGS + NUM_PSEUDO_REGS) * sizeof (*register_valid));
register_valid = xmalloc (sizeof_register_valid);
memset (register_valid, 0, sizeof_register_valid);
}
On the 1st time of calling, none of the gdbarch stuff is set up, so NUM_REGS = NUM_PSEUDO_REGS = 0. So xmalloc gets called with size=0. That returns 0 as the 'address', which gets passed to memset. I guess this just works OK on other architectures (it does on x86 anyway).
Easy enough to fix I suppose, but is that really the point?
Steve Thomas
SuperH (UK) Ltd.
-----Original Message-----
From: Andrew Cagney [mailto:ac131313@redhat.com]
Sent: 04 April 2003 16:17
To: Rennecke,Joern
Cc: gdb@sources.redhat.com; newlib@sources.redhat.com; bug-glibc@gnu.org; Thomas,Stephen; McGoogan,Sean
Subject: Re: memset (0, 0, 0);
> This conflicts with gdb usage of memset (0, 0, 0); in some places.
> There are three practical questions here:
> - should gdb use this idiom?
> - should all target-specific variants of newlib's memset implement it?
> - should all target-specific variants of glibc's memset implement it?
I'm not sure why you're refering to GDB here. GDB assumes ISO C and
hence should never use memset in ways that violate the ISO C spec. If
it is, then someone gets to fix it.
Andrew
next reply other threads:[~2003-04-07 9:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-07 9:22 Thomas,Stephen [this message]
2003-04-07 13:07 ` Daniel Jacobowitz
2003-04-07 17:18 ` Geoff Keating
-- strict thread matches above, loose matches on Subject: below --
2003-04-08 7:52 Thomas,Stephen
2003-04-08 13:10 ` Richard Earnshaw
2003-04-08 13:26 ` Daniel Jacobowitz
2003-04-08 16:40 ` Richard Earnshaw
2003-04-08 20:51 ` Andrew Cagney
2003-04-08 17:57 ` Richard Earnshaw
2003-04-04 16:12 Petr Vandrovec
2003-04-04 21:36 ` Andreas Schwab
2003-04-04 14:54 Joern Rennecke
2003-04-04 15:04 ` Daniel Jacobowitz
2003-04-04 15:16 ` Andrew Cagney
2003-04-04 15:21 ` Andreas Schwab
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=9FF3133289A7A84E81E2ED8F5E56B379604384@sh-uk-ex01.uk.w2k.superh.com \
--to=stephen.thomas@superh.com \
--cc=ac131313@redhat.com \
--cc=bug-glibc@gnu.org \
--cc=gdb@sources.redhat.com \
--cc=joern.rennecke@superh.com \
--cc=newlib@sources.redhat.com \
--cc=sean.mcgoogan@superh.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