How do output hex in DOUT’s ?
Thanks,
Aaron
How do output hex in DOUT’s ?
Thanks,
Aaron
Please don’t use DOUT, please use:
DEBUG(errs() << stuff);
instead.
-Chris
How do output hex in DOUT’s ?
Please don’t use DOUT, please use:>
DEBUG(errs() << stuff);
instead.
Okay, I will modify my code. But how do I do hexadecimal output ?
Aaron
raw_ostream has a write_hex method.
O << "foo: ";
O.write_hex(42);
…
-Chris
I've got some more DOUT-involving patches in the queue. Is this
a general design choice that's been made? If so I can change the
patches to use errs() instead, but the choice should be documented
and DOUT should be marked deprecated if indeed that's the case.
-Dave
I'd prefer for it to be eliminated, but it is currently used widely. If your patches don't make it substantially worse, I won't have a problem with them. Bonus points for removing DOUTs though
-Chris
Ok, this is good to know. With some of these patches I will have
opportunities to remove DOUTS.
What's the rationale for getting rid of it?
-Dave
I'd prefer for it to be eliminated, but it is currently used widely.
If your patches don't make it substantially worse, I won't have a
problem with them. Bonus points for removing DOUTs thoughOk, this is good to know. With some of these patches I will have
opportunities to remove DOUTS.
Nice! Thanks,
What's the rationale for getting rid of it?
The big issue is things like this:
DOUT << foo.getName() << "\n";
When -debug is disable and even when assertions are turned off, foo.getName() is still called. When you use:
DEBUG(errs() << foo.getName() << "\n");
When assertions are turned off, the call doesn't exist. It is also a lot less "magic".
-Chris
The big issue is things like this:
DOUT << foo.getName() << "\n";
When -debug is disable and even when assertions are turned off,
foo.getName() is still called. When you use:
Yep, that's a problem.
DEBUG(errs() << foo.getName() << "\n");
When assertions are turned off, the call doesn't exist. It is also a
lot less "magic".
Why doesn't
DEBUG(DOUT << foo.getName() << "\n");
work? That's how I've always done it. A bit redundant perhaps, but it works.
In any event, errs() is probably nicer. I'll have to see if I can do some of
the tricks I did with DOUT in these patches. I think so, but I may be asking
questions in the future.
-Dave
2009/8/5 David Greene <dag@cray.com>
The big issue is things like this:
DOUT << foo.getName() << “\n”;
When -debug is disable and even when assertions are turned off,
foo.getName() is still called. When you use:Yep, that’s a problem.
Right !
DEBUG(errs() << foo.getName() << “\n”);
When assertions are turned off, the call doesn’t exist. It is also a
lot less “magic”.Why doesn’t
DEBUG(DOUT << foo.getName() << “\n”);
work? That’s how I’ve always done it. A bit redundant perhaps, but it works.
In any event, errs() is probably nicer. I’ll have to see if I can do some of
the tricks I did with DOUT in these patches. I think so, but I may be asking
questions in the future.
So I can say
DEBUG( err().write_hex(address); err() << “\n”; );
And can I say :-
DEBUG( err().write_hex(address) << “\n”; );
does it associate like that ?
Sorry I am away from my main computer on a laptop otherwise I would try it
Aaron
It is redundant, if you are using DEBUG there is no reason to provide
DOUT. And we didn't want to replicate the DOUT behavior for
raw_ostream, since it is was too much magic (and could hide
performance issues).
I didn't explicitly document that DOUT was deprecated, but I did
update the documentation here:
http://llvm.org/docs/ProgrammersManual.html#DEBUG
and put some comments in the 2.6 release notes about changing DOUT to DEBUG.
The main missing feature, which sparked this discussion, is the lack
of formatted output. Most clients don't use this, and we do have
llvm/Support/Format.h, so the hope is the move to DEBUG(errs ...) is
largely mechanical.
- Daniel
Yes. You can also use format objects from llvm/Support/Format.h, as in: