Commit Graph

422 Commits

Author SHA1 Message Date
Greg Clayton c7bece56fa <rdar://problem/13069948>
Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary.

So I defined a new "lldb::offset_t" which should be used for all file offsets.

After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed.

Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections.

llvm-svn: 173463
2013-01-25 18:06:21 +00:00
Greg Clayton a4d8747d0f <rdar://problem/13010007>
Added the ability for OS plug-ins to lazily populate the thread this. The python OS plug-in classes can now implement the following method:

class OperatingSystemPlugin:
  def create_thread(self, tid, context):
    # Return a dictionary for a new thread to create it on demand

This will add a new thread to the thread list if it doesn't already exist. The example code in lldb/examples/python/operating_system.py has been updated to show how this call us used.

Cleaned up the code in PythonDataObjects.cpp/h:
- renamed all classes that started with PythonData* to be Python*. 
- renamed PythonArray to PythonList. Cleaned up the code to use inheritance where
- Centralized the code that does ref counting in the PythonObject class to a single function.
- Made the "bool PythonObject::Reset(PyObject *)" function be virtual so each subclass can correctly check to ensure a PyObject is of the right type before adopting the object.
- Cleaned up all APIs and added new constructors for the Python* classes to they can all construct form:
	- PyObject *
	- const PythonObject &
	- const lldb::ScriptInterpreterObjectSP &

Cleaned up code in ScriptInterpreterPython:
- Made calling python functions safer by templatizing the production of value formats. Python specifies the value formats based on built in C types (long, long long, etc), and code often uses typedefs for uint32_t, uint64_t, etc when passing arguments down to python. We will now always produce correct value formats as the templatized code will "do the right thing" all the time.
- Fixed issues with the ScriptInterpreterPython::Locker where entering the session and leaving the session had a bunch of issues that could cause the "lldb" module globals lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame to not be initialized.

llvm-svn: 172873
2013-01-18 23:41:08 +00:00
Greg Clayton e0d5323734 Disassemble the vAttach packet.
llvm-svn: 172871
2013-01-18 23:30:12 +00:00
Greg Clayton b14bed80cb Remove std::string input arguments and replace with "const char *".
llvm-svn: 172647
2013-01-16 19:53:55 +00:00
Enrico Granata bcd80b4723 <rdar://problem/13021266>
Adding FindFirstGlobalVariable to SBModule and SBTarget
These calls work like FindGlobalVariables but they only return the first match found and so they can return an SBValue instead of an SBValueList for added convenience of use

llvm-svn: 172636
2013-01-16 18:53:52 +00:00
Greg Clayton 949e82216c <rdar://problem/13009943>
Added a unique integer identifier to processes. Some systems, like JTAG or other simulators, might always assign the same process ID (pid) to the processes that are being debugged. In order for scripts and the APIs to uniquely identify the processes, there needs to be another ID. Now the SBProcess class has:

uint32_t SBProcess::GetUniqueID();

This integer ID will help to truly uniquely identify a process and help with appropriate caching that can be associated with a SBProcess object.

llvm-svn: 172628
2013-01-16 17:29:04 +00:00
Greg Clayton d393ca9fb8 SDKROOT should only be unset/cleared for ARM builds. The first fix by Bob Wilson removed it for ARM for both configure and make, but only unset it for desktop configure, not for the make. My next fix unset/cleared it all the time. This fix only unset/clears it for ARM builds.
llvm-svn: 172593
2013-01-16 01:27:32 +00:00
Greg Clayton b02cb40c18 Fix clang builds that were broken due to SDKROOT changes of you have an internal OS build.
llvm-svn: 172582
2013-01-16 00:41:14 +00:00
Jim Ingham 184e981111 Separated the "expr --unwind-on-error" behavior into two parts, actual errors (i.e. crashes) which continue to be
controlled by the --unwind-on-error flag, and --ignore-breakpoint which separately controls behavior when a called
function hits a breakpoint.  For breakpoints, we don't unwind, we either stop, or ignore the breakpoint, which makes
more sense.  
Also make both these behaviors globally settable through "settings set".
Also handle the case where a breakpoint command calls code that ends up re-hitting the breakpoint.  We were recursing
and crashing.  Now we just stop without calling the second command.

<rdar://problem/12986644>
<rdar://problem/9119325>

llvm-svn: 172503
2013-01-15 02:47:48 +00:00
Bob Wilson 1b53bc78a3 Fix cross-compiling problems in build-llvm.pl script. <rdar://problem/12986905>
As with llvm svn r172138, this patch is basically copying some changes that
we've been using for building clang at Apple. Besides cleaning it up to use
xcrun to locate the proper versions of tools, especially for cross compiling,
it fixes the build to work with newer versions of clang that honor SDKROOT
settings in the environment.

llvm-svn: 172324
2013-01-12 19:33:08 +00:00
Bob Wilson d1897e4f86 Fix typo in function name and one more whitespace tweak.
llvm-svn: 172240
2013-01-11 19:24:51 +00:00
Bob Wilson aec10c6d44 Fix whitespace.
This script used an inconsistent mix of spaces and tabs, and even
ignoring that, it still had inconsistent indentation, which is
pretty scary for a Python script. I also removed trailing whitespace
from some lines.

llvm-svn: 172237
2013-01-11 19:00:56 +00:00
Jim Ingham bf2956a2f8 Add an SBProcess API to get the current StopID, either considering or ignoring stops caused by expression
evaluation.

<rdar://problem/12968562>

llvm-svn: 171914
2013-01-08 23:22:42 +00:00
Greg Clayton 4b63a5c1ce <rdar://problem/12928282>
Added SBTarget::EvaluateExpression() so expressions can be evaluated without needing a process.

Also fixed many functions that deal with clang AST types to be able to properly handle the clang::Type::Elaborated types ("struct foo", "class bar").

llvm-svn: 171476
2013-01-04 18:10:18 +00:00
Jim Ingham 1b5792e5ad Adding events when watchpoints are set or changed.
<rdar://problem/11597849>

llvm-svn: 170400
2012-12-18 02:03:49 +00:00
Jim Ingham c627682ef7 Fixed a few bugs in the "step in" thread plan logic.
Added a "step-in-target" flag to "thread step-in" so if you have something like:

Process 28464 stopped
* thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1
    frame #0: 0x0000000100000e08 a.out`main at main.c:62
   61         
-> 62         int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint.
   63             

and you want to get into "complex" skipping a, b and c, you can do:

(lldb) step -t complex
Process 28464 stopped
* thread #1: tid = 0x1c03, function: complex , stop reason = step in
    frame #0: 0x0000000100000d0d a.out`complex at main.c:44
   41     
   42     int complex (int first, int second, int third)
   43     {
-> 44         return first + second + third;  // Step in targetting complex should stop here
   45     }
   46         
   47     int main (int argc, char const *argv[])

llvm-svn: 170008
2012-12-12 19:58:40 +00:00
Greg Clayton bc41bf70bd Make sure that the lldb globals:
lldb.target
    lldb.process
    lldb.thread
    lldb.frame

are initialized to at least contain empty lldb classes in case some python gets imported that uses them.

llvm-svn: 169750
2012-12-10 19:18:23 +00:00
Greg Clayton 315501e254 Added GetCanonicalType() to SBType:
lldb::SBType
SBType::GetCanonicalType();

llvm-svn: 169655
2012-12-08 00:17:07 +00:00
Greg Clayton b43165b7a5 <rdar://problem/12749733>
Always allows getting builtin types by name even if there is no backing debug information.

llvm-svn: 169424
2012-12-05 21:24:42 +00:00
Greg Clayton 90ba81150e <rdar://problem/12649160>
Added the ability to debug through your process exec'ing itself to the same architecture.

llvm-svn: 169340
2012-12-05 00:16:59 +00:00
Greg Clayton e14e19253d <rdar://problem/12750060>
Add the ability to get a symbol or symbols by name and type from a SBModule, and also the ability to get all symbols by name and type from SBTarget objects.

llvm-svn: 169205
2012-12-04 02:22:16 +00:00
Daniel Malea c9449ad631 Match extern "C" in declaration and definition (swig template)
- Fix for building with gcc 4.6

llvm-svn: 168901
2012-11-29 16:38:44 +00:00
Daniel Malea 16e126c70b Linux buildbot fix: detect swig tool from PATH in shell script (before searching hardcoded directories)
llvm-svn: 168831
2012-11-28 23:49:11 +00:00
Han Ming Ong ab3b8b22a1 <rdar://problem/12720514> Sub-TLF: Provide service to profile the inferior
This allows client to query profiling states on the inferior.

