Commit Graph

2275 Commits

Author SHA1 Message Date
Sean Callanan ae6d614118 Fixed a potential crasher if the frame is not
avalable when a global variable is looked up.
In ClangExpressionDeclMap, a frame should usually
be available.

llvm-svn: 146066
2011-12-07 20:41:47 +00:00
Jim Ingham b35274095c Fix assert string to be more informative.
llvm-svn: 146061
2011-12-07 20:10:58 +00:00
Greg Clayton 09c3e3d7f5 <rdar://problem/10487848>
Protect a member variable from being modified by multiple threads.

llvm-svn: 145920
2011-12-06 04:51:14 +00:00
Sean Callanan 0eed0d42a0 As part of the work to make Objective-C type information
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
2011-12-06 03:41:14 +00:00
Sean Callanan 853604d596 Set a flag on the AST type dump to see Objective-C
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
2011-12-06 01:44:41 +00:00
Jim Ingham 7d1c115d2e Correct typo in method name (AddSymbolFileRepresendation...)
llvm-svn: 145884
2011-12-06 01:07:22 +00:00
Jim Ingham ac01260545 Sanity check the inputs to SBCommandInterpreter::HandleCompletion
llvm-svn: 145840
2011-12-05 19:24:15 +00:00
Sean Callanan 458bba71be Because we now call StartTagDeclarationDefinition()
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
2011-12-05 18:49:06 +00:00
Greg Clayton 3649ef008d Fixed the remaining test suite failures after the recent objective C cleanup
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
2011-12-05 06:07:35 +00:00
Greg Clayton 1075acafeb Added the ability for clients to grab a set of symbol table indexes and then
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
2011-12-03 20:02:42 +00:00
Greg Clayton 901c5ca15b Added code to make sure we don't recursively try to find an objective C
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
2011-12-03 04:40:03 +00:00
Sean Callanan bfaf54d665 Testcase fixes with the new symbol lookup code for
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
2011-12-03 04:38:43 +00:00
Sean Callanan 3b107b172d Added ClangExternalASTSourceCommon, a local superclass
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
2011-12-03 03:15:28 +00:00
Greg Clayton ef3ad87ac6 Remove accidental "else" that was left in in prior checking.
llvm-svn: 145746
2011-12-03 03:02:17 +00:00
Greg Clayton 456809c161 Added new symbol types for Objective C classes, metaclasses, and ivars. Each
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
2011-12-03 02:30:59 +00:00
Jim Ingham 25f6670003 Make the ThreadPlanStepThrough set a backstop breakpoint on the return address from
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
2011-12-03 01:52:59 +00:00
Greg Clayton c91d804af9 Fixed some extra warnings that show up with the new clang.
llvm-svn: 145735
2011-12-03 00:46:21 +00:00
Greg Clayton 934cb05e40 <rdar://problem/10522194>
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
2011-12-03 00:27:05 +00:00
Greg Clayton 4c3b8fb7e6 <rdar://problem/10410131>
Fixed an issue that could cause an infinite recursion when using "type filter".

llvm-svn: 145720
2011-12-02 22:48:25 +00:00
Sean Callanan 3ed3bca38e Modified the Objective-C type map in SymbolFileSymtab
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
2011-12-02 18:06:45 +00:00
Sean Callanan 596ab8ee08 Added support for extracting method information from
Objective-C symbols.  The methods aren't used yet if
there is a competing definition in the DWARF; I will
resolve that next.

llvm-svn: 145675
2011-12-02 03:41:39 +00:00
Greg Clayton 1ba6cfd1e6 After moving lldb::pid_t to 64 bits, keep a deprecated version around for
previous binaries that link against this for a few builds to make sure we
can continue to run against previous binaries.

llvm-svn: 145668
2011-12-02 02:10:57 +00:00
Greg Clayton e04741d03a <rdar://problem/10394517>
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
2011-12-02 02:09:28 +00:00
Jim Ingham 6d6d107167 "f" should be an alias for "frame select" not "finish" to match the gdb usage.
llvm-svn: 145660
2011-12-02 01:12:59 +00:00
Greg Clayton 61e7a58c0c Process IDs (lldb::pid_t) and thread IDs (lldb::tid_t) are now 64 bit. This
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
2011-12-01 23:28:38 +00:00
Sean Callanan e0a64f7302 Modified clients of ClangASTImporter to be more robust
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
2011-12-01 21:04:37 +00:00
Jim Ingham 87c665fb8d Protect a few log->Printf calls with "if (log)"...
llvm-svn: 145625
2011-12-01 20:26:15 +00:00
Sean Callanan a5230ce303 Picked up a new revision of Clang to pull in Objective-C
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
2011-12-01 04:31:46 +00:00
Greg Clayton eaeaf6f906 <rdar://problem/10507811>
Avoid a crash for the new DW_OP_stack_value and DW_OP_implicit_value opcodes
that was due to an assertion.

