Commit Graph

102 Commits

Author SHA1 Message Date
Jason Molenda 7e1f45f9c5 Make a nested if .. if .. else block nesting more explicit with some curly braces.
llvm-svn: 151292
2012-02-23 22:32:13 +00:00
Greg Clayton 1ac04c3088 Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptr
objects for the backlink to the lldb_private::Process. The issues we were
running into before was someone was holding onto a shared pointer to a 
lldb_private::Thread for too long, and the lldb_private::Process parent object
would get destroyed and the lldb_private::Thread had a "Process &m_process"
member which would just treat whatever memory that used to be a Process as a
valid Process. This was mostly happening for lldb_private::StackFrame objects
that had a member like "Thread &m_thread". So this completes the internal
strong/weak changes.

Documented the ExecutionContext and ExecutionContextRef classes so that our
LLDB developers can understand when and where to use ExecutionContext and 
ExecutionContextRef objects.

llvm-svn: 151009
2012-02-21 00:09:25 +00:00
Sean Callanan 9df05fbb7f Extended function lookup to allow the user to
indicate whether inline functions are desired.
This allows the expression parser, for instance,
to filter out inlined functions when looking for
functions it can call.

llvm-svn: 150279
2012-02-10 22:52:19 +00:00
Jim Ingham 6a4617bb01 Some Breakpoint:: methods crept down be log the Breakpoint::BreakpointEventData methods.
llvm-svn: 150131
2012-02-09 01:49:26 +00:00
Jim Ingham e6bc6cb96f Send Breakpoint Changed events for all the relevant changes to breakpoints.
Also, provide and use accessors for the thread options on breakpoints so we
can control sending the appropriate events.

llvm-svn: 150057
2012-02-08 05:23:15 +00:00
Johnny Chen fdad6794ac Add const-ness to BreakpointLocation::IsEnabled().
llvm-svn: 149523
2012-02-01 19:05:20 +00:00
Johnny Chen 50df1f96dc Reverted 149277 changeset. It was coded that way for a reason.
llvm-svn: 149292
2012-01-30 22:48:10 +00:00
Johnny Chen dedb67ab9b Add "watch set" command as a more general interface in conjunction with "frame var -w".
Also add test cases for watching a variable as well as a location expressed as an expression.

o TestMyFirstWatchpoint.py:

  Modified to test "watchpoint set -w write global".

o TestWatchLocationWithWatchSet.py:

  Added to test "watchpoint set -w write -x 1 g_char_ptr + 7" where a contrived example program
  with several threads is supposed to only access the array index within the range [0..6], but
  there's some misbehaving thread writing past the range.

rdar://problem/10701761

llvm-svn: 149280
2012-01-30 21:46:17 +00:00
Johnny Chen a5822c0501 Make BreakpointLocation::IsEnabled() consistent with the BreakpointLocation::SetEnabled() implementation.
llvm-svn: 149277
2012-01-30 21:16:22 +00:00
Greg Clayton e1cd1be6d6 Switching back to using std::tr1::shared_ptr. We originally switched away
due to RTTI worries since llvm and clang don't use RTTI, but I was able to 
switch back with no issues as far as I can tell. Once the RTTI issue wasn't
an issue, we were looking for a way to properly track weak pointers to objects
to solve some of the threading issues we have been running into which naturally
led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared 
pointer from just a pointer, which is also easily solved using the 
std::tr1::enable_shared_from_this class. 

The main reason for this move back is so we can start properly having weak
references to objects. Currently a lldb_private::Thread class has a refrence
to its parent lldb_private::Process. This doesn't work well when we now hand
out a SBThread object that contains a shared pointer to a lldb_private::Thread
as this SBThread can be held onto by external clients and if they end up
using one of these objects we can easily crash.

So the next task is to start adopting std::tr1::weak_ptr where ever it makes
sense which we can do with lldb_private::Debugger, lldb_private::Target,
lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and
many more objects now that they are no longer using intrusive ref counted
pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive
pointers).

