[llvm-dev] [cfe-dev] Printing while developing on LLVM/Clang code

via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 11 08:46:12 PST 2021


I don't have any problems with printing inside gdb.
Except that we lack a bunch of pretty-printers which is unpleasant.
In those cases, you can use the `dump` method of the corresponding entity. However, evaluating that function might cause a crash.

  print SVal->dump()

Once, I tried to create gdb pretty-printers for the Clang Static Analyzer related types, but it would depend on the pretty printers for other Clang specific types such as `FunctionDecl` etc.
It would require a huge effort of implementing every pretty-printer transitively. 2x -  once for gdb and once for lldb.
It would be a huge win for the debugging experience, especially if someone uses an IDE.

Debug symbols + LLVM_ENABLE_ASSERTIONS and LLVM_ENABLE_DUMP usually enough for me.
BTW you can always use `llvm::dbgs() << "hello"`, `llvm::outs()` or `llvm::errs()` instead of the usual iostreams.

Sometimes a few debug statements are beneficial.
IMO you can leave a few of those are wrapped inside the `LLVM_DEBUG` macro. grep a few examples to see if that fits your needs.

Cheers, Balazs.

-----Original Message-----
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of David Blaikie via cfe-dev
Sent: 2021. február 11., csütörtök 17:02
To: Deep Majumder <deep.majumder2019 at gmail.com>
Cc: llvm-dev <llvm-dev at lists.llvm.org>; Clang Dev <cfe-dev at lists.llvm.org>
Subject: Re: [cfe-dev] [llvm-dev] Printing while developing on LLVM/Clang code

dump functions, as Matt mentioned, are probably the immediate go-to.
Otherwise if you want to improve 'print <expr>' support, it probably involves writing pretty printers like/in here:
llvm/utils/lldbDataFormatters.py

On Thu, Feb 11, 2021 at 4:20 AM Deep Majumder via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> Hi everyone,
> I have found that `print <expr>` often doesn't work while running a debug build of clang in lldb. So I have to resort to print statements. Since <iostream> is not used inside LLVM/Clang code, I have to include it in manually and remember to remove it before committing. Is there a better way to do this, either in lldb or insert print statements?
> Warm regards,
> Deep
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the llvm-dev mailing list