mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add Dump functions to Check, Parse, and Lex (#4669)
- Provide `Check::Dump(context, arg)` and similar. - gdb and lldb should do contextual lookup, and `call Dump(*this, Lex::TokenIndex::Invalid)` has been tested with gdb. - Since this is only for debug, keeps the functions fully separated from code. - Uses alwayslink to ensure objects are correctly linked, even though there are no calls. - `-Wno-missing-prototypes` is needed when we don't have forward declarations. - Code is not linked in opt builds, using `#ifndef NDEBUG`. - This probably could be doing something in BUILD files with a `select()`, but the `#ifndef` seemed easier. This is based on #4620, but uses free functions instead of member functions. Co-authored-by: Dana Jansens <danakj@orodu.net> --------- Co-authored-by: danakj <danakj@orodu.net>
This commit is contained in:
co-authored by
Dana Jansens
parent
79ba184dab
commit
3ce0df67bb
@@ -23,6 +23,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
- [Reviewing test deltas](#reviewing-test-deltas)
|
||||
- [Verbose output](#verbose-output)
|
||||
- [Stack traces](#stack-traces)
|
||||
- [Dumping objects in interactive debuggers](#dumping-objects-in-interactive-debuggers)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
@@ -496,3 +497,13 @@ While the iterative processing pattern means function stack traces will have
|
||||
minimal context for how the current function is reached, we use LLVM's
|
||||
`PrettyStackTrace` to include details about the state stack. The state stack
|
||||
will be above the function stack in crash output.
|
||||
|
||||
### Dumping objects in interactive debuggers
|
||||
|
||||
We provide namespace-scoped `Dump` functions in several components, such as
|
||||
[check/dump.cpp](/toolchain/check/dump.cpp). These `Dump` functions will print
|
||||
contextual information about an object to stderr. The files contain details
|
||||
regarding support.
|
||||
|
||||
Objects which inherit from `Printable` also have `Dump` member functions, but
|
||||
these will lack contextual information.
|
||||
|
||||
Reference in New Issue
Block a user