This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GDB transition to GPLv3 should now be complete


> Date: Fri, 24 Aug 2007 12:54:39 -0400
> From: Daniel Jacobowitz <drow@false.org>
> 
> On Fri, Aug 24, 2007 at 06:16:25PM +0200, Mark Kettenis wrote:
> > 1. There is quite a bit of code that uses "unsigned char *" for
> >    strings, to avoid unwanted sign extension.
> 
> This is the real question, yes.  I've made it even easier to view
> these as strings if desired.  I've asked several times if the changes
> were good enough.  I think I got a generally affirmative reaction, but
> it's hard to tell.

Well, the problem with this diff is that it actually seems to be a
good idea until you actually start to use it.  I thought it was a good
idea, so I put it in my tree.  And I threw it out again after a few
days because I was annoyed by the fact that it didn't print strings as
strings in many cases where I was sure it did before.  As I said, the
use of "unsigned char *" is very common in string manipulation code.

> We can't be right by default all the time, since there just isn't
> enough information.  What I'm suggesting is that the new behavior will
> be right more often than the old behavior.  I have worked with a
> variety of high performance computing and signal processing
> developers who are interested in unsigned single-byte data.

Yes, I can imagine that, but these people are working in fairly
specialized areas with specific requirements.

> If you're already using user-defined commands to print data, by the
> way, the difference is a non-issue.  I believe that covers much of
> the Emacs case.

But the developers you talk about above can easily do the same.  And
when I'm not specifically talking about Emacs when I talk about code
that does string manipulations.

> > 2. Not all debug formats (most notably stabs) do not make the
> >    distinction between unqualified "char" and "(un)signed char".
> 
> That does not seem to be correct, at least in the case of stabs.  Even
> with -gstabs (i.e. without GNU extensions to stabs), GDB correctly
> sets the NOSIGN and UNSIGNED flags for char variants (example below).
> I also checked the "maint print type" output and NOSIGN is set where
> I'd expect.  And it already gets set for types whose name is char in
> init_type; this also handles all typedefs to char, et cetera, as long
> as your debug format represents typedefs.  I admit it will leave
> "typedef char char_t" users having to type a couple extra characters
> to get a string if they're using mdebug...
> 
> I did find a bug in the stabs reader testing this, though.  It
> bypasses the NOSIGN check because it creates the type and then sets
> TYPE_NAME later.  Easy to fix.
> 
> drow@caradoc:~% cat foo.c
> char c;
> signed char d;
> unsigned char e;
> int main(){}
> 
> drow@caradoc:~% gcc -gstabs foo.c
> drow@caradoc:~% gdb ./a.out
> GNU gdb 6.6-debian
> ...
> (gdb) ptype c
> type = char
> (gdb) ptype d
> type = signed char
> (gdb) ptype e
> type = unsigned char

Ah, that fix would be very welcome.  Need to verify this with GCC
2.95.3 though.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]