mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 22:02:41 +01:00
- 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>
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// This library contains functions to assist dumping objects to stderr during
|
|
// interactive debugging. Functions named `Dump` are intended for direct use by
|
|
// developers, and should use overload resolution to determine which will be
|
|
// invoked. The debugger should do namespace resolution automatically. For
|
|
// example:
|
|
//
|
|
// - lldb: `expr Dump(tokens, id)`
|
|
// - gdb: `call Dump(tokens, id)`
|
|
//
|
|
// The `DumpNoNewline` functions are helpers that exclude a trailing newline.
|
|
// They're intended to be composed by `Dump` function implementations.
|
|
|
|
#ifndef CARBON_TOOLCHAIN_LEX_DUMP_H_
|
|
#define CARBON_TOOLCHAIN_LEX_DUMP_H_
|
|
|
|
#ifndef NDEBUG
|
|
|
|
#include "toolchain/lex/tokenized_buffer.h"
|
|
|
|
namespace Carbon::Lex {
|
|
|
|
auto DumpNoNewline(const TokenizedBuffer& tokens, TokenIndex token) -> void;
|
|
|
|
auto Dump(const TokenizedBuffer& tokens, TokenIndex token) -> void;
|
|
|
|
} // namespace Carbon::Lex
|
|
|
|
#endif // NDEBUG
|
|
|
|
#endif // CARBON_TOOLCHAIN_LEX_DUMP_H_
|