llvm-svn: 149207
2012-01-29 20:56:30 +00:00
Johnny Chen 9ec3c4f5a7 For Dump(Stream *s), use GetOptionsNoCreate()->GetIgnoreCount() and fix the indentation.
llvm-svn: 149002
2012-01-26 00:08:14 +00:00
Johnny Chen 29f7dff581 Typo.
llvm-svn: 148994
2012-01-25 23:08:23 +00:00
Johnny Chen a5cde26b3e Minor comment change. Plus use member function instead of directly accessing member field.
llvm-svn: 148756
2012-01-24 00:11:02 +00:00
Johnny Chen fab7a91d92 Tiny refactoring to use member functions instead of directly accessing member fields.
llvm-svn: 148743
2012-01-23 23:03:59 +00:00
Jim Ingham bc2f918200 Don't set breakpoints independently comp unit by comp unit, but look over all the file & line matches
and only pick the "best" ones.
<rdar://problem/10685990>

llvm-svn: 148087
2012-01-13 02:04:05 +00:00
Sean Callanan 20bb3aa53a The "desired result type" code in the expression
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
2011-12-21 22:22:58 +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 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 c7b650670e Added a language parameter to the expression parser,
which will in the future allow expressions to be
compiled as C, C++, and Objective-C instead of the
current default Objective-C++.  This feature requires
some additional support from Clang -- specifically, it
requires reference types in the parser regardless of
language -- so it is not yet exposed to the user.

llvm-svn: 144042
2011-11-07 23:35:40 +00:00
Johnny Chen 16dcf718d3 Add a commnad to set a condition for a watchpoint. Example:
watchpoint modify -c 'global==5'

modifies the last created watchpoint so that the condition expression
is evaluated at the stop point to decide whether we should proceed with
the stopping.

Also add SBWatchpont::SetCondition(const char *condition) to set condition
programmatically.

Test cases to come later.

llvm-svn: 142227
2011-10-17 18:58:00 +00:00
Johnny Chen ed456eb0a9 Add SBWatchpoint::GetError() API, which is not currently populated as yet.
llvm-svn: 141979
2011-10-14 19:15:48 +00:00
Johnny Chen 01a678603a SBValue::Watch() and SBValue::WatchPointee() are now the official API for creating
a watchpoint for either the variable encapsulated by SBValue (Watch) or the pointee
encapsulated by SBValue (WatchPointee).

Removed SBFrame::WatchValue() and SBFrame::WatchLocation() API as a result of that.

Modified the watchpoint related test suite to reflect the change.

Plus replacing WatchpointLocation with Watchpoint throughout the code base.

There are still cleanups to be dome.  This patch passes the whole test suite.
Check it in so that we aggressively catch regressions.

llvm-svn: 141925
2011-10-14 00:42:25 +00:00
Sean Callanan b96ff33b0e Removed namespace qualification from symbol queries.
llvm-svn: 141866
2011-10-13 16:49:47 +00:00
Sean Callanan b6d70ebc0a Added ClangNamespaceDecl * parameters to several
core Module functions that the expression parser
will soon be using.

llvm-svn: 141766
2011-10-12 02:08:07 +00:00
Jim Ingham 4cda6e058b Move the responsibility for translating the various eFunctionNameType lookups to the
SymbolFIle (it was done mostly in the BreakpointResolverName resolver before.)  Then
tailor our searches to the way the indexed maps are laid out.  This removes a bunch 
of test case failures using indexed dSYM's.

llvm-svn: 141428
2011-10-07 22:23:45 +00:00
Johnny Chen 98a49d9b77 Simplify the verbose output of WatchpointLocation::DumpWithLevel().
llvm-svn: 141307
2011-10-06 20:27:05 +00:00
Johnny Chen d4dd7993b5 Export the watchpoint related API (SBWatchpointLocation class and added SBTarget methods)
to the Python interface.

Implement yet another (threre're 3 now) iterator protocol for SBTarget: watchpoint_location_iter(),
to iterate on the available watchpoint locations.  And add a print representation for
SBWatchpointLocation.

Exercise some of these Python API with TestWatchpointLocationIter.py.

llvm-svn: 140595
2011-09-27 01:19:20 +00:00
Johnny Chen 5d0434644c Add SB API class SBWatchpointLocation and some extra methods to the SBTarget class to
iterate on the available watchpoint locations and to perform watchpoint manipulations.

I still need to export the SBWatchpointLocation class as well as the added watchpoint
manipulation methods to the Python interface.  And write test cases for them.

llvm-svn: 140575
2011-09-26 22:40:50 +00:00
Jim Ingham 87df91b866 Added the ability to restrict breakpoints by function name, function regexp, selector
etc to specific source files.
Added SB API's to specify these source files & also more than one module.
Added an "exact" option to CompileUnit's FindLineEntry API.

llvm-svn: 140362
2011-09-23 00:54:11 +00:00
Johnny Chen f04ee930a0 Add initial implementation of watchpoint commands for list, enable, disable, and delete.
Test cases to be added later.

llvm-svn: 140322
2011-09-22 18:04:58 +00:00
Greg Clayton c14ee32db5 Converted the lldb_private::Process over to use the intrusive
shared pointers.

Changed the ExecutionContext over to use shared pointers for
the target, process, thread and frame since these objects can
easily go away at any time and any object that was holding onto
an ExecutionContext was running the risk of using a bad object.

Now that the shared pointers for target, process, thread and
frame are just a single pointer (they all use the instrusive
shared pointers) the execution context is much safer and still
the same size. 

Made the shared pointers in the the ExecutionContext class protected
and made accessors for all of the various ways to get at the pointers,
references, and shared pointers.

llvm-svn: 140298
2011-09-22 04:58:26 +00:00
Johnny Chen fd158f411a StopInfoWatchpoint should override the StopInfo::ShouldStop() virtual method and delegate to
the WatchpointLocation object to check whether it should stop and allow it to update the hit
count, among other bookkeepings.

llvm-svn: 140279
2011-09-21 22:47:15 +00:00
Jim Ingham 969795f14b Add a new breakpoint type "break by source regular expression".
Fix the RegularExpression class so it has a real copy constructor.
Fix the breakpoint setting with multiple shared libraries so it makes
  one breakpoint not one per shared library.
Add SBFileSpecList, to be used to expose the above to the SB interface (not done yet.)

llvm-svn: 140225
2011-09-21 01:17:13 +00:00
Johnny Chen 86364b4521 Add some watchpoint maintenance methods to the Target class.
Plus some minor changes to the WatchpointLocationList and WatchpointLocation classes.

llvm-svn: 140211
2011-09-20 23:28:55 +00:00
Jason Molenda fd54b368ea Update declarations for all functions/methods that accept printf-style
stdarg formats to use __attribute__ format so the compiler can flag
incorrect uses.  Fix all incorrect uses.  Most of these are innocuous,
a few were resulting in crashes.

llvm-svn: 140185
2011-09-20 21:44:10 +00:00
Johnny Chen ac559323aa Add GetByIndex() methods to the WatchpointLocationList class to facilitate iteration
through the watchpoint locations by index.

llvm-svn: 140071
2011-09-19 21:53:51 +00:00
Greg Clayton 4d122c4009 Adopt the intrusive pointers in:
lldb_private::Breakpoint
lldb_private::BreakpointLocations
lldb_private::BreakpointSite
lldb_private::Debugger
lldb_private::StackFrame
lldb_private::Thread
lldb_private::Target

llvm-svn: 139985
2011-09-17 08:33:22 +00:00
Johnny Chen de6bd2432c Add a declaraion info member field to the WatchpointLocation class.
Modify CommandObjectFrame.cpp to populate this field when creating a watchpoint location.
Update the test case to verify that the declaration info matches the file and line number.

llvm-svn: 139946
2011-09-16 21:41:42 +00:00
Johnny Chen ecb623a672 Add cleanup of watchpoint locations during Target::DeleteCurrentProcess().
llvm-svn: 139840
2011-09-15 20:54:25 +00:00
Sean Callanan 3bfdaa2a47 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 02:13:07 +00:00
Johnny Chen 0c40637012 Add logging to Target::CreateWatchpointLocation() and fix some bug of using the wrong variable.
Plus simplify WatchpointLocation::Dump() output.

llvm-svn: 139724
2011-09-14 20:23:45 +00:00
Johnny Chen 3c53258964 Watchpoint WIP:
o WatchpointLocationList:
  Add a GetListMutex() method.
o WatchpointLocation:
  Fix Dump() method where there was an extra % in the format string.
o Target.cpp:
  Add implementation to CreateWatchpointLocation() to create and enable a watchpoint.

o DNBArchImplX86_64.cpp:
  Fix bugs in SetWatchpoint()/ClearWatchpoint() where '==' was used, instead of '=',
  to assign/reset the data break address to a debug register.

  Also fix bugs where a by reference debug_state should have been used, not by value.

llvm-svn: 139666
2011-09-13 23:29:31 +00:00
Johnny Chen 02ae341043 Add trivial implementation for GetDescription().
llvm-svn: 139568
2011-09-13 01:13:20 +00:00
Johnny Chen 887062aeb3 Watchpoint WIP:
o Rename from OptionGroupWatchpoint::WatchMode to OptionGroupWatchpoint::WatchType,
  and CommandArgumentType::eArgTypeWatchMode to CommandArgumentType::eArgTypeWatchType.
  Update the sources to reflect the change.

o Add a CreateWatchpointLocation() method to Target class, which is currently not implmeneted
  (returns an empty WatchpointLocationSP object).  Add logic to CommandObjectFrame::Execute()
  to exercise the added API for creating a watchpoint location.

llvm-svn: 139560
2011-09-12 23:38:44 +00:00
Johnny Chen 11309a39ea Fill out implementation of Enable/DisableWatchpoint() for ProcessGDBRemote class (Not Tested Yet).
Also update the signature of WatchpointLocation::SetEnable() to take a bool as input arg.

llvm-svn: 139198
2011-09-06 22:38:36 +00:00
Johnny Chen 1d6bad0b47 Add a data type WatchpointLocationList to the repository. A Target contains an instance of watchpoint location list.
Also add a typefed for WatchpointLocationSP to lldb-forward-rtti.h.

llvm-svn: 139166
2011-09-06 20:05:25 +00:00
Johnny Chen 8ed0ef9bae Change the signature of WatchpointLocation ctor so that the second param becomes
'size_t size', instead of 'lldb::tid_t tid'.  Pass size to the StoppointLocation
ctor as well.

llvm-svn: 139131
2011-09-06 02:52:28 +00:00
Greg Clayton 9e315589e9 Added alpha .debug_names and .debug_types support in the DWARF parser.
llvm-svn: 138996
2011-09-02 04:03:59 +00:00
Jim Ingham 16e0c68627 Make ValueObject::SetValueFromCString work correctly.
Also change the SourceInitFile to look for .lldb-<APPNAME> and source that
preferentially if it exists.
Also made the breakpoint site report its address as well as its breakpoint number
when it gets hit and can't find any the associated locations (usually because the
breakpoint got disabled or deleted programmatically between the time it was hit
and reported.)
Changed ThreadPlanCallFunction to initialize the ivar m_func in the initializers of the
constructor, rather than waiting to initialize till later on in the function.
Fixed a bug where if you make an SBError and the ask it Success, it returns false.
Fixed ValueObject::ResolveValue so that it resolves a temporary value, rather than
overwriting the one in the value object.

llvm-svn: 137536
2011-08-12 23:34:31 +00:00
Johnny Chen 0861be0c30 Silence the static analyzer.
llvm-svn: 137360
2011-08-11 21:43:13 +00:00