[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
|
|
|
//===-- FunctionCaller.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
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
#include "lldb/Expression/FunctionCaller.h"
|
2014-03-25 07:10:19 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
2016-03-19 08:03:59 +08:00
|
|
|
#include "lldb/Expression/DiagnosticManager.h"
|
2014-03-25 07:10:19 +08:00
|
|
|
#include "lldb/Expression/IRExecutionUnit.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
|
|
|
#include "lldb/Symbol/Function.h"
|
2014-03-25 07:10:19 +08:00
|
|
|
#include "lldb/Symbol/Type.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
2010-07-23 08:16:21 +08:00
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2011-02-16 05:59:32 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
#include "lldb/Target/ThreadPlanCallFunction.h"
|
2017-03-04 09:30:05 +08:00
|
|
|
#include "lldb/Utility/DataExtractor.h"
|
2022-02-03 20:26:10 +08:00
|
|
|
#include "lldb/Utility/LLDBLog.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2018-08-07 19:07:21 +08:00
|
|
|
#include "lldb/Utility/State.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
|
2019-11-12 17:04:32 +08:00
|
|
|
char FunctionCaller::ID;
|
|
|
|
|
2015-09-16 05:13:50 +08:00
|
|
|
// FunctionCaller constructor
|
2011-03-18 04:02:56 +08:00
|
|
|
FunctionCaller::FunctionCaller(ExecutionContextScope &exe_scope,
|
2015-08-12 06:53:00 +08:00
|
|
|
const CompilerType &return_type,
|
2010-10-16 06:48:33 +08:00
|
|
|
const Address &functionAddress,
|
2014-04-22 09:42:22 +08:00
|
|
|
const ValueList &arg_value_list,
|
|
|
|
const char *name)
|
2019-11-12 17:04:32 +08:00
|
|
|
: Expression(exe_scope), m_execution_unit_sp(), m_parser(),
|
|
|
|
m_jit_module_wp(), m_name(name ? name : "<unknown>"),
|
[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
|
|
|
m_function_ptr(nullptr), m_function_addr(functionAddress),
|
2013-07-12 06:46:58 +08:00
|
|
|
m_function_return_type(return_type),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_wrapper_function_name("__lldb_caller_function"),
|
|
|
|
m_wrapper_struct_name("__lldb_caller_struct"), m_wrapper_args_addrs(),
|
2018-06-01 04:01:15 +08:00
|
|
|
m_struct_valid(false), m_arg_values(arg_value_list), m_compiled(false),
|
|
|
|
m_JITted(false) {
|
2012-09-18 08:08:47 +08:00
|
|
|
m_jit_process_wp = lldb::ProcessWP(exe_scope.CalculateProcess());
|
2015-09-16 05:13:50 +08:00
|
|
|
// Can't make a FunctionCaller without a process.
|
2012-09-18 08:08:47 +08:00
|
|
|
assert(m_jit_process_wp.lock());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Destructor
|
2015-09-16 05:13:50 +08:00
|
|
|
FunctionCaller::~FunctionCaller() {
|
2014-03-25 07:10:19 +08:00
|
|
|
lldb::ProcessSP process_sp(m_jit_process_wp.lock());
|
|
|
|
if (process_sp) {
|
|
|
|
lldb::ModuleSP jit_module_sp(m_jit_module_wp.lock());
|
|
|
|
if (jit_module_sp)
|
|
|
|
process_sp->GetTarget().GetImages().Remove(jit_module_sp);
|
2016-03-19 08:03:59 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
bool FunctionCaller::WriteFunctionWrapper(
|
|
|
|
ExecutionContext &exe_ctx, DiagnosticManager &diagnostic_manager) {
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-18 08:08:47 +08:00
|
|
|
if (!process)
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-03-25 07:10:19 +08:00
|
|
|
lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-03-25 07:10:19 +08:00
|
|
|
if (process != jit_process_sp.get())
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
if (!m_compiled)
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
if (m_JITted)
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
bool can_interpret = false; // should stay that way
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status jit_error(m_parser->PrepareForExecution(
|
2013-03-19 08:10:07 +08:00
|
|
|
m_jit_start_addr, m_jit_end_addr, m_execution_unit_sp, exe_ctx,
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
can_interpret, eExecutionPolicyAlways));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-06-29 04:02:11 +08:00
|
|
|
if (!jit_error.Success()) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"Error in PrepareForExecution: %s.",
|
|
|
|
jit_error.AsCString());
|
2011-03-18 04:02:56 +08:00
|
|
|
return false;
|
2018-06-29 04:02:11 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-03-25 07:10:19 +08:00
|
|
|
if (m_parser->GetGenerateDebugInfo()) {
|
|
|
|
lldb::ModuleSP jit_module_sp(m_execution_unit_sp->GetJITModule());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-03-25 07:10:19 +08:00
|
|
|
if (jit_module_sp) {
|
|
|
|
ConstString const_func_name(FunctionName());
|
|
|
|
FileSpec jit_file;
|
|
|
|
jit_file.GetFilename() = const_func_name;
|
|
|
|
jit_module_sp->SetFileSpecAndObjectName(jit_file, ConstString());
|
|
|
|
m_jit_module_wp = jit_module_sp;
|
2019-04-09 07:03:02 +08:00
|
|
|
process->GetTarget().GetImages().Append(jit_module_sp,
|
|
|
|
true /* notify */);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
}
|
2013-03-19 08:10:07 +08:00
|
|
|
if (process && m_jit_start_addr)
|
2014-03-25 07:10:19 +08:00
|
|
|
m_jit_process_wp = process->shared_from_this();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-01-15 05:45:38 +08:00
|
|
|
m_JITted = true;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
return true;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
bool FunctionCaller::WriteFunctionArguments(
|
|
|
|
ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref,
|
|
|
|
DiagnosticManager &diagnostic_manager) {
|
|
|
|
return WriteFunctionArguments(exe_ctx, args_addr_ref, m_arg_values,
|
|
|
|
diagnostic_manager);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: Assure that the ValueList we were passed in is consistent with the one
|
|
|
|
// that defined this function.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
bool FunctionCaller::WriteFunctionArguments(
|
|
|
|
ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref,
|
|
|
|
ValueList &arg_values, DiagnosticManager &diagnostic_manager) {
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
// All the information to reconstruct the struct is provided by the
|
|
|
|
// StructExtractor.
|
|
|
|
if (!m_struct_valid) {
|
2016-11-13 03:12:56 +08:00
|
|
|
diagnostic_manager.PutString(eDiagnosticSeverityError,
|
|
|
|
"Argument information was not correctly "
|
|
|
|
"parsed, so the function cannot be called.");
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
return false;
|
|
|
|
}
|
2016-03-19 08:03:59 +08:00
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
2014-05-05 10:47:44 +08:00
|
|
|
lldb::ExpressionResults return_value = lldb::eExpressionSetupError;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
2010-06-09 00:52:24 +08: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 19:14:47 +08:00
|
|
|
if (process == nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
return return_value;
|
2011-03-18 04:02:56 +08:00
|
|
|
|
2012-09-18 08:08:47 +08:00
|
|
|
lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-18 08:08:47 +08:00
|
|
|
if (process != jit_process_sp.get())
|
2011-03-18 04:02:56 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (args_addr_ref == LLDB_INVALID_ADDRESS) {
|
This is a major refactoring of the expression parser.
The goal is to separate the parser's data from the data
belonging to the parser's clients. This allows clients
to use the parser to obtain (for example) a JIT compiled
function or some DWARF code, and then discard the parser
state.
Previously, parser state was held in ClangExpression and
used liberally by ClangFunction, which inherited from
ClangExpression. The main effects of this refactoring
are:
- reducing ClangExpression to an abstract class that
declares methods that any client must expose to the
expression parser,
- moving the code specific to implementing the "expr"
command from ClangExpression and
CommandObjectExpression into ClangUserExpression,
a new class,
- moving the common parser interaction code from
ClangExpression into ClangExpressionParser, a new
class, and
- making ClangFunction rely only on
ClangExpressionParser and not depend on the
internal implementation of ClangExpression.
Side effects include:
- the compiler interaction code has been factored
out of ClangFunction and is now in an AST pass
(ASTStructExtractor),
- the header file for ClangFunction is now fully
documented,
- several bugs that only popped up when Clang was
deallocated (which never happened, since the
lifetime of the compiler was essentially infinite)
are now fixed, and
- the developer-only "call" command has been
disabled.
I have tested the expr command and the Objective-C
step-into code, which use ClangUserExpression and
ClangFunction, respectively, and verified that they
work. Please let me know if you encounter bugs or
poor documentation.
llvm-svn: 112249
2010-08-27 09:01:44 +08:00
|
|
|
args_addr_ref = process->AllocateMemory(
|
|
|
|
m_struct_size, lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
2016-09-07 04:57:50 +08:00
|
|
|
error);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (args_addr_ref == LLDB_INVALID_ADDRESS)
|
|
|
|
return false;
|
|
|
|
m_wrapper_args_addrs.push_back(args_addr_ref);
|
|
|
|
} else {
|
|
|
|
// Make sure this is an address that we've already handed out.
|
|
|
|
if (find(m_wrapper_args_addrs.begin(), m_wrapper_args_addrs.end(),
|
|
|
|
args_addr_ref) == m_wrapper_args_addrs.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
// TODO: verify fun_addr needs to be a callable address
|
2015-09-16 05:13:50 +08:00
|
|
|
Scalar fun_addr(
|
|
|
|
m_function_addr.GetCallableLoadAddress(exe_ctx.GetTargetPtr()));
|
2013-01-26 02:06:21 +08:00
|
|
|
uint64_t first_offset = m_member_offsets[0];
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr,
|
|
|
|
process->GetAddressByteSize(), error);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// FIXME: We will need to extend this for Variadic functions.
|
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status value_error;
|
2016-03-19 08:03:59 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
size_t num_args = arg_values.GetSize();
|
|
|
|
if (num_args != m_arg_values.GetSize()) {
|
2016-03-19 08:03:59 +08:00
|
|
|
diagnostic_manager.Printf(
|
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"Wrong number of arguments - was: %" PRIu64 " should be: %" PRIu64 "",
|
|
|
|
(uint64_t)num_args, (uint64_t)m_arg_values.GetSize());
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
2016-03-19 08:03:59 +08:00
|
|
|
|
2010-07-10 04:39:50 +08:00
|
|
|
for (size_t i = 0; i < num_args; i++) {
|
2010-06-09 00:52:24 +08:00
|
|
|
// FIXME: We should sanity check sizes.
|
|
|
|
|
|
|
|
uint64_t offset = m_member_offsets[i + 1]; // Clang sizes are in bytes.
|
|
|
|
Value *arg_value = arg_values.GetValueAtIndex(i);
|
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
// FIXME: For now just do scalars:
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
// Special case: if it's a pointer, don't do anything (the ABI supports
|
|
|
|
// passing cstrings)
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-02-12 04:57:04 +08:00
|
|
|
if (arg_value->GetValueType() == Value::ValueType::HostAddress &&
|
|
|
|
arg_value->GetContextType() == Value::ContextType::Invalid &&
|
2016-03-19 08:03:59 +08:00
|
|
|
arg_value->GetCompilerType().IsPointerType())
|
|
|
|
continue;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-11-30 05:49:15 +08:00
|
|
|
if (!process->WriteScalarToMemory(args_addr_ref + offset, arg_scalar,
|
|
|
|
arg_scalar.GetByteSize(), error))
|
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
bool FunctionCaller::InsertFunction(ExecutionContext &exe_ctx,
|
|
|
|
lldb::addr_t &args_addr_ref,
|
|
|
|
DiagnosticManager &diagnostic_manager) {
|
|
|
|
if (CompileFunction(exe_ctx.GetThreadSP(), diagnostic_manager) != 0)
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
return false;
|
2016-03-19 08:03:59 +08:00
|
|
|
if (!WriteFunctionWrapper(exe_ctx, diagnostic_manager))
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
return false;
|
2016-03-19 08:03:59 +08:00
|
|
|
if (!WriteFunctionArguments(exe_ctx, args_addr_ref, diagnostic_manager))
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2022-01-31 22:57:48 +08:00
|
|
|
Log *log = GetLog(LLDBLog::Step);
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log, "Call Address: 0x%" PRIx64 " Struct Address: 0x%" PRIx64 ".\n",
|
|
|
|
m_jit_start_addr, args_addr_ref);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
lldb::ThreadPlanSP FunctionCaller::GetThreadPlanToCallFunction(
|
2015-09-16 05:13:50 +08:00
|
|
|
ExecutionContext &exe_ctx, lldb::addr_t args_addr,
|
2013-11-07 08:11:47 +08:00
|
|
|
const EvaluateExpressionOptions &options,
|
2016-03-19 08:03:59 +08:00
|
|
|
DiagnosticManager &diagnostic_manager) {
|
2022-01-31 22:57:48 +08:00
|
|
|
Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"-- [FunctionCaller::GetThreadPlanToCallFunction] Creating "
|
|
|
|
"thread plan to call function \"%s\" --",
|
|
|
|
m_name.c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// FIXME: Use the errors Stream for better error reporting.
|
2011-09-22 12:58:26 +08:00
|
|
|
Thread *thread = exe_ctx.GetThreadPtr();
|
[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 (thread == nullptr) {
|
2016-11-13 03:12:56 +08:00
|
|
|
diagnostic_manager.PutString(
|
2016-03-19 08:03:59 +08:00
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"Can't call a function without a valid thread.");
|
[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
|
|
|
return nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// Okay, now run the function:
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-07 08:11:47 +08:00
|
|
|
Address wrapper_address(m_jit_start_addr);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-08 09:14:26 +08:00
|
|
|
lldb::addr_t args = {args_addr};
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-09-30 07:17:18 +08:00
|
|
|
lldb::ThreadPlanSP new_plan_sp(new ThreadPlanCallFunction(
|
2010-12-14 06:46:15 +08:00
|
|
|
*thread, wrapper_address, CompilerType(), args, options));
|
2021-11-02 21:58:19 +08:00
|
|
|
new_plan_sp->SetIsControllingPlan(true);
|
2014-09-30 07:17:18 +08:00
|
|
|
new_plan_sp->SetOkayToDiscard(false);
|
|
|
|
return new_plan_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2015-09-16 05:13:50 +08:00
|
|
|
bool FunctionCaller::FetchFunctionResults(ExecutionContext &exe_ctx,
|
|
|
|
lldb::addr_t args_addr,
|
|
|
|
Value &ret_value) {
|
2010-06-09 00:52:24 +08:00
|
|
|
// Read the return value - it is the last field in the struct:
|
|
|
|
// FIXME: How does clang tell us there's no return value? We need to handle
|
|
|
|
// that case.
|
2015-08-12 06:53:00 +08:00
|
|
|
// FIXME: Create our ThreadPlanCallFunction with the return CompilerType, and
|
|
|
|
// then use GetReturnValueObject
|
2011-12-23 03:12:40 +08:00
|
|
|
// to fetch the value. That way we can fetch any values we need.
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2022-01-31 22:57:48 +08:00
|
|
|
Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"-- [FunctionCaller::FetchFunctionResults] Fetching function "
|
|
|
|
"results for \"%s\"--",
|
|
|
|
m_name.c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
2016-09-07 04:57:50 +08: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 19:14:47 +08:00
|
|
|
if (process == nullptr)
|
2011-03-18 04:02:56 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-18 08:08:47 +08:00
|
|
|
lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-09-18 08:08:47 +08:00
|
|
|
if (process != jit_process_sp.get())
|
2011-03-18 04:02:56 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status error;
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
ret_value.GetScalar() = process->ReadUnsignedIntegerFromMemory(
|
|
|
|
args_addr + m_return_offset, m_return_size, 0, error);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
if (error.Fail())
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-08-25 07:46:31 +08:00
|
|
|
ret_value.SetCompilerType(m_function_return_type);
|
2021-02-12 04:57:04 +08:00
|
|
|
ret_value.SetValueType(Value::ValueType::Scalar);
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-16 05:13:50 +08:00
|
|
|
void FunctionCaller::DeallocateFunctionResults(ExecutionContext &exe_ctx,
|
|
|
|
lldb::addr_t args_addr) {
|
2010-06-09 00:52:24 +08:00
|
|
|
std::list<lldb::addr_t>::iterator pos;
|
|
|
|
pos = std::find(m_wrapper_args_addrs.begin(), m_wrapper_args_addrs.end(),
|
|
|
|
args_addr);
|
|
|
|
if (pos != m_wrapper_args_addrs.end())
|
|
|
|
m_wrapper_args_addrs.erase(pos);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
exe_ctx.GetProcessRef().DeallocateMemory(args_addr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
lldb::ExpressionResults FunctionCaller::ExecuteFunction(
|
|
|
|
ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr,
|
|
|
|
const EvaluateExpressionOptions &options,
|
|
|
|
DiagnosticManager &diagnostic_manager, Value &results) {
|
2014-05-05 10:47:44 +08:00
|
|
|
lldb::ExpressionResults return_value = lldb::eExpressionSetupError;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08:00
|
|
|
// FunctionCaller::ExecuteFunction execution is always just to get the
|
2021-02-25 03:04:47 +08:00
|
|
|
// result. Unless explicitly asked for, ignore breakpoints and unwind on
|
|
|
|
// error.
|
|
|
|
const bool enable_debugging =
|
|
|
|
exe_ctx.GetTargetPtr() &&
|
|
|
|
exe_ctx.GetTargetPtr()->GetDebugUtilityExpression();
|
2013-11-07 08:11:47 +08:00
|
|
|
EvaluateExpressionOptions real_options = options;
|
2021-02-25 03:04:47 +08:00
|
|
|
real_options.SetDebug(false); // This halts the expression for debugging.
|
|
|
|
real_options.SetGenerateDebugInfo(enable_debugging);
|
|
|
|
real_options.SetUnwindOnError(!enable_debugging);
|
|
|
|
real_options.SetIgnoreBreakpoints(!enable_debugging);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-07 08:11:47 +08:00
|
|
|
lldb::addr_t args_addr;
|
2016-09-07 04:57:50 +08: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 19:14:47 +08:00
|
|
|
if (args_addr_ptr != nullptr)
|
2013-11-07 08:11:47 +08:00
|
|
|
args_addr = *args_addr_ptr;
|
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
args_addr = LLDB_INVALID_ADDRESS;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-22 03:21:13 +08:00
|
|
|
if (CompileFunction(exe_ctx.GetThreadSP(), diagnostic_manager) != 0)
|
2013-11-07 08:11:47 +08:00
|
|
|
return lldb::eExpressionSetupError;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-07 08:11:47 +08:00
|
|
|
if (args_addr == LLDB_INVALID_ADDRESS) {
|
2016-03-22 03:21:13 +08:00
|
|
|
if (!InsertFunction(exe_ctx, args_addr, diagnostic_manager))
|
2014-05-05 10:47:44 +08:00
|
|
|
return lldb::eExpressionSetupError;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2022-01-31 22:57:48 +08:00
|
|
|
Log *log(GetLog(LLDBLog::Expressions | LLDBLog::Step));
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"== [FunctionCaller::ExecuteFunction] Executing function \"%s\" ==",
|
|
|
|
m_name.c_str());
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2013-11-07 08:11:47 +08:00
|
|
|
lldb::ThreadPlanSP call_plan_sp = GetThreadPlanToCallFunction(
|
2016-03-19 08:03:59 +08:00
|
|
|
exe_ctx, args_addr, real_options, diagnostic_manager);
|
|
|
|
if (!call_plan_sp)
|
2014-05-05 10:47:44 +08:00
|
|
|
return lldb::eExpressionSetupError;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-03-13 07:43:15 +08:00
|
|
|
// We need to make sure we record the fact that we are running an expression
|
2018-05-01 00:49:04 +08:00
|
|
|
// here otherwise this fact will fail to be recorded when fetching an
|
|
|
|
// Objective-C object description
|
2012-08-04 06:24:48 +08:00
|
|
|
if (exe_ctx.GetProcessPtr())
|
|
|
|
exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2016-03-19 08:03:59 +08:00
|
|
|
return_value = exe_ctx.GetProcessRef().RunThreadPlan(
|
|
|
|
exe_ctx, call_plan_sp, real_options, diagnostic_manager);
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
if (log) {
|
2014-05-05 10:47:44 +08:00
|
|
|
if (return_value != lldb::eExpressionCompleted) {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
|
2020-05-21 09:00:56 +08:00
|
|
|
"completed abnormally: %s ==",
|
|
|
|
m_name.c_str(),
|
|
|
|
Process::ExecutionResultAsCString(return_value));
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2019-07-25 01:56:10 +08:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
"== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
|
|
|
|
"completed normally ==",
|
|
|
|
m_name.c_str());
|
2013-11-07 08:11:47 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
if (exe_ctx.GetProcessPtr())
|
|
|
|
exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
|
2013-03-07 03:57:25 +08: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 19:14:47 +08:00
|
|
|
if (args_addr_ptr != nullptr)
|
2015-09-16 05:13:50 +08:00
|
|
|
*args_addr_ptr = args_addr;
|
2016-03-19 08:03:59 +08:00
|
|
|
|
2014-05-05 10:47:44 +08:00
|
|
|
if (return_value != lldb::eExpressionCompleted)
|
|
|
|
return return_value;
|
2016-03-19 08:03:59 +08:00
|
|
|
|
2012-08-04 06:24:48 +08:00
|
|
|
FetchFunctionResults(exe_ctx, args_addr, results);
|
2016-03-19 08:03:59 +08: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 19:14:47 +08:00
|
|
|
if (args_addr_ptr == nullptr)
|
2016-03-19 08:03:59 +08:00
|
|
|
DeallocateFunctionResults(exe_ctx, args_addr);
|
|
|
|
|
2014-05-05 10:47:44 +08:00
|
|
|
return lldb::eExpressionCompleted;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|