llvm-svn: 145564
2011-12-01 04:06:15 +00:00
Jim Ingham f220d59399 If we are going to assert due to an unhanded opcode, stuff the opcode value into the CrashReporter string first.
llvm-svn: 145558
2011-12-01 03:01:30 +00:00
Sean Callanan 947ccc7396 Made symbol lookup in the expression parser more
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
2011-12-01 02:04:16 +00:00
Johnny Chen 60e2c6aa43 rdar://problem/10501020
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
2011-11-30 23:18:53 +00:00
Sean Callanan 09ab4b777c Added support to the Objective-C language runtime
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
2011-11-30 22:11:59 +00:00
Greg Clayton 1bba2bedde Make sure that we print out function or symbol information. If we disassembled
a symbol, were weren't showing the "<module>`<symbol>" header.

llvm-svn: 145511
2011-11-30 19:36:42 +00:00
Johnny Chen d0cff1ea9b I broke the test suite (4 failures) with r145459 check-in.
Fix the breakage by properly setting the result status before returning.

llvm-svn: 145507
2011-11-30 19:09:20 +00:00
Jim Ingham 5a14c543c7 Turn off the resolver detection till we find a better method to do so.
llvm-svn: 145472
2011-11-30 03:15:08 +00:00
Greg Clayton 3a5f29a073 Add a work around to deal with incorrect forward class definitions in
objective C DWARF emitted by clang.

llvm-svn: 145471
2011-11-30 02:48:28 +00:00
Johnny Chen faa5c13d8f Remove possible cut-and-paste code which doesn't belong.
llvm-svn: 145459
2011-11-29 23:56:14 +00:00
Greg Clayton 187748456a <rdar://problem/10500242>
Find the one true objective C type definition if there is one within a module.

llvm-svn: 145457
2011-11-29 23:40:34 +00:00
Sean Callanan 0712f46f4f Modified ClangExpressionDeclMap to use existing
ValueObjects when creating variables referring to
live data rather than constructing
ValueObjectConstResults.

llvm-svn: 145437
2011-11-29 22:03:21 +00:00
Jim Ingham 9c97844404 Missing return in error handling for "source list".
llvm-svn: 145435
2011-11-29 21:21:26 +00:00
Jim Ingham e309e75d5a Typo in error string.
llvm-svn: 145434
2011-11-29 21:16:36 +00:00
Greg Clayton 28041352cb Patch from Dawn that fixes up linux debugging and a first passs at an
implementation of the linux platform.

llvm-svn: 145433
2011-11-29 20:50:10 +00:00
Greg Clayton ad9e828c89 <rdar://problem/10429064>
Fixed an issue where if we are debugging on a remote platform and set a
platform path for our executable, it was not being honored by the new
launch functions that used the ProcessLaunchInfo.

llvm-svn: 145371
2011-11-29 04:03:30 +00:00
Johnny Chen 62212f0e62 Patch from Daniel Dunbar for future-proof against http://llvm.org/viewvc/llvm-project?view=rev&revision=145331.
llvm-svn: 145345
2011-11-29 01:09:49 +00:00
Sean Callanan 9973231fb0 Changed ClangASTImporter to allow finer-grained
management of what allocations remain after an
expression finishes executing.  This saves around
2.5KiB per expression for simple expressions.

llvm-svn: 145342
2011-11-29 00:42:02 +00:00
Greg Clayton 129d12c00c <rdar://problem/10413589>
Fixed a potential crasher where we weren't checking we got a valid DIE in
a compile unit.

llvm-svn: 145226
2011-11-28 03:29:03 +00:00
Greg Clayton cc23eb6fbf Now the linux platform lets it be known that it can't launch processes for
debugging.

llvm-svn: 145221
2011-11-28 01:47:46 +00:00
Greg Clayton c982b3d6e6 CommandObjectProcess was recently changed to automatically use the platform
to launch a process for debugging. Since this isn't supported on all platforms,
we need to do what we used to do if this isn't supported. I added:

    bool
    Platform::CanDebugProcess ();
    
This will get checked before trying to launch a process for debugging and then
fall back to launching the process through the current host debugger. This
should solve the issue for linux and keep the platform code clean.

Centralized logging code for logging errors, warnings and logs when reporting
things for modules or symbol files. Both lldb_private::Module and 
lldb_private::SymbolFile now have the following member functions:

    void                    
    LogMessage (Log *log, const char *format, ...);

    void
    ReportWarning (const char *format, ...);

    void
    ReportError (const char *format, ...);

These will all output the module name and object (if any) such as:

    "error: lldb.so ...."
    "warning: my_archive.a(foo.o) ...."
    
This will keep the output consistent and stop a lot of logging calls from 
having to try and output all of the information that uniquely identifies
a module or symbol file. Many places in the code were grabbing the path to the
object file manually and if the module represented a .o file in an archive, we
would see log messages like:

    error: foo.a - some error happened

llvm-svn: 145219
2011-11-28 01:45:00 +00:00
Greg Clayton 1abfe04d79 Fixed an issue in the DWARFLocationList::Dump() function where default
arguments were quietly masked as the code changed (modified version of a path
from Dawn).

llvm-svn: 145216
2011-11-28 00:51:27 +00:00