Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Matt Rice <ratmice@gmail.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] Be in language c more c++ compatible
Date: Sat, 23 Jul 2011 22:12:00 -0000	[thread overview]
Message-ID: <CACTLOFrQSr3AsYCsEpEB1rHmpxu8vRJeaMO62iYVY4KZpd=T1A@mail.gmail.com> (raw)
In-Reply-To: <20110715191920.GA29975@host1.jankratochvil.net>

[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]

On Fri, Jul 15, 2011 at 12:19 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> Hi,
>
> I always see some terrible C++ GDB bug so I fix in some hours and then find out
> it works in GDB when one has `set language c++'.  This usually happens with
> artificial testcases like the one today:
>        http://sourceware.org/ml/gdb-patches/2011-07/msg00387.html

was curious what it did with the attached objc++ version.

which isn't really a supported language by any means.
gdb considers it to be 'minimal'/doesn't recognize the CU language in
the debuginfo.  and it is difficult to say how meaningful it would be
if it did.
I imagine gdb wants DW_TAG_partial_unit/DW_AT_language when
switching between c++/objective-c functions, I hadn't been able to
coax this out of gcc

anyhow the last line was a bit suprising.

gcc -g -o objcxx objc++.mm -lobjc

GNU gdb (GDB) Fedora (7.2-51.fc14)
(gdb) set language c++
(gdb) whatis C::t
No symbol "C" in current context.
(gdb) set language objective-c
(gdb) whatis C::t
No symbol "C" in current context.
(gdb) break main
Breakpoint 1 at 0x400808: file objc++.mm, line 47.
(gdb) r
Breakpoint 1, main () at objc++.mm:47
47	  Foo *foo = [[Foo alloc] init];
Warning: the current language does not match this frame.
(gdb) whatis C::t
type = t
(gdb) show language
The current source language is "objective-c".
Warning: the current language does not match this frame.
(gdb) set language c++
(gdb) whatis C::t
A syntax error in expression, near `'.

[-- Attachment #2: objc++.mm --]
[-- Type: text/plain, Size: 441 bytes --]

#include <objc/Object.h>

class C { 
  public:
  typedef int t;
  C();
  C(t);
  t i;
} c;

C::C()
{
  i = 9;
}

C::C(t x)
{
  i = x;
}

@interface Foo : Object
{
  @public
    C::t i;
}
- (C::t) bar;
@end

@implementation Foo
- (id) init
{
  if ((self = [super init]))
    i = 5;

  return self;
}

- (C::t) bar 
{
  return i;
}

@end

int main()
{
  Foo *foo = [[Foo alloc] init];
  C c = C([foo bar]);
  printf("%i %i\n", foo->i, c.i);
}

  parent reply	other threads:[~2011-07-23 21:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-15 20:47 Jan Kratochvil
2011-07-16  8:42 ` Tom Tromey
2011-07-16  9:45   ` Jan Kratochvil
2011-07-23 21:17 ` Mark Kettenis
2011-07-23 21:38   ` Jan Kratochvil
2011-07-25 15:00   ` Tom Tromey
2011-07-23 22:12 ` Matt Rice [this message]
2011-07-24 15:59   ` Jan Kratochvil
2011-07-24 15:59     ` Matt Rice
2011-07-25 14:52       ` Tom Tromey

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='CACTLOFrQSr3AsYCsEpEB1rHmpxu8vRJeaMO62iYVY4KZpd=T1A@mail.gmail.com' \
    --to=ratmice@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@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