This is the mail archive of the gdb-patches@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: wrong assumptions about pthread_t being numeric


On Saturday 17 September 2011 00:13:10, John Spencer wrote:
> On 09/17/2011 01:00 AM, Pedro Alves wrote:
> >
> > These are only built natively on solaris and aix respectively, so
> > let's just leave them alone.
> >
> 
> I expected it to be desirable for a product in industrial use to be 
> standard-compliant and not invoking undefined behavior.

Those files are tied to those platforms' thread_db/libc implementations.
There's absolutely no need to handle some other hipotetical libc that
defines pthread_t diferently there.  If it appears, we'll handle it.
Chances are, some other changes would be necessary to make it really
work, not just build.

> >> thread-db.c: In function 'find_one_thread':
> >> thread-db.c:295:7: error: format '%ld' expects type 'long int', but
> >> argument 3 has type 'thread_t'
> >> thread-db.c: In function 'attach_thread':
> >> thread-db.c:335:7: error: format '%ld' expects type 'long int', but
> >> argument 3 has type 'thread_t'
> >> thread-db.c:341:9: error: format '%ld' expects type 'long int', but
> >> argument 2 has type 'thread_t'
> > So just cast it to long, and you're done.
> >
> 
> pthread_t could legally be a struct, which you can't just cast to a long.

No need to complicate things for an hipotetical scenario.  The set of
libc's in existence is finite.  If we were to handle a struct pthread_t,
we'd need to be able to print it, and so we'd need some libc specific
way to do it, something autoconf'ed.  There's no need to invent work.

-- 
Pedro Alves


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