[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- SBSourceManager.cpp -----------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBSourceManager.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2011-09-13 08:29:56 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
2010-12-11 09:20:39 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBTarget.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include "lldb/API/SBFileSpec.h"
|
2011-09-13 08:29:56 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/SourceManager.h"
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/Stream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-10-01 10:59:24 +08:00
|
|
|
namespace lldb_private {
|
|
|
|
class SourceManagerImpl {
|
|
|
|
public:
|
2013-03-19 08:20:55 +08:00
|
|
|
SourceManagerImpl(const lldb::DebuggerSP &debugger_sp)
|
|
|
|
: m_debugger_wp(debugger_sp), m_target_wp() {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-03-19 08:20:55 +08:00
|
|
|
SourceManagerImpl(const lldb::TargetSP &target_sp)
|
|
|
|
: m_debugger_wp(), m_target_wp(target_sp) {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-01 10:59:24 +08:00
|
|
|
SourceManagerImpl(const SourceManagerImpl &rhs) {
|
|
|
|
if (&rhs == this)
|
|
|
|
return;
|
2013-03-19 08:20:55 +08:00
|
|
|
m_debugger_wp = rhs.m_debugger_wp;
|
|
|
|
m_target_wp = rhs.m_target_wp;
|
2011-10-01 10:59:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-01 10:59:24 +08:00
|
|
|
size_t DisplaySourceLinesWithLineNumbers(const lldb_private::FileSpec &file,
|
add stop column highlighting support
This change introduces optional marking of the column within a source
line where a thread is stopped. This marking will show up when the
source code for a thread stop is displayed, when the debug info
knows the column information, and if the optional column marking is
enabled.
There are two separate methods for handling the marking of the stop
column:
* via ANSI terminal codes, which are added inline to the source line
display. The default ANSI mark-up is to underline the column.
* via a pure text-based caret that is added in the appropriate column
in a newly-inserted blank line underneath the source line in
question.
There are some new options that control how this all works.
* settings set stop-show-column
This takes one of 4 values:
* ansi-or-caret: use the ANSI terminal code mechanism if LLDB
is running with color enabled; if not, use the caret-based,
pure text method (see the "caret" mode below).
* ansi: only use the ANSI terminal code mechanism to highlight
the stop line. If LLDB is running with color disabled, no
stop column marking will occur.
* caret: only use the pure text caret method, which introduces
a newly-inserted line underneath the current line, where
the only character in the new line is a caret that highlights
the stop column in question.
* none: no stop column marking will be attempted.
* settings set stop-show-column-ansi-prefix
This is a text format that indicates the ANSI formatting
code to insert into the stream immediately preceding the
column where the stop column character will be marked up.
It defaults to ${ansi.underline}; however, it can contain
any valid LLDB format codes, e.g.
${ansi.fg.red}${ansi.bold}${ansi.underline}
* settings set stop-show-column-ansi-suffix
This is the text format that specifies the ANSI terminal
codes to end the markup that was started with the prefix
described above. It defaults to: ${ansi.normal}. This
should be sufficient for the common cases.
Significant leg-work was done by Adrian Prantl. (Thanks, Adrian!)
differential review: https://reviews.llvm.org/D20835
reviewers: clayborg, jingham
llvm-svn: 282105
2016-09-22 04:13:14 +08:00
|
|
|
uint32_t line, uint32_t column,
|
2011-10-01 10:59:24 +08:00
|
|
|
uint32_t context_before,
|
|
|
|
uint32_t context_after,
|
2011-12-20 08:04:58 +08:00
|
|
|
const char *current_line_cstr,
|
2011-10-01 10:59:24 +08:00
|
|
|
lldb_private::Stream *s) {
|
2011-10-04 04:56:39 +08:00
|
|
|
if (!file)
|
2011-10-01 10:59:24 +08:00
|
|
|
return 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-03-19 08:20:55 +08:00
|
|
|
lldb::TargetSP target_sp(m_target_wp.lock());
|
|
|
|
if (target_sp) {
|
|
|
|
return target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers(
|
add stop column highlighting support
This change introduces optional marking of the column within a source
line where a thread is stopped. This marking will show up when the
source code for a thread stop is displayed, when the debug info
knows the column information, and if the optional column marking is
enabled.
There are two separate methods for handling the marking of the stop
column:
* via ANSI terminal codes, which are added inline to the source line
display. The default ANSI mark-up is to underline the column.
* via a pure text-based caret that is added in the appropriate column
in a newly-inserted blank line underneath the source line in
question.
There are some new options that control how this all works.
* settings set stop-show-column
This takes one of 4 values:
* ansi-or-caret: use the ANSI terminal code mechanism if LLDB
is running with color enabled; if not, use the caret-based,
pure text method (see the "caret" mode below).
* ansi: only use the ANSI terminal code mechanism to highlight
the stop line. If LLDB is running with color disabled, no
stop column marking will occur.
* caret: only use the pure text caret method, which introduces
a newly-inserted line underneath the current line, where
the only character in the new line is a caret that highlights
the stop column in question.
* none: no stop column marking will be attempted.
* settings set stop-show-column-ansi-prefix
This is a text format that indicates the ANSI formatting
code to insert into the stream immediately preceding the
column where the stop column character will be marked up.
It defaults to ${ansi.underline}; however, it can contain
any valid LLDB format codes, e.g.
${ansi.fg.red}${ansi.bold}${ansi.underline}
* settings set stop-show-column-ansi-suffix
This is the text format that specifies the ANSI terminal
codes to end the markup that was started with the prefix
described above. It defaults to: ${ansi.normal}. This
should be sufficient for the common cases.
Significant leg-work was done by Adrian Prantl. (Thanks, Adrian!)
differential review: https://reviews.llvm.org/D20835
reviewers: clayborg, jingham
llvm-svn: 282105
2016-09-22 04:13:14 +08:00
|
|
|
file, line, column, context_before, context_after, current_line_cstr,
|
|
|
|
s);
|
2011-10-01 10:59:24 +08:00
|
|
|
} else {
|
2013-03-19 08:20:55 +08:00
|
|
|
lldb::DebuggerSP debugger_sp(m_debugger_wp.lock());
|
|
|
|
if (debugger_sp) {
|
|
|
|
return debugger_sp->GetSourceManager()
|
add stop column highlighting support
This change introduces optional marking of the column within a source
line where a thread is stopped. This marking will show up when the
source code for a thread stop is displayed, when the debug info
knows the column information, and if the optional column marking is
enabled.
There are two separate methods for handling the marking of the stop
column:
* via ANSI terminal codes, which are added inline to the source line
display. The default ANSI mark-up is to underline the column.
* via a pure text-based caret that is added in the appropriate column
in a newly-inserted blank line underneath the source line in
question.
There are some new options that control how this all works.
* settings set stop-show-column
This takes one of 4 values:
* ansi-or-caret: use the ANSI terminal code mechanism if LLDB
is running with color enabled; if not, use the caret-based,
pure text method (see the "caret" mode below).
* ansi: only use the ANSI terminal code mechanism to highlight
the stop line. If LLDB is running with color disabled, no
stop column marking will occur.
* caret: only use the pure text caret method, which introduces
a newly-inserted line underneath the current line, where
the only character in the new line is a caret that highlights
the stop column in question.
* none: no stop column marking will be attempted.
* settings set stop-show-column-ansi-prefix
This is a text format that indicates the ANSI formatting
code to insert into the stream immediately preceding the
column where the stop column character will be marked up.
It defaults to ${ansi.underline}; however, it can contain
any valid LLDB format codes, e.g.
${ansi.fg.red}${ansi.bold}${ansi.underline}
* settings set stop-show-column-ansi-suffix
This is the text format that specifies the ANSI terminal
codes to end the markup that was started with the prefix
described above. It defaults to: ${ansi.normal}. This
should be sufficient for the common cases.
Significant leg-work was done by Adrian Prantl. (Thanks, Adrian!)
differential review: https://reviews.llvm.org/D20835
reviewers: clayborg, jingham
llvm-svn: 282105
2016-09-22 04:13:14 +08:00
|
|
|
.DisplaySourceLinesWithLineNumbers(file, line, column,
|
|
|
|
context_before, context_after,
|
|
|
|
current_line_cstr, s);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-03-19 08:20:55 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2011-10-01 10:59:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-10-01 10:59:24 +08:00
|
|
|
private:
|
2013-03-19 08:20:55 +08:00
|
|
|
lldb::DebuggerWP m_debugger_wp;
|
|
|
|
lldb::TargetWP m_target_wp;
|
2011-10-01 10:59:24 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
SBSourceManager::SBSourceManager(const SBDebugger &debugger) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &),
|
|
|
|
debugger);
|
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<SourceManagerImpl>(debugger.get_sp());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
SBSourceManager::SBSourceManager(const SBTarget &target) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &), target);
|
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<SourceManagerImpl>(target.GetSP());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
SBSourceManager::SBSourceManager(const SBSourceManager &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &),
|
|
|
|
rhs);
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
if (&rhs == this)
|
|
|
|
return;
|
2010-11-06 07:17:00 +08:00
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get()));
|
2010-11-06 07:17:00 +08:00
|
|
|
}
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
const lldb::SBSourceManager &SBSourceManager::
|
|
|
|
operator=(const lldb::SBSourceManager &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBSourceManager &,
|
|
|
|
SBSourceManager, operator=,(const lldb::SBSourceManager &),
|
|
|
|
rhs);
|
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get()));
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2011-09-13 08:29:56 +08:00
|
|
|
}
|
|
|
|
|
2020-02-18 14:57:06 +08:00
|
|
|
SBSourceManager::~SBSourceManager() = default;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t SBSourceManager::DisplaySourceLinesWithLineNumbers(
|
|
|
|
const SBFileSpec &file, uint32_t line, uint32_t context_before,
|
2011-12-20 08:04:58 +08:00
|
|
|
uint32_t context_after, const char *current_line_cstr, SBStream &s) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(size_t, SBSourceManager, DisplaySourceLinesWithLineNumbers,
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t,
|
|
|
|
const char *, lldb::SBStream &),
|
|
|
|
file, line, context_before, context_after,
|
|
|
|
current_line_cstr, s);
|
|
|
|
|
add stop column highlighting support
This change introduces optional marking of the column within a source
line where a thread is stopped. This marking will show up when the
source code for a thread stop is displayed, when the debug info
knows the column information, and if the optional column marking is
enabled.
There are two separate methods for handling the marking of the stop
column:
* via ANSI terminal codes, which are added inline to the source line
display. The default ANSI mark-up is to underline the column.
* via a pure text-based caret that is added in the appropriate column
in a newly-inserted blank line underneath the source line in
question.
There are some new options that control how this all works.
* settings set stop-show-column
This takes one of 4 values:
* ansi-or-caret: use the ANSI terminal code mechanism if LLDB
is running with color enabled; if not, use the caret-based,
pure text method (see the "caret" mode below).
* ansi: only use the ANSI terminal code mechanism to highlight
the stop line. If LLDB is running with color disabled, no
stop column marking will occur.
* caret: only use the pure text caret method, which introduces
a newly-inserted line underneath the current line, where
the only character in the new line is a caret that highlights
the stop column in question.
* none: no stop column marking will be attempted.
* settings set stop-show-column-ansi-prefix
This is a text format that indicates the ANSI formatting
code to insert into the stream immediately preceding the
column where the stop column character will be marked up.
It defaults to ${ansi.underline}; however, it can contain
any valid LLDB format codes, e.g.
${ansi.fg.red}${ansi.bold}${ansi.underline}
* settings set stop-show-column-ansi-suffix
This is the text format that specifies the ANSI terminal
codes to end the markup that was started with the prefix
described above. It defaults to: ${ansi.normal}. This
should be sufficient for the common cases.
Significant leg-work was done by Adrian Prantl. (Thanks, Adrian!)
differential review: https://reviews.llvm.org/D20835
reviewers: clayborg, jingham
llvm-svn: 282105
2016-09-22 04:13:14 +08:00
|
|
|
const uint32_t column = 0;
|
|
|
|
return DisplaySourceLinesWithLineNumbersAndColumn(
|
|
|
|
file.ref(), line, column, context_before, context_after,
|
|
|
|
current_line_cstr, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SBSourceManager::DisplaySourceLinesWithLineNumbersAndColumn(
|
|
|
|
const SBFileSpec &file, uint32_t line, uint32_t column,
|
|
|
|
uint32_t context_before, uint32_t context_after,
|
|
|
|
const char *current_line_cstr, SBStream &s) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(
|
|
|
|
size_t, SBSourceManager, DisplaySourceLinesWithLineNumbersAndColumn,
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t, uint32_t,
|
|
|
|
const char *, lldb::SBStream &),
|
|
|
|
file, line, column, context_before, context_after, current_line_cstr, s);
|
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
if (m_opaque_up == nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
return 0;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up->DisplaySourceLinesWithLineNumbers(
|
add stop column highlighting support
This change introduces optional marking of the column within a source
line where a thread is stopped. This marking will show up when the
source code for a thread stop is displayed, when the debug info
knows the column information, and if the optional column marking is
enabled.
There are two separate methods for handling the marking of the stop
column:
* via ANSI terminal codes, which are added inline to the source line
display. The default ANSI mark-up is to underline the column.
* via a pure text-based caret that is added in the appropriate column
in a newly-inserted blank line underneath the source line in
question.
There are some new options that control how this all works.
* settings set stop-show-column
This takes one of 4 values:
* ansi-or-caret: use the ANSI terminal code mechanism if LLDB
is running with color enabled; if not, use the caret-based,
pure text method (see the "caret" mode below).
* ansi: only use the ANSI terminal code mechanism to highlight
the stop line. If LLDB is running with color disabled, no
stop column marking will occur.
* caret: only use the pure text caret method, which introduces
a newly-inserted line underneath the current line, where
the only character in the new line is a caret that highlights
the stop column in question.
* none: no stop column marking will be attempted.
* settings set stop-show-column-ansi-prefix
This is a text format that indicates the ANSI formatting
code to insert into the stream immediately preceding the
column where the stop column character will be marked up.
It defaults to ${ansi.underline}; however, it can contain
any valid LLDB format codes, e.g.
${ansi.fg.red}${ansi.bold}${ansi.underline}
* settings set stop-show-column-ansi-suffix
This is the text format that specifies the ANSI terminal
codes to end the markup that was started with the prefix
described above. It defaults to: ${ansi.normal}. This
should be sufficient for the common cases.
Significant leg-work was done by Adrian Prantl. (Thanks, Adrian!)
differential review: https://reviews.llvm.org/D20835
reviewers: clayborg, jingham
llvm-svn: 282105
2016-09-22 04:13:14 +08:00
|
|
|
file.ref(), line, column, context_before, context_after,
|
|
|
|
current_line_cstr, s.get());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBSourceManager>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &));
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &));
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
const lldb::SBSourceManager &,
|
|
|
|
SBSourceManager, operator=,(const lldb::SBSourceManager &));
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBSourceManager,
|
|
|
|
DisplaySourceLinesWithLineNumbers,
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, uint32_t,
|
|
|
|
uint32_t, const char *, lldb::SBStream &));
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBSourceManager,
|
|
|
|
DisplaySourceLinesWithLineNumbersAndColumn,
|
|
|
|
(const lldb::SBFileSpec &, uint32_t, uint32_t,
|
|
|
|
uint32_t, uint32_t, const char *, lldb::SBStream &));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|