llvm-svn: 168228
2012-11-17 00:21:04 +00:00
Filipe Cabecinhas c281a3bf43 Makefile patches from Charles Davis and Daniel Malea (+ one or two tweaks).
llvm-svn: 167242
2012-11-01 18:55:16 +00:00
Greg Clayton 373670df5a Added the ability to get function return and argument types to SBType():
bool
     SBType::IsFunctionType ();

     lldb::SBType
     SBType::GetFunctionReturnType ();
 
     lldb::SBTypeList
     SBType::GetFunctionArgumentTypes ();

llvm-svn: 167023
2012-10-30 16:57:17 +00:00
Enrico Granata 7389f8454f Ensuring that the swig typemaps for SBData set the size to 0 along with the pointer to NULL
There should be no functional changes as SBData creation functions already checked for NULL regardless of size - but it ensures consistency

llvm-svn: 166978
2012-10-29 23:06:44 +00:00
Jim Ingham d7b30ef93c Add API to get the process plugin name & short name.
llvm-svn: 166799
2012-10-26 19:18:04 +00:00
Enrico Granata adaf282c76 <rdar://problem/12523238> Commit 1 of 3
This commit enables the new HasChildren() feature for synthetic children providers
Namely, it hooks up the required bits and pieces so that individual synthetic children providers can implement a new (optional) has_children call
Default implementations have been provided where necessary so that any existing providers continue to work and behave correctly

Next steps are:
2) writing smart implementations of has_children for our providers whenever possible
3) make a test case

llvm-svn: 166495
2012-10-23 19:54:09 +00:00
Greg Clayton 4a792072ce <rdar://problem/12493007>
Added a new API call to help efficiently determine if a SBValue could have children:

     bool
     SBValue::MightHaveChildren ();
     
This is inteneded to be used bui GUI programs that need to show if a SBValue needs a disclosure triangle when displaying a hierarchical type in a tree view without having to complete the type (by calling SBValue::GetNumChildren()) as completing the type is expensive.

llvm-svn: 166460
2012-10-23 01:50:10 +00:00
Enrico Granata e3e91517ff <rdar://problem/12437442>
Given our implementation of ValueObjects we could have a scenario where a ValueObject has a dynamic type of Foo* at one point, and then its dynamic type changes to Bar*
If Bar* has synthetic children enabled, by the time we figure that out, our public API is already vending SBValues wrapping a DynamicVO, instead of a SyntheticVO and there was
no trivial way for us to change the SP inside an SBValue on the fly
This checkin reimplements SBValue in terms of a wrapper, ValueImpl, that allows this substitutions on-the-fly by overriding GetSP() to do The Right Thing (TM)
As an additional bonus, GetNonSyntheticValue() now works, and we can get rid of the ForceDisableSyntheticChildren idiom in ScriptInterpreterPython
Lastly, this checkin makes sure the synthetic VOs get the correct m_value and m_data from their parents (prevented summaries from working in some cases)

llvm-svn: 166426
2012-10-22 18:18:36 +00:00
Greg Clayton cced1566e2 API cleanup.
llvm-svn: 166070
2012-10-16 22:58:25 +00:00
Jim Ingham 35e1bda695 Add the ability to set timeout & "run all threads" options both from the "expr" command and from
the SB API's that evaluate expressions.

<rdar://problem/12457211>

llvm-svn: 166062
2012-10-16 21:41:58 +00:00
Enrico Granata 430e540b6b Removing the two extra GetXSize(bool) calls since we do not desire to support them long-term
llvm-svn: 166060
2012-10-16 21:11:14 +00:00
Enrico Granata cd4d24d5e9 <rdar://problem/12446320> Fixing an issue with our Driver where setting an immediate output would not cause suppression of the final printout. This allows effective output redirection for Python commands
llvm-svn: 166058
2012-10-16 20:57:12 +00:00
Greg Clayton eaafa732df <rdar://problem/12490588>
From SBType, we can now get a lldb::BasicType enumeration out of an existing type.

llvm-svn: 165857
2012-10-13 00:20:27 +00:00
Greg Clayton ea561dcffb <rdar://problem/12490558>
SBProcess::SetSelectedThreadByID() had a "uint32_t tid" parameter which would truncate 64 bit thread IDs (lldb::tid_t is 64 bit).

llvm-svn: 165852
2012-10-12 23:32:11 +00:00
Enrico Granata 10de09044e <rdar://problem/12462744> Implement a new SBDeclaration class to wrap an lldb_private::Declaration - make a GetDeclaration() API on SBValue to return a declaration. This will only work for vroot variables as they are they only objects for which we currently provide a valid Declaration
llvm-svn: 165672
2012-10-10 22:54:17 +00:00
Jim Ingham 4f465cff8a Change the Thread constructor over to take a Process& rather than a ProcessSP. We can't create Threads with a NULL ProcessSP, so it makes no sense to use the SP.
Then make the Thread a Broadcaster, and get it to broadcast when the selected frame is changed (but only from the Command Line) and when Thread::ReturnFromFrame 
changes the stack.
Made the Driver use this notification to print the new thread status rather than doing it in the command.
Fixed a few places where people were setting their broadcaster class by hand rather than using the static broadcaster class call.

<rdar://problem/12383087>

llvm-svn: 165640
2012-10-10 18:32:14 +00:00
Greg Clayton 13d4dfd3f2 Fix a build warning and a dangerous possible crasher.
llvm-svn: 165460
2012-10-08 23:50:19 +00:00
Enrico Granata beea93c130 <rdar://problem/12200505> Fixing a logical error in SBProcess, where the get_process_thread_list function was creating invalid threads_access instances, and hence failing to correctly fill in the list
llvm-svn: 165421
2012-10-08 19:06:11 +00:00
Enrico Granata f75c976928 Silly me! There was a closing ) missing from one of the lines - and Python complained about syntax errors on the next line. It being a Friday afternoon made the rest
llvm-svn: 165420
2012-10-08 19:01:10 +00:00
Enrico Granata 944b4c4c1b Retrying to apply Vishal's patch - hopefully this time it won't break Jason's build
llvm-svn: 165410
2012-10-08 17:32:55 +00:00
Jason Molenda cc62f28735 Revert Vishal's patch that Enrico commited, at least for the weekend. With it applied,
starting lldb I get

% ./lldb -x
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/build/Debug/LLDB.framework/Versions/A/Resources/Python/lldb/__init__.py", line 9008
    raise TypeError("No array item of type %s" % str(type(key)))
        ^
SyntaxError: invalid syntax
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
(lldb)


I did a clean build and still got the problem so I'm backing this out until Enrico can
look at it.

llvm-svn: 165356
2012-10-06 01:46:12 +00:00
Enrico Granata ffe2d52a06 patch from Vishal Patel to improve our lldb.value wrapper
llvm-svn: 165348
2012-10-06 00:06:18 +00:00
Enrico Granata cd29fefbff <rdar://problem/12442990> Fix the implementation of lldb.value.__eq__
llvm-svn: 165344
2012-10-05 23:20:58 +00:00
Jim Ingham ca36cd16e4 Add one-shot breakpoints (-o option to "break set") and a tbreak alias for our gdb friends.
llvm-svn: 165328
2012-10-05 19:16:31 +00:00
Enrico Granata 70fd574c2e <rdar://problem/12099999> renaming SBStream::Printf to Print in the scripting world in order to avoid supporting varargs through SWIG
llvm-svn: 165274
2012-10-04 23:54:09 +00:00
Sean Callanan bfeb28087a Removed a directive to delete the test subdirectories
from LLVM and Clang.  This made "svn update" very
unpleasant if the original repository was fetched by
build-llvm.pl.

llvm-svn: 165268
2012-10-04 22:37:53 +00:00
Enrico Granata 21dfcd9d41 Implementing plugins that provide commands.
This checkin adds the capability for LLDB to load plugins from external dylibs that can provide new commands
It exports an SBCommand class from the public API layer, and a new SBCommandPluginInterface

There is a minimal load-only plugin manager built into the debugger, which can be accessed via Debugger::LoadPlugin.

Plugins are loaded from two locations at debugger startup (LLDB.framework/Resources/PlugIns and ~/Library/Application Support/LLDB/PlugIns) and more can be (re)loaded via the "plugin load" command

For an example of how to make a plugin, refer to the fooplugin.cpp file in examples/plugins/commands

Caveats:
	Currently, the new API objects and features are not exposed via Python.
	The new commands can only be "parsed" (i.e. not raw) and get their command line via a char** parameter (we do not expose our internal Args object)
	There is no unloading feature, which can potentially lead to leaks if you overwrite the commands by reloading the same or different plugins
	There is no API exposed for option parsing, which means you may need to use getopt or roll-your-own

llvm-svn: 164865
2012-09-28 23:57:51 +00:00