debugging llvm from clang using gdb

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

debugging llvm from clang using gdb

Reed Kotler
I've always debugged the backend llc by running it as a separate executable.

I'm seeing a bug that only happens when I run the compiler from clang.

How do you debug this from gdb?

I can put a breakpoint but it never stops when I say "run ...."

Tia.

Reed


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: debugging llvm from clang using gdb

Reid Kleckner-2
Are you debugging the driver process or the -cc1 process?  To get the -cc1 process, unfortunately you have to go through the dance of passing -### to get the -cc1 line and then run that in gdb (or write one manually).  Alternatively in gdb you can say "set follow-fork child" (or something, check the docs) to automatically follow into the -cc1 child.


On Tue, May 21, 2013 at 8:00 AM, reed kotler <[hidden email]> wrote:
I've always debugged the backend llc by running it as a separate executable.

I'm seeing a bug that only happens when I run the compiler from clang.

How do you debug this from gdb?

I can put a breakpoint but it never stops when I say "run ...."

Tia.

Reed


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: debugging llvm from clang using gdb

Tim Northover-2
In reply to this post by Reed Kotler
Hi Reed,

> I can put a breakpoint but it never stops when I say "run ...."

This is usually because clang forks off a process to do the actual
work. Try executing "set follow-fork-mode child" in gdb before running
clang.

I vaguely remember that running gdb against the "clang -cc1" command
works too (sometimes), but it's so rare that something is only
clang-debuggable that I've forgotten the details.

Cheers.

Tim.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: debugging llvm from clang using gdb

Reed Kotler
In reply to this post by Reid Kleckner-2
That did it. Thanks.

That's how I debug clang itself. I'm not using my head right now. :)

Reed

On 05/21/2013 05:35 AM, Reid Kleckner wrote:
Are you debugging the driver process or the -cc1 process?  To get the -cc1 process, unfortunately you have to go through the dance of passing -### to get the -cc1 line and then run that in gdb (or write one manually).  Alternatively in gdb you can say "set follow-fork child" (or something, check the docs) to automatically follow into the -cc1 child.


On Tue, May 21, 2013 at 8:00 AM, reed kotler <[hidden email]> wrote:
I've always debugged the backend llc by running it as a separate executable.

I'm seeing a bug that only happens when I run the compiler from clang.

How do you debug this from gdb?

I can put a breakpoint but it never stops when I say "run ...."

Tia.

Reed


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev