[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 08:23:27 +01:00
|
|
|
//===-- SBInstruction.cpp -------------------------------------------------===//
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00: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-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBInstruction.h"
|
2019-03-06 00:06:00 +00:00
|
|
|
#include "SBReproducerPrivate.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-10-06 03:09:58 +00:00
|
|
|
#include "lldb/API/SBAddress.h"
|
2011-04-05 23:22:54 +00:00
|
|
|
#include "lldb/API/SBFrame.h"
|
2019-10-14 20:59:57 +00:00
|
|
|
#include "lldb/API/SBFile.h"
|
2019-02-11 23:13:08 +00:00
|
|
|
|
2010-10-06 03:09:58 +00:00
|
|
|
#include "lldb/API/SBInstruction.h"
|
|
|
|
#include "lldb/API/SBStream.h"
|
2011-04-05 23:22:54 +00:00
|
|
|
#include "lldb/API/SBTarget.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Core/Disassembler.h"
|
2011-04-05 23:22:54 +00:00
|
|
|
#include "lldb/Core/EmulateInstruction.h"
|
2014-10-10 23:07:36 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
2010-10-06 03:09:58 +00:00
|
|
|
#include "lldb/Core/StreamFile.h"
|
2017-10-31 10:56:03 +00:00
|
|
|
#include "lldb/Host/HostInfo.h"
|
2011-04-05 23:22:54 +00:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
2013-11-04 09:33:30 +00:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2011-04-05 23:22:54 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2017-11-13 16:16:33 +00:00
|
|
|
#include "lldb/Utility/ArchSpec.h"
|
2017-03-04 01:30:05 +00:00
|
|
|
#include "lldb/Utility/DataBufferHeap.h"
|
|
|
|
#include "lldb/Utility/DataExtractor.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-02-11 23:13:08 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// We recently fixed a leak in one of the Instruction subclasses where the
|
|
|
|
// instruction will only hold a weak reference to the disassembler to avoid a
|
|
|
|
// cycle that was keeping both objects alive (leak) and we need the
|
|
|
|
// InstructionImpl class to make sure our public API behaves as users would
|
|
|
|
// expect. Calls in our public API allow clients to do things like:
|
2016-06-07 22:56:40 +00:00
|
|
|
//
|
|
|
|
// 1 lldb::SBInstruction inst;
|
|
|
|
// 2 inst = target.ReadInstructions(pc, 1).GetInstructionAtIndex(0)
|
|
|
|
// 3 if (inst.DoesBranch())
|
|
|
|
// 4 ...
|
|
|
|
//
|
|
|
|
// There was a temporary lldb::DisassemblerSP object created in the
|
2018-04-30 16:49:04 +00:00
|
|
|
// SBInstructionList that was returned by lldb.target.ReadInstructions() that
|
|
|
|
// will go away after line 2 but the "inst" object should be able to still
|
|
|
|
// answer questions about itself. So we make sure that any SBInstruction
|
|
|
|
// objects that are given out have a strong reference to the disassembler and
|
|
|
|
// the instruction so that the object can live and successfully respond to all
|
|
|
|
// queries.
|
2016-06-07 22:56:40 +00:00
|
|
|
class InstructionImpl {
|
|
|
|
public:
|
|
|
|
InstructionImpl(const lldb::DisassemblerSP &disasm_sp,
|
|
|
|
const lldb::InstructionSP &inst_sp)
|
|
|
|
: m_disasm_sp(disasm_sp), m_inst_sp(inst_sp) {}
|
|
|
|
|
|
|
|
lldb::InstructionSP GetSP() const { return m_inst_sp; }
|
|
|
|
|
|
|
|
bool IsValid() const { return (bool)m_inst_sp; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
lldb::DisassemblerSP m_disasm_sp; // Can be empty/invalid
|
|
|
|
lldb::InstructionSP m_inst_sp;
|
|
|
|
};
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
SBInstruction::SBInstruction() : m_opaque_sp() {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBInstruction);
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
SBInstruction::SBInstruction(const lldb::DisassemblerSP &disasm_sp,
|
|
|
|
const lldb::InstructionSP &inst_sp)
|
|
|
|
: m_opaque_sp(new InstructionImpl(disasm_sp, inst_sp)) {}
|
2010-10-06 03:09:58 +00:00
|
|
|
|
2010-11-05 23:17:00 +00:00
|
|
|
SBInstruction::SBInstruction(const SBInstruction &rhs)
|
2019-03-06 00:06:00 +00:00
|
|
|
: m_opaque_sp(rhs.m_opaque_sp) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &), rhs);
|
|
|
|
}
|
2010-11-05 23:17:00 +00:00
|
|
|
|
|
|
|
const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBInstruction &,
|
|
|
|
SBInstruction, operator=,(const lldb::SBInstruction &),
|
|
|
|
rhs);
|
|
|
|
|
2010-11-05 23:17:00 +00:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
2019-04-03 21:31:22 +00:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2010-11-05 23:17:00 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 22:57:06 -08:00
|
|
|
SBInstruction::~SBInstruction() = default;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
bool SBInstruction::IsValid() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 13:58:46 +00:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBInstruction::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstruction, operator bool);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
|
|
|
return m_opaque_sp && m_opaque_sp->IsValid();
|
|
|
|
}
|
2010-10-06 03:09:58 +00:00
|
|
|
|
|
|
|
SBAddress SBInstruction::GetAddress() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBInstruction, GetAddress);
|
|
|
|
|
2010-10-06 03:09:58 +00:00
|
|
|
SBAddress sb_addr;
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp && inst_sp->GetAddress().IsValid())
|
2020-09-25 11:15:44 -07:00
|
|
|
sb_addr.SetAddress(inst_sp->GetAddress());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_addr);
|
2010-10-06 03:09:58 +00:00
|
|
|
}
|
|
|
|
|
2011-09-27 00:58:45 +00:00
|
|
|
const char *SBInstruction::GetMnemonic(SBTarget target) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(const char *, SBInstruction, GetMnemonic, (lldb::SBTarget),
|
|
|
|
target);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp) {
|
2011-09-26 07:11:27 +00:00
|
|
|
ExecutionContext exe_ctx;
|
2012-01-30 07:41:31 +00:00
|
|
|
TargetSP target_sp(target.GetSP());
|
2016-05-19 05:13:57 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
2012-01-30 07:41:31 +00:00
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
target_sp->CalculateExecutionContext(exe_ctx);
|
|
|
|
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
|
2011-09-26 07:11:27 +00:00
|
|
|
}
|
2016-06-07 22:56:40 +00:00
|
|
|
return inst_sp->GetMnemonic(&exe_ctx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
[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 11:14:47 +00:00
|
|
|
return nullptr;
|
2011-09-26 07:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-27 00:58:45 +00:00
|
|
|
const char *SBInstruction::GetOperands(SBTarget target) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(const char *, SBInstruction, GetOperands, (lldb::SBTarget),
|
|
|
|
target);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp) {
|
2011-09-26 07:11:27 +00:00
|
|
|
ExecutionContext exe_ctx;
|
2012-01-30 07:41:31 +00:00
|
|
|
TargetSP target_sp(target.GetSP());
|
2016-05-19 05:13:57 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
2012-01-30 07:41:31 +00:00
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
target_sp->CalculateExecutionContext(exe_ctx);
|
|
|
|
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
|
2011-09-26 07:11:27 +00:00
|
|
|
}
|
2016-06-07 22:56:40 +00:00
|
|
|
return inst_sp->GetOperands(&exe_ctx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
[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 11:14:47 +00:00
|
|
|
return nullptr;
|
2011-09-26 07:11:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *SBInstruction::GetComment(SBTarget target) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(const char *, SBInstruction, GetComment, (lldb::SBTarget),
|
|
|
|
target);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp) {
|
2011-09-26 07:11:27 +00:00
|
|
|
ExecutionContext exe_ctx;
|
2012-01-30 07:41:31 +00:00
|
|
|
TargetSP target_sp(target.GetSP());
|
2016-05-19 05:13:57 +00:00
|
|
|
std::unique_lock<std::recursive_mutex> lock;
|
2012-01-30 07:41:31 +00:00
|
|
|
if (target_sp) {
|
2016-05-19 05:13:57 +00:00
|
|
|
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
target_sp->CalculateExecutionContext(exe_ctx);
|
|
|
|
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
|
2011-09-26 07:11:27 +00:00
|
|
|
}
|
2016-06-07 22:56:40 +00:00
|
|
|
return inst_sp->GetComment(&exe_ctx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
[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 11:14:47 +00:00
|
|
|
return nullptr;
|
2011-09-26 07:11:27 +00:00
|
|
|
}
|
|
|
|
|
2010-10-06 03:09:58 +00:00
|
|
|
size_t SBInstruction::GetByteSize() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(size_t, SBInstruction, GetByteSize);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp)
|
|
|
|
return inst_sp->GetOpcode().GetByteSize();
|
2010-10-06 03:09:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2011-09-26 07:11:27 +00:00
|
|
|
SBData SBInstruction::GetData(SBTarget target) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBData, SBInstruction, GetData, (lldb::SBTarget),
|
|
|
|
target);
|
|
|
|
|
2011-09-26 07:11:27 +00:00
|
|
|
lldb::SBData sb_data;
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp) {
|
2012-04-11 21:13:31 +00:00
|
|
|
DataExtractorSP data_extractor_sp(new DataExtractor());
|
2016-06-07 22:56:40 +00:00
|
|
|
if (inst_sp->GetData(*data_extractor_sp)) {
|
2011-09-26 07:11:27 +00:00
|
|
|
sb_data.SetOpaque(data_extractor_sp);
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_data);
|
2011-09-26 07:11:27 +00:00
|
|
|
}
|
|
|
|
|
2010-10-06 03:09:58 +00:00
|
|
|
bool SBInstruction::DoesBranch() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, DoesBranch);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp)
|
|
|
|
return inst_sp->DoesBranch();
|
2010-10-06 03:09:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2016-01-27 10:16:30 +00:00
|
|
|
bool SBInstruction::HasDelaySlot() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, HasDelaySlot);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp)
|
|
|
|
return inst_sp->HasDelaySlot();
|
2016-01-27 10:16:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
bool SBInstruction::CanSetBreakpoint() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, CanSetBreakpoint);
|
|
|
|
|
2017-05-04 11:34:42 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp)
|
|
|
|
return inst_sp->CanSetBreakpoint();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP SBInstruction::GetOpaque() {
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetSP();
|
|
|
|
else
|
|
|
|
return lldb::InstructionSP();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBInstruction::SetOpaque(const lldb::DisassemblerSP &disasm_sp,
|
|
|
|
const lldb::InstructionSP &inst_sp) {
|
2019-02-11 23:13:08 +00:00
|
|
|
m_opaque_sp = std::make_shared<InstructionImpl>(disasm_sp, inst_sp);
|
2010-10-06 03:09:58 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-10-06 03:09:58 +00:00
|
|
|
bool SBInstruction::GetDescription(lldb::SBStream &s) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBInstruction, GetDescription, (lldb::SBStream &),
|
|
|
|
s);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp) {
|
2014-10-10 23:07:36 +00:00
|
|
|
SymbolContext sc;
|
2016-06-07 22:56:40 +00:00
|
|
|
const Address &addr = inst_sp->GetAddress();
|
2014-10-10 23:07:36 +00:00
|
|
|
ModuleSP module_sp(addr.GetModule());
|
|
|
|
if (module_sp)
|
|
|
|
module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything,
|
|
|
|
sc);
|
2010-10-06 03:09:58 +00:00
|
|
|
// Use the "ref()" instead of the "get()" accessor in case the SBStream
|
|
|
|
// didn't have a stream already created, one will get created...
|
2015-02-04 22:00:53 +00:00
|
|
|
FormatEntity::Entry format;
|
|
|
|
FormatEntity::Parse("${addr}: ", format);
|
[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 11:14:47 +00:00
|
|
|
inst_sp->Dump(&s.ref(), 0, true, false, nullptr, &sc, nullptr, &format, 0);
|
2010-10-06 03:09:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-10-14 20:59:57 +00:00
|
|
|
void SBInstruction::Print(FILE *outp) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), outp);
|
|
|
|
FileSP out = std::make_shared<NativeFile>(outp, /*take_ownership=*/false);
|
|
|
|
Print(out);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBInstruction::Print(SBFile out) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBInstruction, Print, (SBFile), out);
|
2019-10-14 21:51:02 +00:00
|
|
|
Print(out.m_opaque_sp);
|
2019-10-14 20:59:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SBInstruction::Print(FileSP out_sp) {
|
|
|
|
LLDB_RECORD_METHOD(void, SBInstruction, Print, (FileSP), out_sp);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
2019-10-14 20:59:57 +00:00
|
|
|
if (!out_sp || !out_sp->IsValid())
|
2010-06-08 16:52:24 +00:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp) {
|
2014-10-10 23:07:36 +00:00
|
|
|
SymbolContext sc;
|
2016-06-07 22:56:40 +00:00
|
|
|
const Address &addr = inst_sp->GetAddress();
|
2014-10-10 23:07:36 +00:00
|
|
|
ModuleSP module_sp(addr.GetModule());
|
|
|
|
if (module_sp)
|
|
|
|
module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything,
|
|
|
|
sc);
|
2019-10-14 20:59:57 +00:00
|
|
|
StreamFile out_stream(out_sp);
|
2015-02-04 22:00:53 +00:00
|
|
|
FormatEntity::Entry format;
|
|
|
|
FormatEntity::Parse("${addr}: ", format);
|
[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 11:14:47 +00:00
|
|
|
inst_sp->Dump(&out_stream, 0, true, false, nullptr, &sc, nullptr, &format,
|
|
|
|
0);
|
2010-10-06 03:09:58 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2011-04-05 23:22:54 +00:00
|
|
|
|
2011-04-26 04:39:08 +00:00
|
|
|
bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame,
|
|
|
|
uint32_t evaluate_options) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBInstruction, EmulateWithFrame,
|
|
|
|
(lldb::SBFrame &, uint32_t), frame, evaluate_options);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp) {
|
2013-11-04 09:33:30 +00:00
|
|
|
lldb::StackFrameSP frame_sp(frame.GetFrameSP());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-01-30 07:41:31 +00:00
|
|
|
if (frame_sp) {
|
|
|
|
lldb_private::ExecutionContext exe_ctx;
|
|
|
|
frame_sp->CalculateExecutionContext(exe_ctx);
|
|
|
|
lldb_private::Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
lldb_private::ArchSpec arch = target->GetArchitecture();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
return inst_sp->Emulate(
|
|
|
|
arch, evaluate_options, (void *)frame_sp.get(),
|
|
|
|
&lldb_private::EmulateInstruction::ReadMemoryFrame,
|
|
|
|
&lldb_private::EmulateInstruction::WriteMemoryFrame,
|
|
|
|
&lldb_private::EmulateInstruction::ReadRegisterFrame,
|
|
|
|
&lldb_private::EmulateInstruction::WriteRegisterFrame);
|
2011-04-05 23:22:54 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2011-04-05 23:22:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBInstruction::DumpEmulation(const char *triple) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBInstruction, DumpEmulation, (const char *),
|
|
|
|
triple);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp && triple) {
|
2017-10-31 10:56:03 +00:00
|
|
|
return inst_sp->DumpEmulation(HostInfo::GetAugmentedArchSpec(triple));
|
2011-04-05 23:22:54 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
bool SBInstruction::TestEmulation(lldb::SBStream &output_stream,
|
|
|
|
const char *test_file) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBInstruction, TestEmulation,
|
|
|
|
(lldb::SBStream &, const char *), output_stream,
|
|
|
|
test_file);
|
|
|
|
|
2016-06-07 22:56:40 +00:00
|
|
|
if (!m_opaque_sp)
|
|
|
|
SetOpaque(lldb::DisassemblerSP(),
|
|
|
|
lldb::InstructionSP(new PseudoInstruction()));
|
|
|
|
|
|
|
|
lldb::InstructionSP inst_sp(GetOpaque());
|
|
|
|
if (inst_sp)
|
|
|
|
return inst_sp->TestEmulation(output_stream.get(), test_file);
|
|
|
|
return false;
|
2011-04-21 20:27:45 +00:00
|
|
|
}
|
2019-03-19 17:13:13 +00:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBInstruction>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBInstruction, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
const lldb::SBInstruction &,
|
|
|
|
SBInstruction, operator=,(const lldb::SBInstruction &));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBInstruction, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBAddress, SBInstruction, GetAddress, ());
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBInstruction, GetMnemonic,
|
|
|
|
(lldb::SBTarget));
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBInstruction, GetOperands,
|
|
|
|
(lldb::SBTarget));
|
|
|
|
LLDB_REGISTER_METHOD(const char *, SBInstruction, GetComment,
|
|
|
|
(lldb::SBTarget));
|
|
|
|
LLDB_REGISTER_METHOD(size_t, SBInstruction, GetByteSize, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBData, SBInstruction, GetData,
|
|
|
|
(lldb::SBTarget));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, DoesBranch, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, HasDelaySlot, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, CanSetBreakpoint, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, GetDescription,
|
|
|
|
(lldb::SBStream &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FILE *));
|
2019-10-14 20:59:57 +00:00
|
|
|
LLDB_REGISTER_METHOD(void, SBInstruction, Print, (SBFile));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FileSP));
|
2019-03-19 17:13:13 +00:00
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, EmulateWithFrame,
|
|
|
|
(lldb::SBFrame &, uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, DumpEmulation, (const char *));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBInstruction, TestEmulation,
|
|
|
|
(lldb::SBStream &, const char *));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|