Switch from GetReturnValue, which was hardly ever used, to GetReturnValueObject
which is much more convenient.
Return the "return value object" as a persistent variable if requested.
llvm-svn: 147157
parser has hitherto been an implementation waiting
for a use. I have now tied the '-o' option for
the expression command -- which indicates that the
result is an Objective-C object and needs to be
printed -- to the ExpressionParser, which
communicates the desired type to Clang.
Now, if the result of an expression is determined
by an Objective-C method call for which there is
no type information, that result is implicitly
cast to id if and only if the -o option is passed
to the expression command. (Otherwise if there
is no explicit cast Clang will issue an error.
This behavior is identical to what happened before
r146756.)
Also added a testcase for -o enabled and disabled.
llvm-svn: 147099
with incomplete definition data were being converted.
Now Clang attempts to complete RecordDecls before
converting them, avoiding a nasty crash.
llvm-svn: 147029
types that have been imported multiple times.
The discussion below uses this diagram:
ASTContext A B C
Decl Da Db Dc
ASTImporter \-Iab-/\-Iac-/
\-----Iac----/
When a Decl D is imported from ASTContext A to
ASTContext B, the ASTImporter Iab records the
pair <Da, Db> in a DenseMap. That way, if Iab
ever encounters Da again (for example, as the
DeclContext for another Decl), it can use the
imported version. This is not an optimization,
it is critical: if I import the field "st_dev"
as part of importing "struct stat," the field
must have DeclContext equal to the parent
structure or we end up with multiple different
Decls containing different parts of "struct
stat." "struct stat" is imported once and
recorded in the DenseMap; then the ASTImporter
finds that same version when looking for the
DeclContext of "st_dev."
The bug arises when Db is imported into another
ASTContext C and ASTContext B goes away. This
often occurs when LLDB produces result variables
for expressions. Ibc is aware of the transport
of Db to Dc, but a brand new ASTImporter, Iac,
is responsible for completing Dc from its source
upon request. That ASTImporter has no mappings,
so it will produce a clone of Dc when attempting
to import its children. That means that type
completion operations on Dc will fail.
The solution is to create Iac as soon as Ibc
imports D from B to C, and inform Iac of the
mapping between Da and Dc. This allows type
completion to happen correctly.
llvm-svn: 147016
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check
Add a NULL check for SBValue.CreateValueFromExpression().
llvm-svn: 146954
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check
Add a NULL check for SBTarget.AttachToProcessWithName() so it will not hang.
llvm-svn: 146948
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check
Add NULL checks for SBCommandReturnObject.AppendMessage().
llvm-svn: 146911
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check
Add NULL checks for SBCommandInterpreter APIs.
llvm-svn: 146909
rdar://problem/10577182
Audit lldb API impl for places where we need to perform a NULL check
Add NULL checks for SBModule and SBSection APIs.
llvm-svn: 146899
"id" from being found by the parser as an
externally-defined type. Before, "id" would
sometimes make it through if it was defined in
a namespace, but this sometimes caused
confusion, for example when it conflicted with
std::locale::id.
llvm-svn: 146891
as part of the thread format output.
Currently this is only done for the ThreadPlanStepOut.
Add a convenience API ABI::GetReturnValueObject.
Change the ValueObject::EvaluationPoint to BE an ExecutionContextScope, rather than
trying to hand out one of its subsidiary object's pointers. That way this will always
be good.
llvm-svn: 146806
enhanced disassembler classify disassemblers by
target triple (as a string) rather than just by
the architecture component of the triple. This
fixes a problem where different variants of the
Thumb instruction set were lumped into the same
hash bucket.
llvm-svn: 146799
valobj.AddressOf() returns None when an address is expected in a SyntheticChildrenProvider
Patch from Enrico Granata:
The problem was that the frozen object created by the expression parser was a copy of the contents of the StgClosure, rather than a pointer to it. Thus, the expression parser was correctly computing the result of the arithmetic&cast operation along with its address, but only saving it in the live object. This meant that the frozen copy acted as an address-less variable, hence the problem.
The fix attached to this email lets the expression parser store the "live address" in the frozen copy of the address when the object is built without a valid address of its own.
Doing so, along with delegating ValueObjectConstResult to calculate its own address when necessary, solves the issue. I have also added a new test case to check for regressions in this area, and checked that existing test cases pass correctly.
llvm-svn: 146768
we handle Objective-C method calls. Currently,
LLDB treats the result of an Objective-C method
as unknown if the type information doesn't have
the method's signature. Now Clang can cast the
result to id if it isn't explicitly cast.
I also added a test case for this, as well as a
fix for a type import problem that this feature
exposed.
llvm-svn: 146756
1 -- an address pointing off into non-executable memory -- don't
abort the unwind. We'll use the ABI's default UnwindPlan to try
to get out of frame 1 and on many platforms with a standard frame
chain stack layout we can get back on track and get a valid frame
2. This preserves the lldb behavior to-date; the change last week
to require the memory region to be executable broke it.
I'd like to mark this frame specially when displayed to the user;
I tried to override the places where the frame's pc value is returned
to change it to a sentinel value (e.g. LLDB_INVALID_ADDRESS) but
couldn't get that to work cleanly so I backed that part out for
now. When this happens we'll often miss one of the user's actual
frames, the one that's of most interest to the user, so I'd like
to make this visually distinctive.
Note that a frame in non-executable memory region is only allowed
for frame 1. After that we should be solid on the unwind and any
pc address in non-executable memory indicates a failure and we
should stop unwinding.
llvm-svn: 146723
Instead of getting the location of the variable and converting the hex string to an int, just use
val.AddressOf().GetValueAsUnsigned() to compute the address of the memory region to read from.
llvm-svn: 146719
Added a static memory pressure function in SBDebugger:
void SBDebugger::MemoryPressureDetected ()
This can be called by applications that detect memory pressure to cause LLDB to release cached information.
llvm-svn: 146640
size_t
SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
uint64_t
SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
lldb::addr_t
SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
These ReadCStringFromMemory() has some SWIG type magic that makes it return the
python string directly and the "buf" is not needed:
error = SBError()
max_cstr_len = 256
cstr = lldb.process.ReadCStringFromMemory (0x1000, max_cstr_len, error)
if error.Success():
....
The other two functions behave as expteced. This will make it easier to get integer values
from the inferior process that are correctly byte swapped. Also for pointers, the correct
pointer byte size will be used.
Also cleaned up a few printf style warnings for the 32 bit lldb build on darwin.
llvm-svn: 146636
lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds
SBValue::CreateValueFromAddress() should check the validity of type and its derived pointer type
before using it. Add a test case.
llvm-svn: 146629
clients to disassemble a series of raw bytes as
demonstrated by a new testcase.
In the future, this API will also allow clients
to provide a callback that adds comments for
addresses in the disassembly.
I also modified the SWIG harness to ensure that
Python ByteArrays work as well as strings as
sources of raw data.
llvm-svn: 146611
LLDBSwigPythonCallCommand crashes when a command script returns an object
Add more robustness to LLDBSwigPythonCallCommand. It should check whether the returned Python object
is a string, and only assign it as the error msg when the check holds.
Also add a regression test.
llvm-svn: 146584
dispatch functions that are implemented in hand-written assembly.
There is also hand-written eh_frame instructions for unwinding
from these functions.
Normally we don't use eh_frame instructions for the currently
executing function, prefering the assembly instruction profiling
method. But in these hand-written dispatch functions, the
profiling is doomed and we should use the eh_frame instructions.
Unfortunately there's no easy way to flag/extend the eh_frame/debug_frame
sections to annotate if the unwind instructions are accurate at
all addresses ("asynchronous") or if they are only accurate at locations
that can throw an exception ("synchronous" and the normal case for
gcc/clang generated eh_frame/debug_frame CFI).
<rdar://problem/10508134>
llvm-svn: 146551
the expression parser to locate instances where
dyn_cast<>() and isa<>() are used on types, and
replace them with getAs<>() as appropriate.
The difference is that dyn_cast<>() and isa<>()
are essentially LLVM/Clang's equivalent of RTTI
-- that is, they try to downcast the object and
return NULL if they cannot -- but getAs<>() can
traverse typedefs to perform a semantic cast.
llvm-svn: 146537
Check that the pc value for frames up the stack is in a
mapped+executable region of memory.
Check that the stack pointer for frames up the stack is
in a mapped+readable region of memory.
If the unwinder ever makes a mistake walking the stack,
these checks will help to keep it from going too far into
the weeds.
These aren't fixing any bugs that I know of, but they
add extra robustness to a complicated task.
llvm-svn: 146478
if this is a mapped/executable region of memory. If it isn't, we've jumped
through a bad pointer and we know how to unwind the stack correctly based
on the ABI.
Previously I had 0x0 special cased but if you jumped to 0x2 on x86_64 one
frame would be skipped because the unwinder would try using the x86_64
ArchDefaultUnwindPlan which relied on the rbp.
Fixes <rdar://problem/10508291>
llvm-svn: 146477
validates the "self," "this," and "_cmd" pointers
that get passed into expressions. It used to check
them aggressively for validity before allowing the
expression to run as an object method; now, this
functionality is gated by a bool and off by default.
Now the default is that when LLDB is stopped in a
method of a class, code entered using "expr" will
always masquerade as an instance method. If for
some reason "self," "this," or "_cmd" is unavailable
it will be reported as NULL. This may cause the
expression to crash if it relies on those pointers,
but for example getting the addresses of ivars will
now work as the user would expect.
llvm-svn: 146465
Modified the Xcode project to not strip liblldb-core.a for BuildAndIntegration builds
and to correctly strip only debug symbols from the command line binaries.
llvm-svn: 146462
There were two problems associated with this radar:
1. "settings show target.source-map" failed to show the source-map after, for example,
"settings set target.source-map /Volumes/data/lldb/svn/trunk/test/source-manager /Volumes/data/lldb/svn/trunk/test/source-manager/hidden"
has been executed to set the source-map.
2. "list -n main" failed to display the source of the main() function after we properly set the source-map.
The first was fixed by adding the missing functionality to TargetInstanceSettings::GetInstanceSettingsValue (Target.cpp)
and updating the support files PathMappingList.h/.cpp; the second by modifying SourceManager.cpp to fix several places
with incorrect logic.
Also added a test case test_move_and_then_display_source() to TestSourceManager.py, which moves main.c to hidden/main.c,
sets target.source-map to perform the directory mapping, and then verifies that "list -n main" can still show the main()
function.
llvm-svn: 146422
We will return a valid range when possible and omit the "permissions" key
when the memory is not readable, writeable or executeable. This will help us
know the difference between an error back from this packet and unsupported,
from just "this address isn't in a valid region".
llvm-svn: 146394
<rdar://problem/10561406>
Stopped the SymbolFileDWARF::FindFunctions (...) from always calculating
the line table entry for all functions that were found. This can slow down
the expression parser if it ends up finding a bunch of matches. Fixed the
places that were relying on the line table entry being filled in.
Discovered a recursive stack blowout that happened when "main" didn't have
line info for it and there was no line information for "main"
llvm-svn: 146330
- Even if a frame isn't present, we always try
to use FindGlobalVariable to find variables.
Instead of using frame->TrackGlobalVariable()
to promote the VariableSP into a ValueObject,
we now simply use ValueObjectVariable.
- When requesting the value of a variable, we
allow returning of the "live version" of the
variable -- that is, the variable in the
target instead of a pointer to its freeze
dried version in LLDB -- even if there is no
process present.
llvm-svn: 146315
An assertion was firing when parsing types due to trying to complete parent
class decl contenxt types too often.
Also, relax where "dsymutil" binary can come from in the Makefile.rules.
llvm-svn: 146310
hard to ensure it doesn't get invalidated out from under us. Instead look it up from the ThreadID
and StackID when asked for it.
<rdar://problem/10554409>
llvm-svn: 146309
that if we prefer the current compile unit, followed by any compile units that
already had their DIEs parsed, followed by the rest of the matches, that we
might save some memory. This turned out not to help much. The code is commented
out, but I want to check it in so I don't lose the code in case it could help
later.
Added the ability to efficiently find the objective C class implementation
when using the new .apple_types acclerator tables with the type flags. If the
type flags are not available, we default back to what we were doing before.
llvm-svn: 146250
PlatformDarwin.cpp -- call it from both PlatformRemoteiOS.cpp
and the native process PlatformDarwin.cpp when running on an arm
system.
Bump lldb version number to 94.
llvm-svn: 146249
that got hit, and first check the condition, and if that location's condition says we should stop, then we
run the callback. In the end if any location's condition and callback say we should stop, then we stop.
llvm-svn: 146242
translation unit has a interface for a class "Bar" that contains hidden ivars
in the implementation and we make sure we can see these hidden ivars. We also
test the case where we stop in translation unit that contains the
implementation first. So the test runs two tests:
1 - run and stop where we have an interface, run to main and print and make
sure we find the hidden ivar
2 - run and stop where we have an implementation, run to main and print and make
sure we find the hidden ivar
llvm-svn: 146216
in the context in which it was originally found, the
expression parser now goes hunting for it in all modules
(in the appropriate namespace, if applicable). This means
that forward-declared types that exist in another shared
library will now be resolved correctly.
Added a test case to cover this. The test case also tests
"frame variable," which does not have this functionality
yet.
llvm-svn: 146204
pointer to make the result of an expression. LLDB now
dumps the ivars of the Objective-C object and all of
its parents. This just required fixing a bug where we
didn't distinguish between Objective-C object pointers
and regular C-style pointers.
Also added a testcase to verify that this continues to
work.
llvm-svn: 146164
that is in a class from the expression parser, and it was causing an
assertion. There is now a function that will correctly resolve a type
even if it is in a class.
llvm-svn: 146141
take a SymbolFile reference and a lldb::user_id_t and be used in objects
which represent things in debug symbols that have types where we don't need
to know the true type yet, such as in lldb_private::Variable objects. This
allows us to defer resolving the type until something is used. More specifically
this allows us to get 1000 local variables from the current function, and if
the user types "frame variable argc", we end up _only_ resolving the type for
"argc" and not for the 999 other local variables. We can expand the use of this
as needed in the future.
Modified the DWARFMappedHash class to be able to read the HashData that has
more than just the DIE offset. It currently will read the atoms in the header
definition and read the data correctly. Currently only the DIE offset and
type flags are supported. This is needed for adding type flags to the
.apple_types hash accelerator tables.
Fixed a assertion crash that would happen if we have a variable that had a
DW_AT_const_value instead of a location where "location.LocationContains_DW_OP_addr()"
would end up asserting when it tried to parse the variable location as a
DWARF opcode list.
Decreased the amount of memory that LLDB would use when evaluating an expression
by 3x - 4x for clang. There was a place in the namespace lookup code that was
parsing all namespaces with a certain name in a DWARF file instead of stopping
when it found the first match. This was causing all of the compile units with
a matching namespace to get parsed into memory and causing unnecessary memory
bloat.
Improved "Target::EvaluateExpression(...)" to not try and find a variable
when the expression contains characters that would certainly cause an expression
to need to be evaluated by the debugger.
llvm-svn: 146130
for now to fix testcases. Once we have a valid use
for the function information (i.e., once properties
returning UnknownAnyTy are allowed, once we read
return type information from the runtime, among
other uses) I will re-enable this.
llvm-svn: 146129
symbols. Now we find the correct method.
Unfortunately we don't get the superclass from the
runtime yet so the method doesn't import correctly
(and I added a check to make sure that doesn't hurt
us) but once we get that information right we will
report methods correctly to the parser as well.
Getting superclass information requires a common AST
context for all Objective-C runtime information,
meaning that the superclass and the subclass are in
the same AST context in all cases. That is the next
thing that needs to be done here.
llvm-svn: 146089
for use in the benchmark against lldb's disassembly speed. Note that the lldb
executable path can already be specified using the LLDB_EXEC env variable.
rdar://problem/7511194
llvm-svn: 146050
from symbols more accessible, I have added a second
map to the ClangASTImporter: the ObjCInterfaceMetaMap.
This map keeps track of all type definitions found for
a particular Objective-C interface, allowing the
ClangASTSource to refer to all possible sources when
looking for method definitions.
There is a bug in lookup that I still need to figure out,
but after that we should be able to report full method
information for Objective-C classes shown in symbols.
Also fixed some errors I ran into when enabling the maps
for the persistent type store. The persistent type store
previously did not use the ClangASTImporter to import
types, instead using ASTImporters that got allocated each
time a type needed copying. To support the requirements
of the persistent type store -- namely, that types must be
copied, completed, and then completely severed from their
origin in the parser's AST context (which will go away) --
I added a new function called DeportType which severs all
these connections.
llvm-svn: 145914
methods. The Clang dump is now much more verbose,
but when somebody types "target modules lookup -t"
that is typically what they're looking for.
llvm-svn: 145892
and CompleteTagDeclarationDefinition() on Objective-C
interfaces populated by SymbolFileSymtab::FindTypes(),
we should mark the interface as forward-declared when
we create it.
llvm-svn: 145825
and fixes we did. Now that objective C classes are represented by symbols with
their own type, there were a few more places in the objective C code that needed
to be fixed when searching for dynamic types.
Cleaned up the objective C runtime plug-in a bit to not keep having to create
constant strings and make one less memory access when we find an "isa" in the
objective C cache.
llvm-svn: 145799
add them to a fast lookup map. lldb_private::Symtab now export the following
public typedefs:
namespace lldb_private {
class Symtab {
typedef std::vector<uint32_t> IndexCollection;
typedef UniqueCStringMap<uint32_t> NameToIndexMap;
};
}
Clients can then find symbols by name and or type and end up with a
Symtab::IndexCollection that is filled with indexes. These indexes can then
be put into a name to index lookup map and control if the mangled and
demangled names get added to the map:
bool add_demangled = true;
bool add_mangled = true;
Symtab::NameToIndexMap name_to_index;
symtab->AppendSymbolNamesToMap (indexes, add_demangled, add_mangled, name_to_index).
This can be repeated as many times as needed to get a lookup table that
you are happy with, and then this can be sorted:
name_to_index.Sort();
Now name lookups can be done using a subset of the symbols you extracted from
the symbol table. This is currently being used to extract objective C types
from object files when there is no debug info in SymbolFileSymtab.
Cleaned up how the objective C types were being vended to be more efficient
and fixed some errors in the regular expression that was being used.
llvm-svn: 145777
class. The thing with Objective C classes is the debug info might have a
definition that isn't just a forward decl, but it is incomplete. So we need to
look and see if we can find the complete definition and avoid recursing a lot
due to the fact that our accelerator tables will have many versions of the
type, but only one complete one. We might not also have the complete type
and we need to deal with this correctly.
llvm-svn: 145759
Objective-C, making symbol lookups for various raw
Objective-C symbols work correctly. The IR interpreter
makes these lookups because Clang has emitted raw
symbol references for ivars and classes.
Also improved performance in SymbolFiles, caching the
result of asking for SymbolFile abilities.
llvm-svn: 145758
for all our external AST sources that lets us associate
arbitrary flags with the types we put into the AST
contexts. Also added an API on ClangASTContext that
allows access to these flags given only an ASTContext
and a type.
Because we don't have access to RTTI, and because at
some point in the future we might encounter external
AST sources that we didn't make (so they don't subclass
ClangExternalASTSourceCommon) I added a magic number
that we check before doing anything else, so that we
can catch that problem as soon as it appears.
llvm-svn: 145748
object file can correctly make these symbols which will abstract us from the
file format and ABI and we can then ask for the objective C class symbol for
a class and find out which object file it was defined in.
llvm-svn: 145744
the function it is being asked to step through, so that even if we get the trampoline
target wrong (for instance) we will still not lose control.
The other fix here is to tighten up the handling of the case where the current plan
doesn't explain the stop, but a plan above us does. In that case, if the plan that
does explain the stop says it is done, we need to clean up the plans below it and
continue on with our processing.
llvm-svn: 145740
Fixed an issue where if we have the DWARF equivalent of:
struct foo;
class foo { ... };
Or vice versa, we wouldn't be able to find the complete type. Since many
compilers allow forward declarations to have struct and definitions to have
class, we need to be able to deal with both cases. This commit fixes this in
the DWARF parser.
llvm-svn: 145733
to use ConstStrings. The const char*s were assumed to
be from ConstStrings before, but since storing a full-on
ConstString is no more expensive than storing a const
char* it makes better sense to enforce uniqueness with
the type checker.
llvm-svn: 145688
Fixed templates with NonTypeTemplateParmDecl objects. For example:
template <unsigned N>
....
This fixes SmallVector and all of the other classes that have template params
that are non types.
llvm-svn: 145667
will allow us to represent a process/thread ID using a pointer for the OS
plug-ins where they might want to represent the process or thread ID using
the address of the process or thread structure.
llvm-svn: 145644
in the face of failures to import types, since blithely
passing on NULL types can sometimes lead to trouble.
Also eliminated a use of getAs and replaced it with
dyn_cast, which is more robust.
llvm-svn: 145628
enhancements. With these enhancements, the return values
of Objective-C methods with unknown return types can be
implicitly cast to id for the purpose of making method
calls.
So what would have required this:
(int)[(id)[ClassWithNoDebugInfo methodReturningObject] methodReturningInt]
can now be written as:
(int)[[ClassWithNoDebugInfo methodReturningObject] methodReturningInt]
llvm-svn: 145567
robust:
- Now a client can specify what kind of symbols
are needed; notably, this allows looking up
Objective-C class symbols specifically.
- In the class of symbols being looked up, if
one is non-NULL and others are NULL, LLDB now
prefers the non-NULL one.
llvm-svn: 145554
ClangASTSource::~ClangASTSource() was calling
ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext();
which had the side effect of deleting this very ClangASTSource instance. Not good.
Change it to
// We are in the process of destruction, don't create clang ast context on demand
// by passing false to Target::GetScratchClangASTContext(create_on_demand).
ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(false);
The Target::GetScratchClangASTContext(bool create_on_demand=true) has a new signature.
llvm-svn: 145537
to find Objective-C class types by looking in the
symbol tables for the individual object files.
I did this as follows:
- I added code to SymbolFileSymtab that vends
Clang types for symbols matching the pattern
"_OBJC_CLASS_$_NSMyClassName," making them
appear as Objective-C classes. This only occurs
in modules that do not have debug information,
since otherwise SymbolFileDWARF would be in
charge of looking up types.
- I made a new SymbolVendor subclass for the
Apple Objective-C runtime that is in charge of
making global lookups of Objective-C types. It
currently just sends out type lookup requests to
the appropriate SymbolFiles, but in the future we
will probably extend it to query the runtime more
completely.
I also modified a testcase whose behavior is changed
by the fact that we now actually return an Objective-C
type for __NSCFString.
llvm-svn: 145526
Fix wrong test logic in test_modules_search_paths(). Add additional exercising of 'target modules search-paths list/query".
There is a reproducible crash if 'target modules search-paths clear' is exercised during test teardown.
So we currently comment out the stmt as follows:
# Add teardown hook to clear image-search-paths after the test.
# rdar://problem/10501020
# Uncomment the following to reproduce 10501020.
#self.addTearDownHook(lambda: self.runCmd("target modules search-paths clear"))
llvm-svn: 145466