2010-06-09 00:52:24 +08:00
//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
# include "lldb/Target/Target.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
# include "lldb/Breakpoint/BreakpointResolver.h"
# include "lldb/Breakpoint/BreakpointResolverAddress.h"
# include "lldb/Breakpoint/BreakpointResolverFileLine.h"
2011-09-21 09:17:13 +08:00
# include "lldb/Breakpoint/BreakpointResolverFileRegex.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Breakpoint/BreakpointResolverName.h"
2011-10-14 08:42:25 +08:00
# include "lldb/Breakpoint/Watchpoint.h"
2010-12-14 10:59:59 +08:00
# include "lldb/Core/Debugger.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Core/Event.h"
# include "lldb/Core/Log.h"
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
# include "lldb/Core/Module.h"
# include "lldb/Core/ModuleSpec.h"
# include "lldb/Core/Section.h"
2013-03-19 08:20:55 +08:00
# include "lldb/Core/SourceManager.h"
2013-12-14 01:20:18 +08:00
# include "lldb/Core/State.h"
2014-01-28 07:43:24 +08:00
# include "lldb/Core/StreamFile.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Core/StreamString.h"
2010-12-14 10:59:59 +08:00
# include "lldb/Core/Timer.h"
# include "lldb/Core/ValueObject.h"
2015-10-20 07:11:07 +08:00
# include "lldb/Expression/REPL.h"
2015-09-16 05:13:50 +08:00
# include "lldb/Expression/UserExpression.h"
2015-09-26 04:35:58 +08:00
# include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
# include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
# include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
2014-10-21 01:46:43 +08:00
# include "lldb/Host/FileSpec.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Host/Host.h"
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
# include "lldb/Interpreter/CommandInterpreter.h"
# include "lldb/Interpreter/CommandReturnObject.h"
2012-06-05 07:19:54 +08:00
# include "lldb/Interpreter/OptionGroupWatchpoint.h"
2012-08-23 01:17:09 +08:00
# include "lldb/Interpreter/OptionValues.h"
# include "lldb/Interpreter/Property.h"
2015-03-04 07:11:11 +08:00
# include "lldb/Symbol/ClangASTContext.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Symbol/ObjectFile.h"
2015-08-26 14:04:54 +08:00
# include "lldb/Symbol/Function.h"
# include "lldb/Symbol/Symbol.h"
2015-09-16 05:13:50 +08:00
# include "lldb/Target/Language.h"
2015-03-04 07:11:11 +08:00
# include "lldb/Target/LanguageRuntime.h"
# include "lldb/Target/ObjCLanguageRuntime.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Target/Process.h"
2013-12-06 09:12:00 +08:00
# include "lldb/Target/SectionLoadList.h"
2013-11-04 17:33:30 +08:00
# include "lldb/Target/StackFrame.h"
2013-11-05 11:57:19 +08:00
# include "lldb/Target/SystemRuntime.h"
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
# include "lldb/Target/Thread.h"
# include "lldb/Target/ThreadSpec.h"
2015-10-21 08:36:34 +08:00
# include "lldb/Utility/LLDBAssert.h"
2010-06-09 00:52:24 +08:00
using namespace lldb ;
using namespace lldb_private ;
2012-02-16 14:50:00 +08:00
ConstString &
Target : : GetStaticBroadcasterClass ( )
{
static ConstString class_name ( " lldb.target " ) ;
return class_name ;
}
2010-06-09 00:52:24 +08:00
//----------------------------------------------------------------------
// Target constructor
//----------------------------------------------------------------------
2014-11-22 09:42:44 +08:00
Target : : Target ( Debugger & debugger , const ArchSpec & target_arch , const lldb : : PlatformSP & platform_sp , bool is_dummy_target ) :
2012-08-23 01:17:09 +08:00
TargetProperties ( this ) ,
2012-10-11 02:32:14 +08:00
Broadcaster ( & debugger , Target : : GetStaticBroadcasterClass ( ) . AsCString ( ) ) ,
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
ExecutionContextScope ( ) ,
2010-06-23 09:19:29 +08:00
m_debugger ( debugger ) ,
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
m_platform_sp ( platform_sp ) ,
2010-12-21 04:49:23 +08:00
m_mutex ( Mutex : : eMutexTypeRecursive ) ,
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
m_arch ( target_arch ) ,
2012-11-08 10:22:02 +08:00
m_images ( this ) ,
2013-12-06 09:12:00 +08:00
m_section_load_history ( ) ,
2010-06-09 00:52:24 +08:00
m_breakpoint_list ( false ) ,
m_internal_breakpoint_list ( true ) ,
2011-10-14 08:42:25 +08:00
m_watchpoint_list ( ) ,
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
m_process_sp ( ) ,
m_search_filter_sp ( ) ,
2010-06-09 00:52:24 +08:00
m_image_search_paths ( ImageSearchPathsChanged , this ) ,
2013-04-19 02:10:51 +08:00
m_ast_importer_ap ( ) ,
2013-03-19 08:20:55 +08:00
m_source_manager_ap ( ) ,
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
m_stop_hooks ( ) ,
2011-05-12 10:06:14 +08:00
m_stop_hook_next_id ( 0 ) ,
2013-12-06 09:12:00 +08:00
m_valid ( true ) ,
2014-11-22 09:42:44 +08:00
m_suppress_stop_hooks ( false ) ,
m_is_dummy_target ( is_dummy_target )
2010-06-09 00:52:24 +08:00
{
2010-10-31 11:01:06 +08:00
SetEventName ( eBroadcastBitBreakpointChanged , " breakpoint-changed " ) ;
SetEventName ( eBroadcastBitModulesLoaded , " modules-loaded " ) ;
SetEventName ( eBroadcastBitModulesUnloaded , " modules-unloaded " ) ;
2012-12-18 10:03:49 +08:00
SetEventName ( eBroadcastBitWatchpointChanged , " watchpoint-changed " ) ;
2013-04-06 02:49:06 +08:00
SetEventName ( eBroadcastBitSymbolsLoaded , " symbols-loaded " ) ;
2014-04-04 12:06:10 +08:00
2012-02-16 14:50:00 +08:00
CheckInWithManager ( ) ;
2010-10-31 11:01:06 +08:00
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_OBJECT ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
2014-04-04 12:06:10 +08:00
log - > Printf ( " %p Target::Target() " , static_cast < void * > ( this ) ) ;
2012-12-05 08:25:49 +08:00
if ( m_arch . IsValid ( ) )
{
2012-12-12 10:23:56 +08:00
LogIfAnyCategoriesSet ( LIBLLDB_LOG_TARGET , " Target::Target created with architecture %s (%s) " , m_arch . GetArchitectureName ( ) , m_arch . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
2012-12-05 08:25:49 +08:00
}
2010-06-09 00:52:24 +08:00
}
2014-11-22 09:42:44 +08:00
void
Target : : PrimeFromDummyTarget ( Target * target )
{
if ( ! target )
return ;
m_stop_hooks = target - > m_stop_hooks ;
2014-12-06 09:28:03 +08:00
for ( BreakpointSP breakpoint_sp : target - > m_breakpoint_list . Breakpoints ( ) )
{
if ( breakpoint_sp - > IsInternal ( ) )
continue ;
BreakpointSP new_bp ( new Breakpoint ( * this , * breakpoint_sp . get ( ) ) ) ;
AddBreakpoint ( new_bp , false ) ;
}
2014-11-22 09:42:44 +08:00
}
2010-06-09 00:52:24 +08:00
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
Target : : ~ Target ( )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_OBJECT ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
2014-04-04 12:06:10 +08:00
log - > Printf ( " %p Target::~Target() " , static_cast < void * > ( this ) ) ;
2010-06-09 00:52:24 +08:00
DeleteCurrentProcess ( ) ;
}
void
2010-10-26 11:11:13 +08:00
Target : : Dump ( Stream * s , lldb : : DescriptionLevel description_level )
2010-06-09 00:52:24 +08:00
{
2010-10-08 08:21:05 +08:00
// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
2010-10-26 11:11:13 +08:00
if ( description_level ! = lldb : : eDescriptionLevelBrief )
{
s - > Indent ( ) ;
s - > PutCString ( " Target \n " ) ;
s - > IndentMore ( ) ;
2010-10-29 12:59:35 +08:00
m_images . Dump ( s ) ;
m_breakpoint_list . Dump ( s ) ;
m_internal_breakpoint_list . Dump ( s ) ;
s - > IndentLess ( ) ;
2010-10-26 11:11:13 +08:00
}
else
{
2011-08-11 10:48:45 +08:00
Module * exe_module = GetExecutableModulePointer ( ) ;
if ( exe_module )
s - > PutCString ( exe_module - > GetFileSpec ( ) . GetFilename ( ) . GetCString ( ) ) ;
2011-05-12 09:12:28 +08:00
else
s - > PutCString ( " No executable module. " ) ;
2010-10-26 11:11:13 +08:00
}
2010-06-09 00:52:24 +08:00
}
2012-12-05 08:16:59 +08:00
void
Target : : CleanupProcess ( )
{
// Do any cleanup of the target we need to do between process instances.
// NB It is better to do this before destroying the process in case the
// clean up needs some help from the process.
m_breakpoint_list . ClearAllBreakpointSites ( ) ;
m_internal_breakpoint_list . ClearAllBreakpointSites ( ) ;
// Disable watchpoints just on the debugger side.
Mutex : : Locker locker ;
this - > GetWatchpointList ( ) . GetListMutex ( locker ) ;
DisableAllWatchpoints ( false ) ;
ClearAllWatchpointHitCounts ( ) ;
2015-02-11 08:37:54 +08:00
ClearAllWatchpointHistoricValues ( ) ;
2012-12-05 08:16:59 +08:00
}
2010-06-09 00:52:24 +08:00
void
Target : : DeleteCurrentProcess ( )
{
if ( m_process_sp . get ( ) )
{
2013-12-06 09:12:00 +08:00
m_section_load_history . Clear ( ) ;
2010-06-09 00:52:24 +08:00
if ( m_process_sp - > IsAlive ( ) )
2015-04-17 13:01:58 +08:00
m_process_sp - > Destroy ( false ) ;
2011-02-17 01:54:55 +08:00
m_process_sp - > Finalize ( ) ;
2010-06-09 00:52:24 +08:00
2012-12-05 08:16:59 +08:00
CleanupProcess ( ) ;
2010-06-09 00:52:24 +08:00
m_process_sp . reset ( ) ;
}
}
const lldb : : ProcessSP &
2012-02-09 14:16:32 +08:00
Target : : CreateProcess ( Listener & listener , const char * plugin_name , const FileSpec * crash_file )
2010-06-09 00:52:24 +08:00
{
DeleteCurrentProcess ( ) ;
2015-09-02 04:02:29 +08:00
m_process_sp = Process : : FindPlugin ( shared_from_this ( ) , plugin_name , listener , crash_file ) ;
2010-06-09 00:52:24 +08:00
return m_process_sp ;
}
const lldb : : ProcessSP &
Target : : GetProcessSP ( ) const
{
return m_process_sp ;
}
2015-10-20 07:11:07 +08:00
lldb : : REPLSP
2015-10-20 08:23:46 +08:00
Target : : GetREPL ( Error & err , lldb : : LanguageType language , const char * repl_options , bool can_create )
2015-10-20 07:11:07 +08:00
{
if ( language = = eLanguageTypeUnknown )
{
2015-10-22 03:14:33 +08:00
std : : set < LanguageType > repl_languages ;
Language : : GetLanguagesSupportingREPLs ( repl_languages ) ;
if ( repl_languages . size ( ) = = 1 )
{
language = * repl_languages . begin ( ) ;
}
2015-10-22 03:31:17 +08:00
else if ( repl_languages . size ( ) = = 0 )
{
err . SetErrorStringWithFormat ( " LLDB isn't configured with support support for any REPLs. " ) ;
return REPLSP ( ) ;
}
2015-10-22 03:14:33 +08:00
else
{
err . SetErrorStringWithFormat ( " Multiple possible REPL languages. Please specify a language. " ) ;
2015-10-22 03:31:17 +08:00
return REPLSP ( ) ;
2015-10-22 03:14:33 +08:00
}
2015-10-20 07:11:07 +08:00
}
REPLMap : : iterator pos = m_repl_map . find ( language ) ;
if ( pos ! = m_repl_map . end ( ) )
{
return pos - > second ;
}
if ( ! can_create )
{
2015-10-20 08:23:46 +08:00
err . SetErrorStringWithFormat ( " Couldn't find an existing REPL for %s, and can't create a new one " , Language : : GetNameForLanguageType ( language ) ) ;
2015-10-20 07:11:07 +08:00
return lldb : : REPLSP ( ) ;
}
2015-10-21 08:28:44 +08:00
Debugger * const debugger = nullptr ;
lldb : : REPLSP ret = REPL : : Create ( err , language , debugger , this , repl_options ) ;
2015-10-20 07:11:07 +08:00
if ( ret )
{
m_repl_map [ language ] = ret ;
return m_repl_map [ language ] ;
}
2015-10-20 08:23:46 +08:00
if ( err . Success ( ) )
{
err . SetErrorStringWithFormat ( " Couldn't create a REPL for %s " , Language : : GetNameForLanguageType ( language ) ) ;
}
return lldb : : REPLSP ( ) ;
2015-10-20 07:11:07 +08:00
}
2015-10-21 08:36:34 +08:00
void
Target : : SetREPL ( lldb : : LanguageType language , lldb : : REPLSP repl_sp )
{
lldbassert ( ! m_repl_map . count ( language ) ) ;
m_repl_map [ language ] = repl_sp ;
}
2011-08-10 10:10:13 +08:00
void
Target : : Destroy ( )
{
Mutex : : Locker locker ( m_mutex ) ;
2012-05-19 17:59:08 +08:00
m_valid = false ;
2011-08-10 10:10:13 +08:00
DeleteCurrentProcess ( ) ;
m_platform_sp . reset ( ) ;
m_arch . Clear ( ) ;
2013-11-09 08:03:31 +08:00
ClearModules ( true ) ;
2013-12-06 09:12:00 +08:00
m_section_load_history . Clear ( ) ;
2011-08-10 10:10:13 +08:00
const bool notify = false ;
m_breakpoint_list . RemoveAll ( notify ) ;
m_internal_breakpoint_list . RemoveAll ( notify ) ;
m_last_created_breakpoint . reset ( ) ;
2011-10-14 08:42:25 +08:00
m_last_created_watchpoint . reset ( ) ;
2011-08-10 10:10:13 +08:00
m_search_filter_sp . reset ( ) ;
m_image_search_paths . Clear ( notify ) ;
m_stop_hooks . clear ( ) ;
m_stop_hook_next_id = 0 ;
m_suppress_stop_hooks = false ;
}
2010-06-09 00:52:24 +08:00
BreakpointList &
Target : : GetBreakpointList ( bool internal )
{
if ( internal )
return m_internal_breakpoint_list ;
else
return m_breakpoint_list ;
}
const BreakpointList &
Target : : GetBreakpointList ( bool internal ) const
{
if ( internal )
return m_internal_breakpoint_list ;
else
return m_breakpoint_list ;
}
BreakpointSP
Target : : GetBreakpointByID ( break_id_t break_id )
{
BreakpointSP bp_sp ;
if ( LLDB_BREAK_ID_IS_INTERNAL ( break_id ) )
bp_sp = m_internal_breakpoint_list . FindBreakpointByID ( break_id ) ;
else
bp_sp = m_breakpoint_list . FindBreakpointByID ( break_id ) ;
return bp_sp ;
}
BreakpointSP
2011-09-23 08:54:11 +08:00
Target : : CreateSourceRegexBreakpoint ( const FileSpecList * containingModules ,
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
const FileSpecList * source_file_spec_list ,
RegularExpression & source_regex ,
2013-10-12 03:48:25 +08:00
bool internal ,
2015-05-18 21:41:01 +08:00
bool hardware ,
LazyBool move_to_nearest_code )
2010-06-09 00:52:24 +08:00
{
2011-09-23 08:54:11 +08:00
SearchFilterSP filter_sp ( GetSearchFilterForModuleAndCUList ( containingModules , source_file_spec_list ) ) ;
2015-05-18 21:41:01 +08:00
if ( move_to_nearest_code = = eLazyBoolCalculate )
move_to_nearest_code = GetMoveToNearestCode ( ) ? eLazyBoolYes : eLazyBoolNo ;
BreakpointResolverSP resolver_sp ( new BreakpointResolverFileRegex ( NULL , source_regex , ! static_cast < bool > ( move_to_nearest_code ) ) ) ;
2014-01-11 07:46:59 +08:00
return CreateBreakpoint ( filter_sp , resolver_sp , internal , hardware , true ) ;
2011-09-21 09:17:13 +08:00
}
BreakpointSP
2012-05-22 08:12:20 +08:00
Target : : CreateBreakpoint ( const FileSpecList * containingModules ,
const FileSpec & file ,
uint32_t line_no ,
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
LazyBool check_inlines ,
2012-05-22 08:12:20 +08:00
LazyBool skip_prologue ,
2013-10-12 03:48:25 +08:00
bool internal ,
2015-05-18 21:41:01 +08:00
bool hardware ,
LazyBool move_to_nearest_code )
2011-09-21 09:17:13 +08:00
{
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
if ( check_inlines = = eLazyBoolCalculate )
{
const InlineStrategy inline_strategy = GetInlineStrategy ( ) ;
switch ( inline_strategy )
{
case eInlineBreakpointsNever :
check_inlines = eLazyBoolNo ;
break ;
case eInlineBreakpointsHeaders :
if ( file . IsSourceImplementationFile ( ) )
check_inlines = eLazyBoolNo ;
else
check_inlines = eLazyBoolYes ;
break ;
case eInlineBreakpointsAlways :
check_inlines = eLazyBoolYes ;
break ;
}
}
2012-09-08 07:48:57 +08:00
SearchFilterSP filter_sp ;
if ( check_inlines = = eLazyBoolNo )
{
// Not checking for inlines, we are looking only for matching compile units
FileSpecList compile_unit_list ;
compile_unit_list . Append ( file ) ;
filter_sp = GetSearchFilterForModuleAndCUList ( containingModules , & compile_unit_list ) ;
}
else
{
filter_sp = GetSearchFilterForModuleList ( containingModules ) ;
}
2013-04-20 05:31:16 +08:00
if ( skip_prologue = = eLazyBoolCalculate )
skip_prologue = GetSkipPrologue ( ) ? eLazyBoolYes : eLazyBoolNo ;
2015-05-18 21:41:01 +08:00
if ( move_to_nearest_code = = eLazyBoolCalculate )
move_to_nearest_code = GetMoveToNearestCode ( ) ? eLazyBoolYes : eLazyBoolNo ;
2013-04-20 05:31:16 +08:00
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
BreakpointResolverSP resolver_sp ( new BreakpointResolverFileLine ( NULL ,
file ,
line_no ,
check_inlines ,
2015-05-18 21:41:01 +08:00
skip_prologue ,
! static_cast < bool > ( move_to_nearest_code ) ) ) ;
2014-01-11 07:46:59 +08:00
return CreateBreakpoint ( filter_sp , resolver_sp , internal , hardware , true ) ;
2010-06-09 00:52:24 +08:00
}
BreakpointSP
2013-10-12 03:48:25 +08:00
Target : : CreateBreakpoint ( lldb : : addr_t addr , bool internal , bool hardware )
2010-06-09 00:52:24 +08:00
{
Address so_addr ;
2015-08-26 14:04:54 +08:00
// Check for any reason we want to move this breakpoint to other address.
addr = GetBreakableLoadAddress ( addr ) ;
2010-06-09 00:52:24 +08:00
// Attempt to resolve our load address if possible, though it is ok if
// it doesn't resolve to section/offset.
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
// Try and resolve as a load address if possible
2013-12-06 09:12:00 +08:00
GetSectionLoadList ( ) . ResolveLoadAddress ( addr , so_addr ) ;
Added support for inlined stack frames being represented as real stack frames
which is now on by default. Frames are gotten from the unwinder as concrete
frames, then if inline frames are to be shown, extra information to track
and reconstruct these frames is cached with each Thread and exanded as needed.
I added an inline height as part of the lldb_private::StackID class, the class
that helps us uniquely identify stack frames. This allows for two frames to
shared the same call frame address, yet differ only in inline height.
Fixed setting breakpoint by address to not require addresses to resolve.
A quick example:
% cat main.cpp
% ./build/Debug/lldb test/stl/a.out
Current executable set to 'test/stl/a.out' (x86_64).
(lldb) breakpoint set --address 0x0000000100000d31
Breakpoint created: 1: address = 0x0000000100000d31, locations = 1
(lldb) r
Launching 'a.out' (x86_64)
(lldb) Process 38031 Stopped
* thread #1: tid = 0x2e03, pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280, stop reason = breakpoint 1.1, queue = com.apple.main-thread
277
278 _CharT*
279 _M_data() const
280 -> { return _M_dataplus._M_p; }
281
282 _CharT*
283 _M_data(_CharT* __p)
(lldb) bt
thread #1: tid = 0x2e03, stop reason = breakpoint 1.1, queue = com.apple.main-thread
frame #0: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_data() const at /usr/include/c++/4.2.1/bits/basic_string.h:280
frame #1: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::_M_rep() const at /usr/include/c++/4.2.1/bits/basic_string.h:288
frame #2: pc = 0x0000000100000d31, where = a.out`main [inlined] std::string::size() const at /usr/include/c++/4.2.1/bits/basic_string.h:606
frame #3: pc = 0x0000000100000d31, where = a.out`main [inlined] operator<< <char, std::char_traits<char>, std::allocator<char> > at /usr/include/c++/4.2.1/bits/basic_string.h:2414
frame #4: pc = 0x0000000100000d31, where = a.out`main + 33 at /Volumes/work/gclayton/Documents/src/lldb/test/stl/main.cpp:14
frame #5: pc = 0x0000000100000d08, where = a.out`start + 52
Each inline frame contains only the variables that they contain and each inlined
stack frame is treated as a single entity.
llvm-svn: 111877
2010-08-24 08:45:41 +08:00
if ( ! so_addr . IsValid ( ) )
{
// The address didn't resolve, so just set this as an absolute address
so_addr . SetOffset ( addr ) ;
}
2013-10-12 03:48:25 +08:00
BreakpointSP bp_sp ( CreateBreakpoint ( so_addr , internal , hardware ) ) ;
2010-06-09 00:52:24 +08:00
return bp_sp ;
}
BreakpointSP
2013-10-12 03:48:25 +08:00
Target : : CreateBreakpoint ( Address & addr , bool internal , bool hardware )
2010-06-09 00:52:24 +08:00
{
2014-12-06 09:28:03 +08:00
SearchFilterSP filter_sp ( new SearchFilterForUnconstrainedSearches ( shared_from_this ( ) ) ) ;
2010-06-09 00:52:24 +08:00
BreakpointResolverSP resolver_sp ( new BreakpointResolverAddress ( NULL , addr ) ) ;
2014-01-11 07:46:59 +08:00
return CreateBreakpoint ( filter_sp , resolver_sp , internal , hardware , false ) ;
2010-06-09 00:52:24 +08:00
}
BreakpointSP
2011-09-23 08:54:11 +08:00
Target : : CreateBreakpoint ( const FileSpecList * containingModules ,
const FileSpecList * containingSourceFiles ,
2011-07-13 01:06:17 +08:00
const char * func_name ,
uint32_t func_name_type_mask ,
2015-07-22 06:05:07 +08:00
LanguageType language ,
2012-05-22 08:12:20 +08:00
LazyBool skip_prologue ,
2013-10-12 03:48:25 +08:00
bool internal ,
bool hardware )
2010-06-09 00:52:24 +08:00
{
2010-06-29 05:30:43 +08:00
BreakpointSP bp_sp ;
if ( func_name )
{
2011-09-23 08:54:11 +08:00
SearchFilterSP filter_sp ( GetSearchFilterForModuleAndCUList ( containingModules , containingSourceFiles ) ) ;
2013-04-20 05:31:16 +08:00
if ( skip_prologue = = eLazyBoolCalculate )
skip_prologue = GetSkipPrologue ( ) ? eLazyBoolYes : eLazyBoolNo ;
2015-07-22 06:05:07 +08:00
if ( language = = lldb : : eLanguageTypeUnknown )
language = GetLanguage ( ) ;
2013-04-20 05:31:16 +08:00
2011-07-13 01:06:17 +08:00
BreakpointResolverSP resolver_sp ( new BreakpointResolverName ( NULL ,
func_name ,
func_name_type_mask ,
2015-07-22 06:05:07 +08:00
language ,
2011-07-13 01:06:17 +08:00
Breakpoint : : Exact ,
2013-04-20 05:31:16 +08:00
skip_prologue ) ) ;
2014-01-11 07:46:59 +08:00
bp_sp = CreateBreakpoint ( filter_sp , resolver_sp , internal , hardware , true ) ;
2010-06-29 05:30:43 +08:00
}
return bp_sp ;
2010-06-09 00:52:24 +08:00
}
2012-03-06 08:37:27 +08:00
lldb : : BreakpointSP
Target : : CreateBreakpoint ( const FileSpecList * containingModules ,
2012-05-15 10:33:01 +08:00
const FileSpecList * containingSourceFiles ,
const std : : vector < std : : string > & func_names ,
uint32_t func_name_type_mask ,
2015-07-22 06:05:07 +08:00
LanguageType language ,
2012-05-22 08:12:20 +08:00
LazyBool skip_prologue ,
2013-10-12 03:48:25 +08:00
bool internal ,
bool hardware )
2012-03-06 08:37:27 +08:00
{
BreakpointSP bp_sp ;
size_t num_names = func_names . size ( ) ;
if ( num_names > 0 )
{
SearchFilterSP filter_sp ( GetSearchFilterForModuleAndCUList ( containingModules , containingSourceFiles ) ) ;
2013-04-20 05:31:16 +08:00
if ( skip_prologue = = eLazyBoolCalculate )
skip_prologue = GetSkipPrologue ( ) ? eLazyBoolYes : eLazyBoolNo ;
2015-07-22 06:05:07 +08:00
if ( language = = lldb : : eLanguageTypeUnknown )
language = GetLanguage ( ) ;
2013-04-20 05:31:16 +08:00
BreakpointResolverSP resolver_sp ( new BreakpointResolverName ( NULL ,
2012-03-06 08:37:27 +08:00
func_names ,
func_name_type_mask ,
2015-07-22 06:05:07 +08:00
language ,
2013-04-20 05:31:16 +08:00
skip_prologue ) ) ;
2014-01-11 07:46:59 +08:00
bp_sp = CreateBreakpoint ( filter_sp , resolver_sp , internal , hardware , true ) ;
2012-03-06 08:37:27 +08:00
}
return bp_sp ;
}
2012-03-03 10:05:11 +08:00
BreakpointSP
Target : : CreateBreakpoint ( const FileSpecList * containingModules ,
const FileSpecList * containingSourceFiles ,
const char * func_names [ ] ,
size_t num_names ,
uint32_t func_name_type_mask ,
2015-07-22 06:05:07 +08:00
LanguageType language ,
2012-05-22 08:12:20 +08:00
LazyBool skip_prologue ,
2013-10-12 03:48:25 +08:00
bool internal ,
bool hardware )
2012-03-03 10:05:11 +08:00
{
BreakpointSP bp_sp ;
if ( num_names > 0 )
{
SearchFilterSP filter_sp ( GetSearchFilterForModuleAndCUList ( containingModules , containingSourceFiles ) ) ;
2013-04-20 05:31:16 +08:00
if ( skip_prologue = = eLazyBoolCalculate )
skip_prologue = GetSkipPrologue ( ) ? eLazyBoolYes : eLazyBoolNo ;
2015-07-22 06:05:07 +08:00
if ( language = = lldb : : eLanguageTypeUnknown )
language = GetLanguage ( ) ;
2013-04-20 05:31:16 +08:00
BreakpointResolverSP resolver_sp ( new BreakpointResolverName ( NULL ,
2012-03-03 10:05:11 +08:00
func_names ,
num_names ,
2012-03-06 08:37:27 +08:00
func_name_type_mask ,
2015-07-22 06:05:07 +08:00
language ,
2013-04-20 05:31:16 +08:00
skip_prologue ) ) ;
2014-01-11 07:46:59 +08:00
bp_sp = CreateBreakpoint ( filter_sp , resolver_sp , internal , hardware , true ) ;
2012-03-03 10:05:11 +08:00
}
return bp_sp ;
}
2010-06-09 00:52:24 +08:00
SearchFilterSP
Target : : GetSearchFilterForModule ( const FileSpec * containingModule )
{
SearchFilterSP filter_sp ;
if ( containingModule ! = NULL )
{
// TODO: We should look into sharing module based search filters
// across many breakpoints like we do for the simple target based one
2012-01-30 04:56:30 +08:00
filter_sp . reset ( new SearchFilterByModule ( shared_from_this ( ) , * containingModule ) ) ;
2010-06-09 00:52:24 +08:00
}
else
{
if ( m_search_filter_sp . get ( ) = = NULL )
2014-12-06 09:28:03 +08:00
m_search_filter_sp . reset ( new SearchFilterForUnconstrainedSearches ( shared_from_this ( ) ) ) ;
2010-06-09 00:52:24 +08:00
filter_sp = m_search_filter_sp ;
}
return filter_sp ;
}
2011-09-21 09:17:13 +08:00
SearchFilterSP
Target : : GetSearchFilterForModuleList ( const FileSpecList * containingModules )
{
SearchFilterSP filter_sp ;
if ( containingModules & & containingModules - > GetSize ( ) ! = 0 )
{
// TODO: We should look into sharing module based search filters
// across many breakpoints like we do for the simple target based one
2012-01-30 04:56:30 +08:00
filter_sp . reset ( new SearchFilterByModuleList ( shared_from_this ( ) , * containingModules ) ) ;
2011-09-21 09:17:13 +08:00
}
else
{
if ( m_search_filter_sp . get ( ) = = NULL )
2014-12-06 09:28:03 +08:00
m_search_filter_sp . reset ( new SearchFilterForUnconstrainedSearches ( shared_from_this ( ) ) ) ;
2011-09-21 09:17:13 +08:00
filter_sp = m_search_filter_sp ;
}
return filter_sp ;
}
2011-09-23 08:54:11 +08:00
SearchFilterSP
2012-05-22 08:12:20 +08:00
Target : : GetSearchFilterForModuleAndCUList ( const FileSpecList * containingModules ,
const FileSpecList * containingSourceFiles )
2011-09-23 08:54:11 +08:00
{
if ( containingSourceFiles = = NULL | | containingSourceFiles - > GetSize ( ) = = 0 )
return GetSearchFilterForModuleList ( containingModules ) ;
SearchFilterSP filter_sp ;
if ( containingModules = = NULL )
{
// We could make a special "CU List only SearchFilter". Better yet was if these could be composable,
// but that will take a little reworking.
2012-01-30 04:56:30 +08:00
filter_sp . reset ( new SearchFilterByModuleListAndCU ( shared_from_this ( ) , FileSpecList ( ) , * containingSourceFiles ) ) ;
2011-09-23 08:54:11 +08:00
}
else
{
2012-01-30 04:56:30 +08:00
filter_sp . reset ( new SearchFilterByModuleListAndCU ( shared_from_this ( ) , * containingModules , * containingSourceFiles ) ) ;
2011-09-23 08:54:11 +08:00
}
return filter_sp ;
}
2010-06-09 00:52:24 +08:00
BreakpointSP
2011-09-23 08:54:11 +08:00
Target : : CreateFuncRegexBreakpoint ( const FileSpecList * containingModules ,
2012-05-22 08:12:20 +08:00
const FileSpecList * containingSourceFiles ,
RegularExpression & func_regex ,
LazyBool skip_prologue ,
2013-10-12 03:48:25 +08:00
bool internal ,
bool hardware )
2010-06-09 00:52:24 +08:00
{
2011-09-23 08:54:11 +08:00
SearchFilterSP filter_sp ( GetSearchFilterForModuleAndCUList ( containingModules , containingSourceFiles ) ) ;
2014-07-23 09:53:52 +08:00
bool skip =
( skip_prologue = = eLazyBoolCalculate ) ? GetSkipPrologue ( )
: static_cast < bool > ( skip_prologue ) ;
2011-07-13 01:06:17 +08:00
BreakpointResolverSP resolver_sp ( new BreakpointResolverName ( NULL ,
func_regex ,
2014-07-23 09:53:52 +08:00
skip ) ) ;
2010-06-09 00:52:24 +08:00
2014-01-11 07:46:59 +08:00
return CreateBreakpoint ( filter_sp , resolver_sp , internal , hardware , true ) ;
2010-06-09 00:52:24 +08:00
}
2012-03-05 12:47:34 +08:00
lldb : : BreakpointSP
2015-04-23 03:42:18 +08:00
Target : : CreateExceptionBreakpoint ( enum lldb : : LanguageType language , bool catch_bp , bool throw_bp , bool internal , Args * additional_args , Error * error )
2012-03-05 12:47:34 +08:00
{
2015-04-23 03:42:18 +08:00
BreakpointSP exc_bkpt_sp = LanguageRuntime : : CreateExceptionBreakpoint ( * this , language , catch_bp , throw_bp , internal ) ;
if ( exc_bkpt_sp & & additional_args )
{
Breakpoint : : BreakpointPreconditionSP precondition_sp = exc_bkpt_sp - > GetPrecondition ( ) ;
if ( precondition_sp & & additional_args )
{
if ( error )
* error = precondition_sp - > ConfigurePrecondition ( * additional_args ) ;
else
precondition_sp - > ConfigurePrecondition ( * additional_args ) ;
}
}
return exc_bkpt_sp ;
2012-03-05 12:47:34 +08:00
}
2015-04-23 03:42:18 +08:00
2010-06-09 00:52:24 +08:00
BreakpointSP
2014-01-11 07:46:59 +08:00
Target : : CreateBreakpoint ( SearchFilterSP & filter_sp , BreakpointResolverSP & resolver_sp , bool internal , bool request_hardware , bool resolve_indirect_symbols )
2010-06-09 00:52:24 +08:00
{
BreakpointSP bp_sp ;
if ( filter_sp & & resolver_sp )
{
2014-01-11 07:46:59 +08:00
bp_sp . reset ( new Breakpoint ( * this , filter_sp , resolver_sp , request_hardware , resolve_indirect_symbols ) ) ;
2010-06-09 00:52:24 +08:00
resolver_sp - > SetBreakpoint ( bp_sp . get ( ) ) ;
2014-12-06 09:28:03 +08:00
AddBreakpoint ( bp_sp , internal ) ;
}
return bp_sp ;
}
2010-06-09 00:52:24 +08:00
2014-12-06 09:28:03 +08:00
void
Target : : AddBreakpoint ( lldb : : BreakpointSP bp_sp , bool internal )
{
if ( ! bp_sp )
return ;
if ( internal )
m_internal_breakpoint_list . Add ( bp_sp , false ) ;
else
m_breakpoint_list . Add ( bp_sp , true ) ;
2010-06-09 00:52:24 +08:00
2014-12-06 09:28:03 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
if ( log )
{
StreamString s ;
bp_sp - > GetDescription ( & s , lldb : : eDescriptionLevelVerbose ) ;
log - > Printf ( " Target::%s (internal = %s) => break_id = %s \n " , __FUNCTION__ , bp_sp - > IsInternal ( ) ? " yes " : " no " , s . GetData ( ) ) ;
2010-06-09 00:52:24 +08:00
}
2014-12-06 09:28:03 +08:00
bp_sp - > ResolveBreakpoint ( ) ;
if ( ! internal )
2010-10-15 07:45:03 +08:00
{
m_last_created_breakpoint = bp_sp ;
}
2010-06-09 00:52:24 +08:00
}
2011-09-21 07:28:55 +08:00
bool
Target : : ProcessIsValid ( )
{
return ( m_process_sp & & m_process_sp - > IsAlive ( ) ) ;
}
2012-06-05 07:19:54 +08:00
static bool
CheckIfWatchpointsExhausted ( Target * target , Error & error )
{
uint32_t num_supported_hardware_watchpoints ;
Error rc = target - > GetProcessSP ( ) - > GetWatchpointSupportInfo ( num_supported_hardware_watchpoints ) ;
if ( rc . Success ( ) )
{
uint32_t num_current_watchpoints = target - > GetWatchpointList ( ) . GetSize ( ) ;
if ( num_current_watchpoints > = num_supported_hardware_watchpoints )
error . SetErrorStringWithFormat ( " number of supported hardware watchpoints (%u) has been reached " ,
num_supported_hardware_watchpoints ) ;
}
return false ;
}
2011-10-14 08:42:25 +08:00
// See also Watchpoint::SetWatchpointType(uint32_t type) and
2011-09-14 08:26:03 +08:00
// the OptionGroupWatchpoint::WatchType enum type.
2011-10-14 08:42:25 +08:00
WatchpointSP
2015-08-12 06:53:00 +08:00
Target : : CreateWatchpoint ( lldb : : addr_t addr , size_t size , const CompilerType * type , uint32_t kind , Error & error )
2011-09-13 07:38:44 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-09-15 04:23:45 +08:00
if ( log )
2012-11-30 05:49:15 +08:00
log - > Printf ( " Target::%s (addr = 0x%8.8 " PRIx64 " size = % " PRIu64 " type = %u) \n " ,
2012-10-23 15:20:06 +08:00
__FUNCTION__ , addr , ( uint64_t ) size , kind ) ;
2011-09-15 04:23:45 +08:00
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp ;
2011-09-21 07:28:55 +08:00
if ( ! ProcessIsValid ( ) )
2012-06-05 07:19:54 +08:00
{
error . SetErrorString ( " process is not alive " ) ;
2011-10-14 08:42:25 +08:00
return wp_sp ;
2012-06-05 07:19:54 +08:00
}
2013-06-19 05:52:48 +08:00
2011-09-15 06:20:15 +08:00
if ( addr = = LLDB_INVALID_ADDRESS | | size = = 0 )
2012-06-05 07:19:54 +08:00
{
if ( size = = 0 )
error . SetErrorString ( " cannot set a watchpoint with watch_size of 0 " ) ;
else
2012-11-30 05:49:15 +08:00
error . SetErrorStringWithFormat ( " invalid watch address: % " PRIu64 , addr ) ;
2011-10-14 08:42:25 +08:00
return wp_sp ;
2012-06-05 07:19:54 +08:00
}
2013-06-19 05:52:48 +08:00
if ( ! LLDB_WATCH_TYPE_IS_VALID ( kind ) )
{
error . SetErrorStringWithFormat ( " invalid watchpoint type: %d " , kind ) ;
}
2011-09-13 09:15:36 +08:00
2011-10-14 08:42:25 +08:00
// Currently we only support one watchpoint per address, with total number
// of watchpoints limited by the hardware which the inferior is running on.
2012-06-01 06:56:36 +08:00
// Grab the list mutex while doing operations.
2012-12-18 10:03:49 +08:00
const bool notify = false ; // Don't notify about all the state changes we do on creating the watchpoint.
2012-06-01 06:56:36 +08:00
Mutex : : Locker locker ;
this - > GetWatchpointList ( ) . GetListMutex ( locker ) ;
2011-10-14 08:42:25 +08:00
WatchpointSP matched_sp = m_watchpoint_list . FindByAddress ( addr ) ;
2011-09-14 07:29:31 +08:00
if ( matched_sp )
{
2011-09-15 04:23:45 +08:00
size_t old_size = matched_sp - > GetByteSize ( ) ;
2011-09-14 07:29:31 +08:00
uint32_t old_type =
2011-09-15 04:23:45 +08:00
( matched_sp - > WatchpointRead ( ) ? LLDB_WATCH_TYPE_READ : 0 ) |
( matched_sp - > WatchpointWrite ( ) ? LLDB_WATCH_TYPE_WRITE : 0 ) ;
2011-10-14 08:42:25 +08:00
// Return the existing watchpoint if both size and type match.
2013-06-19 05:52:48 +08:00
if ( size = = old_size & & kind = = old_type )
{
2011-10-14 08:42:25 +08:00
wp_sp = matched_sp ;
2012-12-18 10:03:49 +08:00
wp_sp - > SetEnabled ( false , notify ) ;
2013-06-19 05:52:48 +08:00
}
else
{
2011-10-14 08:42:25 +08:00
// Nil the matched watchpoint; we will be creating a new one.
2012-12-18 10:03:49 +08:00
m_process_sp - > DisableWatchpoint ( matched_sp . get ( ) , notify ) ;
m_watchpoint_list . Remove ( matched_sp - > GetID ( ) , true ) ;
2011-09-15 06:20:15 +08:00
}
2011-09-14 07:29:31 +08:00
}
2012-12-06 07:07:34 +08:00
if ( ! wp_sp )
{
2012-12-18 10:03:49 +08:00
wp_sp . reset ( new Watchpoint ( * this , addr , size , type ) ) ;
wp_sp - > SetWatchpointType ( kind , notify ) ;
m_watchpoint_list . Add ( wp_sp , true ) ;
2011-09-15 06:20:15 +08:00
}
2011-09-15 04:23:45 +08:00
2012-12-18 10:03:49 +08:00
error = m_process_sp - > EnableWatchpoint ( wp_sp . get ( ) , notify ) ;
2011-09-15 04:23:45 +08:00
if ( log )
2012-12-06 07:07:34 +08:00
log - > Printf ( " Target::%s (creation of watchpoint %s with id = %u) \n " ,
__FUNCTION__ ,
error . Success ( ) ? " succeeded " : " failed " ,
wp_sp - > GetID ( ) ) ;
2011-09-15 04:23:45 +08:00
2012-12-06 07:07:34 +08:00
if ( error . Fail ( ) )
{
2012-03-27 06:00:10 +08:00
// Enabling the watchpoint on the device side failed.
// Remove the said watchpoint from the list maintained by the target instance.
2012-12-18 10:03:49 +08:00
m_watchpoint_list . Remove ( wp_sp - > GetID ( ) , true ) ;
2012-06-05 07:19:54 +08:00
// See if we could provide more helpful error message.
if ( ! CheckIfWatchpointsExhausted ( this , error ) )
{
if ( ! OptionGroupWatchpoint : : IsWatchSizeSupported ( size ) )
2014-03-04 03:15:20 +08:00
error . SetErrorStringWithFormat ( " watch size of % " PRIu64 " is not supported " , ( uint64_t ) size ) ;
2012-06-05 07:19:54 +08:00
}
2011-10-14 08:42:25 +08:00
wp_sp . reset ( ) ;
2012-03-27 06:00:10 +08:00
}
2011-09-28 04:29:45 +08:00
else
2011-10-14 08:42:25 +08:00
m_last_created_watchpoint = wp_sp ;
return wp_sp ;
2011-09-13 07:38:44 +08:00
}
2010-06-09 00:52:24 +08:00
void
Target : : RemoveAllBreakpoints ( bool internal_also )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
log - > Printf ( " Target::%s (internal_also = %s) \n " , __FUNCTION__ , internal_also ? " yes " : " no " ) ;
2010-07-24 07:33:17 +08:00
m_breakpoint_list . RemoveAll ( true ) ;
2010-06-09 00:52:24 +08:00
if ( internal_also )
2010-07-24 07:33:17 +08:00
m_internal_breakpoint_list . RemoveAll ( false ) ;
2010-10-15 07:45:03 +08:00
m_last_created_breakpoint . reset ( ) ;
2010-06-09 00:52:24 +08:00
}
void
Target : : DisableAllBreakpoints ( bool internal_also )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
log - > Printf ( " Target::%s (internal_also = %s) \n " , __FUNCTION__ , internal_also ? " yes " : " no " ) ;
m_breakpoint_list . SetEnabledAll ( false ) ;
if ( internal_also )
m_internal_breakpoint_list . SetEnabledAll ( false ) ;
}
void
Target : : EnableAllBreakpoints ( bool internal_also )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
log - > Printf ( " Target::%s (internal_also = %s) \n " , __FUNCTION__ , internal_also ? " yes " : " no " ) ;
m_breakpoint_list . SetEnabledAll ( true ) ;
if ( internal_also )
m_internal_breakpoint_list . SetEnabledAll ( true ) ;
}
bool
Target : : RemoveBreakpointByID ( break_id_t break_id )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
log - > Printf ( " Target::%s (break_id = %i, internal = %s) \n " , __FUNCTION__ , break_id , LLDB_BREAK_ID_IS_INTERNAL ( break_id ) ? " yes " : " no " ) ;
if ( DisableBreakpointByID ( break_id ) )
{
if ( LLDB_BREAK_ID_IS_INTERNAL ( break_id ) )
2010-07-24 07:33:17 +08:00
m_internal_breakpoint_list . Remove ( break_id , false ) ;
2010-06-09 00:52:24 +08:00
else
2010-10-15 07:45:03 +08:00
{
2011-01-25 07:35:47 +08:00
if ( m_last_created_breakpoint )
{
if ( m_last_created_breakpoint - > GetID ( ) = = break_id )
m_last_created_breakpoint . reset ( ) ;
}
2010-07-24 07:33:17 +08:00
m_breakpoint_list . Remove ( break_id , true ) ;
2010-10-15 07:45:03 +08:00
}
2010-06-09 00:52:24 +08:00
return true ;
}
return false ;
}
bool
Target : : DisableBreakpointByID ( break_id_t break_id )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
log - > Printf ( " Target::%s (break_id = %i, internal = %s) \n " , __FUNCTION__ , break_id , LLDB_BREAK_ID_IS_INTERNAL ( break_id ) ? " yes " : " no " ) ;
BreakpointSP bp_sp ;
if ( LLDB_BREAK_ID_IS_INTERNAL ( break_id ) )
bp_sp = m_internal_breakpoint_list . FindBreakpointByID ( break_id ) ;
else
bp_sp = m_breakpoint_list . FindBreakpointByID ( break_id ) ;
if ( bp_sp )
{
bp_sp - > SetEnabled ( false ) ;
return true ;
}
return false ;
}
bool
Target : : EnableBreakpointByID ( break_id_t break_id )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
2010-06-09 00:52:24 +08:00
if ( log )
log - > Printf ( " Target::%s (break_id = %i, internal = %s) \n " ,
__FUNCTION__ ,
break_id ,
LLDB_BREAK_ID_IS_INTERNAL ( break_id ) ? " yes " : " no " ) ;
BreakpointSP bp_sp ;
if ( LLDB_BREAK_ID_IS_INTERNAL ( break_id ) )
bp_sp = m_internal_breakpoint_list . FindBreakpointByID ( break_id ) ;
else
bp_sp = m_breakpoint_list . FindBreakpointByID ( break_id ) ;
if ( bp_sp )
{
bp_sp - > SetEnabled ( true ) ;
return true ;
}
return false ;
}
2011-09-24 05:21:43 +08:00
// The flag 'end_to_end', default to true, signifies that the operation is
// performed end to end, for both the debugger and the debuggee.
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end
// to end operations.
2011-09-21 07:28:55 +08:00
bool
2011-10-14 08:42:25 +08:00
Target : : RemoveAllWatchpoints ( bool end_to_end )
2011-09-21 07:28:55 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-09-21 07:28:55 +08:00
if ( log )
log - > Printf ( " Target::%s \n " , __FUNCTION__ ) ;
2011-09-24 05:21:43 +08:00
if ( ! end_to_end ) {
2012-12-18 10:03:49 +08:00
m_watchpoint_list . RemoveAll ( true ) ;
2011-09-24 05:21:43 +08:00
return true ;
}
// Otherwise, it's an end to end operation.
2011-09-21 07:28:55 +08:00
if ( ! ProcessIsValid ( ) )
return false ;
2011-10-14 08:42:25 +08:00
size_t num_watchpoints = m_watchpoint_list . GetSize ( ) ;
2011-09-21 07:28:55 +08:00
for ( size_t i = 0 ; i < num_watchpoints ; + + i )
{
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp = m_watchpoint_list . GetByIndex ( i ) ;
if ( ! wp_sp )
2011-09-21 07:28:55 +08:00
return false ;
2011-10-14 08:42:25 +08:00
Error rc = m_process_sp - > DisableWatchpoint ( wp_sp . get ( ) ) ;
2011-09-21 07:28:55 +08:00
if ( rc . Fail ( ) )
return false ;
}
2012-12-18 10:03:49 +08:00
m_watchpoint_list . RemoveAll ( true ) ;
2013-07-02 10:09:46 +08:00
m_last_created_watchpoint . reset ( ) ;
2011-09-21 07:28:55 +08:00
return true ; // Success!
}
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to
// end operations.
2011-09-21 07:28:55 +08:00
bool
2011-10-14 08:42:25 +08:00
Target : : DisableAllWatchpoints ( bool end_to_end )
2011-09-21 07:28:55 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-09-21 07:28:55 +08:00
if ( log )
log - > Printf ( " Target::%s \n " , __FUNCTION__ ) ;
2011-09-24 05:21:43 +08:00
if ( ! end_to_end ) {
2011-10-14 08:42:25 +08:00
m_watchpoint_list . SetEnabledAll ( false ) ;
2011-09-24 05:21:43 +08:00
return true ;
}
// Otherwise, it's an end to end operation.
2011-09-21 07:28:55 +08:00
if ( ! ProcessIsValid ( ) )
return false ;
2011-10-14 08:42:25 +08:00
size_t num_watchpoints = m_watchpoint_list . GetSize ( ) ;
2011-09-21 07:28:55 +08:00
for ( size_t i = 0 ; i < num_watchpoints ; + + i )
{
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp = m_watchpoint_list . GetByIndex ( i ) ;
if ( ! wp_sp )
2011-09-21 07:28:55 +08:00
return false ;
2011-10-14 08:42:25 +08:00
Error rc = m_process_sp - > DisableWatchpoint ( wp_sp . get ( ) ) ;
2011-09-21 07:28:55 +08:00
if ( rc . Fail ( ) )
return false ;
}
return true ; // Success!
}
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to
// end operations.
2011-09-21 07:28:55 +08:00
bool
2011-10-14 08:42:25 +08:00
Target : : EnableAllWatchpoints ( bool end_to_end )
2011-09-21 07:28:55 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-09-21 07:28:55 +08:00
if ( log )
log - > Printf ( " Target::%s \n " , __FUNCTION__ ) ;
2011-09-24 05:21:43 +08:00
if ( ! end_to_end ) {
2011-10-14 08:42:25 +08:00
m_watchpoint_list . SetEnabledAll ( true ) ;
2011-09-24 05:21:43 +08:00
return true ;
}
// Otherwise, it's an end to end operation.
2011-09-21 07:28:55 +08:00
if ( ! ProcessIsValid ( ) )
return false ;
2011-10-14 08:42:25 +08:00
size_t num_watchpoints = m_watchpoint_list . GetSize ( ) ;
2011-09-21 07:28:55 +08:00
for ( size_t i = 0 ; i < num_watchpoints ; + + i )
{
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp = m_watchpoint_list . GetByIndex ( i ) ;
if ( ! wp_sp )
2011-09-21 07:28:55 +08:00
return false ;
2011-10-14 08:42:25 +08:00
Error rc = m_process_sp - > EnableWatchpoint ( wp_sp . get ( ) ) ;
2011-09-21 07:28:55 +08:00
if ( rc . Fail ( ) )
return false ;
}
return true ; // Success!
}
2012-02-25 14:44:30 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
bool
Target : : ClearAllWatchpointHitCounts ( )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2012-02-25 14:44:30 +08:00
if ( log )
log - > Printf ( " Target::%s \n " , __FUNCTION__ ) ;
size_t num_watchpoints = m_watchpoint_list . GetSize ( ) ;
for ( size_t i = 0 ; i < num_watchpoints ; + + i )
{
WatchpointSP wp_sp = m_watchpoint_list . GetByIndex ( i ) ;
if ( ! wp_sp )
return false ;
wp_sp - > ResetHitCount ( ) ;
}
return true ; // Success!
}
2015-02-11 08:37:54 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
bool
Target : : ClearAllWatchpointHistoricValues ( )
{
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
if ( log )
log - > Printf ( " Target::%s \n " , __FUNCTION__ ) ;
size_t num_watchpoints = m_watchpoint_list . GetSize ( ) ;
for ( size_t i = 0 ; i < num_watchpoints ; + + i )
{
WatchpointSP wp_sp = m_watchpoint_list . GetByIndex ( i ) ;
if ( ! wp_sp )
return false ;
wp_sp - > ResetHistoricValues ( ) ;
}
return true ; // Success!
}
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list
2011-10-06 05:35:46 +08:00
// during these operations.
bool
2011-10-14 08:42:25 +08:00
Target : : IgnoreAllWatchpoints ( uint32_t ignore_count )
2011-10-06 05:35:46 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-10-06 05:35:46 +08:00
if ( log )
log - > Printf ( " Target::%s \n " , __FUNCTION__ ) ;
if ( ! ProcessIsValid ( ) )
return false ;
2011-10-14 08:42:25 +08:00
size_t num_watchpoints = m_watchpoint_list . GetSize ( ) ;
2011-10-06 05:35:46 +08:00
for ( size_t i = 0 ; i < num_watchpoints ; + + i )
{
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp = m_watchpoint_list . GetByIndex ( i ) ;
if ( ! wp_sp )
2011-10-06 05:35:46 +08:00
return false ;
2011-10-14 08:42:25 +08:00
wp_sp - > SetIgnoreCount ( ignore_count ) ;
2011-10-06 05:35:46 +08:00
}
return true ; // Success!
}
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
2011-09-21 07:28:55 +08:00
bool
2011-10-14 08:42:25 +08:00
Target : : DisableWatchpointByID ( lldb : : watch_id_t watch_id )
2011-09-21 07:28:55 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-09-21 07:28:55 +08:00
if ( log )
log - > Printf ( " Target::%s (watch_id = %i) \n " , __FUNCTION__ , watch_id ) ;
if ( ! ProcessIsValid ( ) )
return false ;
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp = m_watchpoint_list . FindByID ( watch_id ) ;
if ( wp_sp )
2011-09-21 07:28:55 +08:00
{
2011-10-14 08:42:25 +08:00
Error rc = m_process_sp - > DisableWatchpoint ( wp_sp . get ( ) ) ;
2011-09-23 02:04:58 +08:00
if ( rc . Success ( ) )
return true ;
2011-09-21 07:28:55 +08:00
2011-09-23 02:04:58 +08:00
// Else, fallthrough.
2011-09-21 07:28:55 +08:00
}
return false ;
}
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
2011-09-21 07:28:55 +08:00
bool
2011-10-14 08:42:25 +08:00
Target : : EnableWatchpointByID ( lldb : : watch_id_t watch_id )
2011-09-21 07:28:55 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-09-21 07:28:55 +08:00
if ( log )
log - > Printf ( " Target::%s (watch_id = %i) \n " , __FUNCTION__ , watch_id ) ;
if ( ! ProcessIsValid ( ) )
return false ;
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp = m_watchpoint_list . FindByID ( watch_id ) ;
if ( wp_sp )
2011-09-21 07:28:55 +08:00
{
2011-10-14 08:42:25 +08:00
Error rc = m_process_sp - > EnableWatchpoint ( wp_sp . get ( ) ) ;
2011-09-23 02:04:58 +08:00
if ( rc . Success ( ) )
return true ;
2011-09-21 07:28:55 +08:00
2011-09-23 02:04:58 +08:00
// Else, fallthrough.
2011-09-21 07:28:55 +08:00
}
return false ;
}
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
2011-09-21 07:28:55 +08:00
bool
2011-10-14 08:42:25 +08:00
Target : : RemoveWatchpointByID ( lldb : : watch_id_t watch_id )
2011-09-21 07:28:55 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-09-21 07:28:55 +08:00
if ( log )
log - > Printf ( " Target::%s (watch_id = %i) \n " , __FUNCTION__ , watch_id ) ;
2013-07-02 10:09:46 +08:00
WatchpointSP watch_to_remove_sp = m_watchpoint_list . FindByID ( watch_id ) ;
if ( watch_to_remove_sp = = m_last_created_watchpoint )
m_last_created_watchpoint . reset ( ) ;
2011-10-14 08:42:25 +08:00
if ( DisableWatchpointByID ( watch_id ) )
2011-09-21 07:28:55 +08:00
{
2012-12-18 10:03:49 +08:00
m_watchpoint_list . Remove ( watch_id , true ) ;
2011-09-21 07:28:55 +08:00
return true ;
}
return false ;
}
2011-10-14 08:42:25 +08:00
// Assumption: Caller holds the list mutex lock for m_watchpoint_list.
2011-10-06 05:35:46 +08:00
bool
2011-10-14 08:42:25 +08:00
Target : : IgnoreWatchpointByID ( lldb : : watch_id_t watch_id , uint32_t ignore_count )
2011-10-06 05:35:46 +08:00
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_WATCHPOINTS ) ) ;
2011-10-06 05:35:46 +08:00
if ( log )
log - > Printf ( " Target::%s (watch_id = %i) \n " , __FUNCTION__ , watch_id ) ;
if ( ! ProcessIsValid ( ) )
return false ;
2011-10-14 08:42:25 +08:00
WatchpointSP wp_sp = m_watchpoint_list . FindByID ( watch_id ) ;
if ( wp_sp )
2011-10-06 05:35:46 +08:00
{
2011-10-14 08:42:25 +08:00
wp_sp - > SetIgnoreCount ( ignore_count ) ;
2011-10-06 05:35:46 +08:00
return true ;
}
return false ;
}
2010-06-09 00:52:24 +08:00
ModuleSP
Target : : GetExecutableModule ( )
{
2015-05-08 17:36:31 +08:00
// search for the first executable in the module list
for ( size_t i = 0 ; i < m_images . GetSize ( ) ; + + i )
{
ModuleSP module_sp = m_images . GetModuleAtIndex ( i ) ;
lldb_private : : ObjectFile * obj = module_sp - > GetObjectFile ( ) ;
if ( obj = = nullptr )
continue ;
if ( obj - > GetType ( ) = = ObjectFile : : Type : : eTypeExecutable )
return module_sp ;
}
// as fall back return the first module loaded
return m_images . GetModuleAtIndex ( 0 ) ;
2011-08-11 10:48:45 +08:00
}
Module *
Target : : GetExecutableModulePointer ( )
{
2015-05-08 17:36:31 +08:00
return GetExecutableModule ( ) . get ( ) ;
2010-06-09 00:52:24 +08:00
}
2012-11-08 10:22:02 +08:00
static void
LoadScriptingResourceForModule ( const ModuleSP & module_sp , Target * target )
{
Error error ;
2013-05-21 08:00:30 +08:00
StreamString feedback_stream ;
if ( module_sp & & ! module_sp - > LoadScriptingResourceInTarget ( target , error , & feedback_stream ) )
2012-11-08 10:22:02 +08:00
{
2013-05-21 08:00:30 +08:00
if ( error . AsCString ( ) )
2014-01-28 07:43:24 +08:00
target - > GetDebugger ( ) . GetErrorFile ( ) - > Printf ( " unable to load scripting data for module %s - error reported was %s \n " ,
2013-05-21 08:00:30 +08:00
module_sp - > GetFileSpec ( ) . GetFileNameStrippingExtension ( ) . GetCString ( ) ,
error . AsCString ( ) ) ;
2012-11-08 10:22:02 +08:00
}
2014-08-16 08:32:58 +08:00
if ( feedback_stream . GetSize ( ) )
target - > GetDebugger ( ) . GetErrorFile ( ) - > Printf ( " %s \n " ,
feedback_stream . GetData ( ) ) ;
2012-11-08 10:22:02 +08:00
}
2010-06-09 00:52:24 +08:00
void
2013-11-09 08:03:31 +08:00
Target : : ClearModules ( bool delete_locations )
2010-06-09 00:52:24 +08:00
{
2013-11-09 08:03:31 +08:00
ModulesDidUnload ( m_images , delete_locations ) ;
2013-12-06 09:12:00 +08:00
m_section_load_history . Clear ( ) ;
2010-06-09 00:52:24 +08:00
m_images . Clear ( ) ;
2015-10-09 05:04:34 +08:00
m_scratch_type_system_map . Clear ( ) ;
2011-11-17 02:20:47 +08:00
m_ast_importer_ap . reset ( ) ;
2013-11-06 07:28:00 +08:00
}
2013-11-09 08:03:31 +08:00
void
Target : : DidExec ( )
{
// When a process exec's we need to know about it so we can do some cleanup.
m_breakpoint_list . RemoveInvalidLocations ( m_arch ) ;
m_internal_breakpoint_list . RemoveInvalidLocations ( m_arch ) ;
}
2013-11-06 07:28:00 +08:00
void
Target : : SetExecutableModule ( ModuleSP & executable_sp , bool get_dependent_files )
{
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_TARGET ) ) ;
2013-11-09 08:03:31 +08:00
ClearModules ( false ) ;
2010-06-09 00:52:24 +08:00
if ( executable_sp . get ( ) )
{
Timer scoped_timer ( __PRETTY_FUNCTION__ ,
2013-04-30 01:25:54 +08:00
" Target::SetExecutableModule (executable = '%s') " ,
executable_sp - > GetFileSpec ( ) . GetPath ( ) . c_str ( ) ) ;
2010-06-09 00:52:24 +08:00
2014-07-02 05:22:11 +08:00
m_images . Append ( executable_sp ) ; // The first image is our executable file
2010-06-09 00:52:24 +08:00
2010-08-10 07:31:02 +08:00
// If we haven't set an architecture yet, reset our architecture based on what we found in the executable module.
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
if ( ! m_arch . IsValid ( ) )
2012-12-05 08:25:49 +08:00
{
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
m_arch = executable_sp - > GetArchitecture ( ) ;
2012-12-05 08:25:49 +08:00
if ( log )
log - > Printf ( " Target::SetExecutableModule setting architecture to %s (%s) based on executable file " , m_arch . GetArchitectureName ( ) , m_arch . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
}
2010-06-09 00:52:24 +08:00
FileSpecList dependent_files ;
2011-03-09 06:40:15 +08:00
ObjectFile * executable_objfile = executable_sp - > GetObjectFile ( ) ;
2010-06-09 00:52:24 +08:00
2011-09-24 08:52:29 +08:00
if ( executable_objfile & & get_dependent_files )
2010-06-09 00:52:24 +08:00
{
executable_objfile - > GetDependentModules ( dependent_files ) ;
for ( uint32_t i = 0 ; i < dependent_files . GetSize ( ) ; i + + )
{
2011-03-19 09:12:21 +08:00
FileSpec dependent_file_spec ( dependent_files . GetFileSpecPointerAtIndex ( i ) ) ;
FileSpec platform_dependent_file_spec ;
if ( m_platform_sp )
2014-01-18 02:18:31 +08:00
m_platform_sp - > GetFileWithUUID ( dependent_file_spec , NULL , platform_dependent_file_spec ) ;
2011-03-19 09:12:21 +08:00
else
platform_dependent_file_spec = dependent_file_spec ;
2012-02-26 13:51:37 +08:00
ModuleSpec module_spec ( platform_dependent_file_spec , m_arch ) ;
ModuleSP image_module_sp ( GetSharedModule ( module_spec ) ) ;
2010-06-09 00:52:24 +08:00
if ( image_module_sp . get ( ) )
{
ObjectFile * objfile = image_module_sp - > GetObjectFile ( ) ;
if ( objfile )
objfile - > GetDependentModules ( dependent_files ) ;
}
}
}
}
}
2010-08-10 07:31:02 +08:00
bool
Target : : SetArchitecture ( const ArchSpec & arch_spec )
{
2013-03-28 07:08:40 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_TARGET ) ) ;
2012-12-14 06:07:14 +08:00
if ( m_arch . IsCompatibleMatch ( arch_spec ) | | ! m_arch . IsValid ( ) )
2010-06-09 00:52:24 +08:00
{
2012-05-08 09:45:38 +08:00
// If we haven't got a valid arch spec, or the architectures are
// compatible, so just update the architecture. Architectures can be
// equal, yet the triple OS and vendor might change, so we need to do
// the assignment here just in case.
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
m_arch = arch_spec ;
2012-12-05 08:25:49 +08:00
if ( log )
log - > Printf ( " Target::SetArchitecture setting architecture to %s (%s) " , arch_spec . GetArchitectureName ( ) , arch_spec . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
2010-08-10 07:31:02 +08:00
return true ;
}
else
{
// If we have an executable file, try to reset the executable to the desired architecture
2012-12-05 08:25:49 +08:00
if ( log )
2012-12-06 07:07:34 +08:00
log - > Printf ( " Target::SetArchitecture changing architecture to %s (%s) " , arch_spec . GetArchitectureName ( ) , arch_spec . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
m_arch = arch_spec ;
2010-08-10 07:31:02 +08:00
ModuleSP executable_sp = GetExecutableModule ( ) ;
2013-11-06 07:28:00 +08:00
2013-11-09 08:03:31 +08:00
ClearModules ( true ) ;
2010-08-10 07:31:02 +08:00
// Need to do something about unsetting breakpoints.
if ( executable_sp )
{
2012-12-05 08:25:49 +08:00
if ( log )
log - > Printf ( " Target::SetArchitecture Trying to select executable file architecture %s (%s) " , arch_spec . GetArchitectureName ( ) , arch_spec . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
2012-02-26 13:51:37 +08:00
ModuleSpec module_spec ( executable_sp - > GetFileSpec ( ) , arch_spec ) ;
Error error = ModuleList : : GetSharedModule ( module_spec ,
executable_sp ,
2012-08-23 02:39:03 +08:00
& GetExecutableSearchPaths ( ) ,
2012-02-26 13:51:37 +08:00
NULL ,
NULL ) ;
2010-08-10 07:31:02 +08:00
if ( ! error . Fail ( ) & & executable_sp )
{
SetExecutableModule ( executable_sp , true ) ;
return true ;
}
}
2010-06-09 00:52:24 +08:00
}
2012-05-08 09:45:38 +08:00
return false ;
2010-06-09 00:52:24 +08:00
}
2015-03-13 18:32:42 +08:00
bool
Target : : MergeArchitecture ( const ArchSpec & arch_spec )
{
if ( arch_spec . IsValid ( ) )
{
if ( m_arch . IsCompatibleMatch ( arch_spec ) )
{
// The current target arch is compatible with "arch_spec", see if we
// can improve our current architecture using bits from "arch_spec"
// Merge bits from arch_spec into "merged_arch" and set our architecture
ArchSpec merged_arch ( m_arch ) ;
merged_arch . MergeFrom ( arch_spec ) ;
return SetArchitecture ( merged_arch ) ;
}
else
{
// The new architecture is different, we just need to replace it
return SetArchitecture ( arch_spec ) ;
}
}
return false ;
}
2010-06-09 00:52:24 +08:00
void
2012-11-09 03:16:03 +08:00
Target : : WillClearList ( const ModuleList & module_list )
2012-11-08 10:22:02 +08:00
{
}
void
2012-11-09 03:16:03 +08:00
Target : : ModuleAdded ( const ModuleList & module_list , const ModuleSP & module_sp )
2010-06-09 00:52:24 +08:00
{
// A module is being added to this target for the first time
2014-03-25 07:10:19 +08:00
if ( m_valid )
{
ModuleList my_module_list ;
my_module_list . Append ( module_sp ) ;
LoadScriptingResourceForModule ( module_sp , this ) ;
ModulesDidLoad ( my_module_list ) ;
}
2010-06-09 00:52:24 +08:00
}
void
2012-11-09 03:16:03 +08:00
Target : : ModuleRemoved ( const ModuleList & module_list , const ModuleSP & module_sp )
2012-11-08 10:22:02 +08:00
{
2015-10-16 06:39:55 +08:00
// A module is being removed from this target.
2014-03-25 07:10:19 +08:00
if ( m_valid )
{
ModuleList my_module_list ;
my_module_list . Append ( module_sp ) ;
ModulesDidUnload ( my_module_list , false ) ;
}
2012-11-08 10:22:02 +08:00
}
void
2012-11-09 03:16:03 +08:00
Target : : ModuleUpdated ( const ModuleList & module_list , const ModuleSP & old_module_sp , const ModuleSP & new_module_sp )
2010-06-09 00:52:24 +08:00
{
2011-08-03 09:00:06 +08:00
// A module is replacing an already added module
2014-03-25 07:10:19 +08:00
if ( m_valid )
m_breakpoint_list . UpdateBreakpointsWhenModuleIsReplaced ( old_module_sp , new_module_sp ) ;
2010-06-09 00:52:24 +08:00
}
void
Target : : ModulesDidLoad ( ModuleList & module_list )
{
2014-03-25 07:10:19 +08:00
if ( m_valid & & module_list . GetSize ( ) )
2012-11-08 10:22:02 +08:00
{
2013-11-06 07:28:00 +08:00
m_breakpoint_list . UpdateBreakpoints ( module_list , true , false ) ;
2013-11-05 11:57:19 +08:00
if ( m_process_sp )
{
2014-03-13 17:37:02 +08:00
m_process_sp - > ModulesDidLoad ( module_list ) ;
2013-11-05 11:57:19 +08:00
}
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-11 05:59:55 +08:00
BroadcastEvent ( eBroadcastBitModulesLoaded , new TargetEventData ( this - > shared_from_this ( ) , module_list ) ) ;
2012-11-08 10:22:02 +08:00
}
2010-06-09 00:52:24 +08:00
}
2013-04-06 02:49:06 +08:00
void
Target : : SymbolsDidLoad ( ModuleList & module_list )
{
2014-03-25 07:10:19 +08:00
if ( m_valid & & module_list . GetSize ( ) )
2013-04-06 02:49:06 +08:00
{
2013-06-05 07:01:35 +08:00
if ( m_process_sp )
2013-04-06 02:49:06 +08:00
{
2013-06-05 07:01:35 +08:00
LanguageRuntime * runtime = m_process_sp - > GetLanguageRuntime ( lldb : : eLanguageTypeObjC ) ;
if ( runtime )
{
ObjCLanguageRuntime * objc_runtime = ( ObjCLanguageRuntime * ) runtime ;
objc_runtime - > SymbolsDidLoad ( module_list ) ;
}
2013-04-06 02:49:06 +08:00
}
2013-06-05 07:01:35 +08:00
2013-11-06 07:28:00 +08:00
m_breakpoint_list . UpdateBreakpoints ( module_list , true , false ) ;
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-11 05:59:55 +08:00
BroadcastEvent ( eBroadcastBitSymbolsLoaded , new TargetEventData ( this - > shared_from_this ( ) , module_list ) ) ;
2013-04-06 02:49:06 +08:00
}
}
2010-06-09 00:52:24 +08:00
void
2013-11-06 07:28:00 +08:00
Target : : ModulesDidUnload ( ModuleList & module_list , bool delete_locations )
2010-06-09 00:52:24 +08:00
{
2014-03-25 07:10:19 +08:00
if ( m_valid & & module_list . GetSize ( ) )
2012-11-08 10:22:02 +08:00
{
2014-11-18 03:39:20 +08:00
UnloadModuleSections ( module_list ) ;
2013-11-06 07:28:00 +08:00
m_breakpoint_list . UpdateBreakpoints ( module_list , false , delete_locations ) ;
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-11 05:59:55 +08:00
BroadcastEvent ( eBroadcastBitModulesUnloaded , new TargetEventData ( this - > shared_from_this ( ) , module_list ) ) ;
2012-11-08 10:22:02 +08:00
}
2010-06-09 00:52:24 +08:00
}
2011-11-01 06:50:37 +08:00
bool
2014-12-06 09:28:03 +08:00
Target : : ModuleIsExcludedForUnconstrainedSearches ( const FileSpec & module_file_spec )
2011-10-29 07:14:11 +08:00
{
2012-08-23 01:17:09 +08:00
if ( GetBreakpointsConsultPlatformAvoidList ( ) )
2011-10-29 07:14:11 +08:00
{
ModuleList matchingModules ;
2012-02-26 13:51:37 +08:00
ModuleSpec module_spec ( module_file_spec ) ;
size_t num_modules = GetImages ( ) . FindModules ( module_spec , matchingModules ) ;
2011-10-29 07:14:11 +08:00
// If there is more than one module for this file spec, only return true if ALL the modules are on the
// black list.
if ( num_modules > 0 )
{
2013-06-20 03:04:53 +08:00
for ( size_t i = 0 ; i < num_modules ; i + + )
2011-10-29 07:14:11 +08:00
{
2014-12-06 09:28:03 +08:00
if ( ! ModuleIsExcludedForUnconstrainedSearches ( matchingModules . GetModuleAtIndex ( i ) ) )
2011-10-29 07:14:11 +08:00
return false ;
}
return true ;
}
}
2012-08-23 01:17:09 +08:00
return false ;
2011-10-29 07:14:11 +08:00
}
2011-11-01 06:50:37 +08:00
bool
2014-12-06 09:28:03 +08:00
Target : : ModuleIsExcludedForUnconstrainedSearches ( const lldb : : ModuleSP & module_sp )
2011-10-29 07:14:11 +08:00
{
2012-08-23 01:17:09 +08:00
if ( GetBreakpointsConsultPlatformAvoidList ( ) )
2011-10-29 07:14:11 +08:00
{
2012-08-23 01:17:09 +08:00
if ( m_platform_sp )
2014-12-06 09:28:03 +08:00
return m_platform_sp - > ModuleIsExcludedForUnconstrainedSearches ( * this , module_sp ) ;
2011-10-29 07:14:11 +08:00
}
2012-08-23 01:17:09 +08:00
return false ;
2011-10-29 07:14:11 +08:00
}
2010-06-09 00:52:24 +08:00
size_t
2011-01-07 09:57:07 +08:00
Target : : ReadMemoryFromFileCache ( const Address & addr , void * dst , size_t dst_len , Error & error )
2010-06-09 00:52:24 +08:00
{
2012-02-24 09:59:29 +08:00
SectionSP section_sp ( addr . GetSection ( ) ) ;
if ( section_sp )
2011-01-07 09:57:07 +08:00
{
2014-07-02 05:22:11 +08:00
// If the contents of this section are encrypted, the on-disk file is unusable. Read only from live memory.
2012-04-25 08:06:56 +08:00
if ( section_sp - > IsEncrypted ( ) )
{
2012-05-26 01:05:55 +08:00
error . SetErrorString ( " section is encrypted " ) ;
2012-04-25 08:06:56 +08:00
return 0 ;
}
2012-02-24 09:59:29 +08:00
ModuleSP module_sp ( section_sp - > GetModule ( ) ) ;
if ( module_sp )
2011-01-07 09:57:07 +08:00
{
2012-02-24 09:59:29 +08:00
ObjectFile * objfile = section_sp - > GetModule ( ) - > GetObjectFile ( ) ;
if ( objfile )
{
size_t bytes_read = objfile - > ReadSectionData ( section_sp . get ( ) ,
addr . GetOffset ( ) ,
dst ,
dst_len ) ;
if ( bytes_read > 0 )
return bytes_read ;
else
error . SetErrorStringWithFormat ( " error reading data from section %s " , section_sp - > GetName ( ) . GetCString ( ) ) ;
}
2011-01-07 09:57:07 +08:00
else
2012-02-24 09:59:29 +08:00
error . SetErrorString ( " address isn't from a object file " ) ;
2011-01-07 09:57:07 +08:00
}
else
2012-02-24 09:59:29 +08:00
error . SetErrorString ( " address isn't in a module " ) ;
2011-01-07 09:57:07 +08:00
}
else
error . SetErrorString ( " address doesn't contain a section that points to a section in a object file " ) ;
2012-02-24 09:59:29 +08:00
2011-01-07 09:57:07 +08:00
return 0 ;
}
2010-07-01 07:03:03 +08:00
2011-01-07 09:57:07 +08:00
size_t
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
Target : : ReadMemory ( const Address & addr ,
bool prefer_file_cache ,
void * dst ,
size_t dst_len ,
Error & error ,
lldb : : addr_t * load_addr_ptr )
2011-01-07 09:57:07 +08:00
{
error . Clear ( ) ;
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
// if we end up reading this from process memory, we will fill this
// with the actual load address
if ( load_addr_ptr )
* load_addr_ptr = LLDB_INVALID_ADDRESS ;
2011-01-07 09:57:07 +08:00
size_t bytes_read = 0 ;
2011-07-11 13:12:02 +08:00
addr_t load_addr = LLDB_INVALID_ADDRESS ;
addr_t file_addr = LLDB_INVALID_ADDRESS ;
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
Address resolved_addr ;
if ( ! addr . IsSectionOffset ( ) )
2010-06-09 00:52:24 +08:00
{
2013-12-06 09:12:00 +08:00
SectionLoadList & section_load_list = GetSectionLoadList ( ) ;
if ( section_load_list . IsEmpty ( ) )
2011-07-11 13:12:02 +08:00
{
2011-07-13 01:06:17 +08:00
// No sections are loaded, so we must assume we are not running
// yet and anything we are given is a file address.
file_addr = addr . GetOffset ( ) ; // "addr" doesn't have a section, so its offset is the file address
m_images . ResolveFileAddress ( file_addr , resolved_addr ) ;
2011-07-11 13:12:02 +08:00
}
2010-07-01 07:03:03 +08:00
else
2011-07-11 13:12:02 +08:00
{
2014-07-02 05:22:11 +08:00
// We have at least one section loaded. This can be because
2011-07-13 01:06:17 +08:00
// we have manually loaded some sections with "target modules load ..."
// or because we have have a live process that has sections loaded
// through the dynamic loader
load_addr = addr . GetOffset ( ) ; // "addr" doesn't have a section, so its offset is the load address
2013-12-06 09:12:00 +08:00
section_load_list . ResolveLoadAddress ( load_addr , resolved_addr ) ;
2011-07-11 13:12:02 +08:00
}
2010-07-01 07:03:03 +08:00
}
Added the ability to get the min and max instruction byte size for
an architecture into ArchSpec:
uint32_t
ArchSpec::GetMinimumOpcodeByteSize() const;
uint32_t
ArchSpec::GetMaximumOpcodeByteSize() const;
Added an AddressClass to the Instruction class in Disassembler.h.
This allows decoded instructions to know know if they are code,
code with alternate ISA (thumb), or even data which can be mixed
into code. The instruction does have an address, but it is a good
idea to cache this value so we don't have to look it up more than
once.
Fixed an issue in Opcode::SetOpcodeBytes() where the length wasn't
getting set.
Changed:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc);
To:
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc,
bool merge_symbol_into_function);
This function was typically being used when looking up functions
and symbols. Now if you lookup a function, then find the symbol,
they can be merged into the same symbol context and not cause
multiple symbol contexts to appear in a symbol context list that
describes the same function.
Fixed the SymbolContext not equal operator which was causing mixed
mode disassembly to not work ("disassembler --mixed --name main").
Modified the disassembler classes to know about the fact we know,
for a given architecture, what the min and max opcode byte sizes
are. The InstructionList class was modified to return the max
opcode byte size for all of the instructions in its list.
These two fixes means when disassemble a list of instructions and dump
them and show the opcode bytes, we can format the output more
intelligently when showing opcode bytes. This affects any architectures
that have varying opcode byte sizes (x86_64 and i386). Knowing the max
opcode byte size also helps us to be able to disassemble N instructions
without having to re-read data if we didn't read enough bytes.
Added the ability to set the architecture for the disassemble command.
This means you can easily cross disassemble data for any supported
architecture. I also added the ability to specify "thumb" as an
architecture so that we can force disassembly into thumb mode when
needed. In GDB this was done using a hack of specifying an odd
address when disassembling. I don't want to repeat this hack in LLDB,
so the auto detection between ARM and thumb is failing, just specify
thumb when disassembling:
(lldb) disassemble --arch thumb --name main
You can also have data in say an x86_64 file executable and disassemble
data as any other supported architecture:
% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) b main
(lldb) run
(lldb) disassemble --arch thumb --count 2 --start-address 0x0000000100001080 --bytes
0x100001080: 0xb580 push {r7, lr}
0x100001082: 0xaf00 add r7, sp, #0
Fixed Target::ReadMemory(...) to be able to deal with Address argument object
that isn't section offset. When an address object was supplied that was
out on the heap or stack, target read memory would fail. Disassembly uses
Target::ReadMemory(...), and the example above where we disassembler thumb
opcodes in an x86 binary was failing do to this bug.
llvm-svn: 128347
2011-03-27 03:14:58 +08:00
if ( ! resolved_addr . IsValid ( ) )
resolved_addr = addr ;
2010-07-01 07:03:03 +08:00
2011-07-11 13:12:02 +08:00
2011-01-07 09:57:07 +08:00
if ( prefer_file_cache )
{
bytes_read = ReadMemoryFromFileCache ( resolved_addr , dst , dst_len , error ) ;
if ( bytes_read > 0 )
return bytes_read ;
}
2010-07-01 07:03:03 +08:00
2011-09-21 07:28:55 +08:00
if ( ProcessIsValid ( ) )
2010-07-01 07:03:03 +08:00
{
2011-07-11 13:12:02 +08:00
if ( load_addr = = LLDB_INVALID_ADDRESS )
load_addr = resolved_addr . GetLoadAddress ( this ) ;
2010-07-01 07:03:03 +08:00
if ( load_addr = = LLDB_INVALID_ADDRESS )
{
2012-02-24 09:59:29 +08:00
ModuleSP addr_module_sp ( resolved_addr . GetModule ( ) ) ;
if ( addr_module_sp & & addr_module_sp - > GetFileSpec ( ) )
2012-11-30 05:49:15 +08:00
error . SetErrorStringWithFormat ( " %s[0x% " PRIx64 " ] can't be resolved, %s in not currently loaded " ,
2014-12-20 03:20:44 +08:00
addr_module_sp - > GetFileSpec ( ) . GetFilename ( ) . AsCString ( " <Unknown> " ) ,
2011-09-20 08:26:08 +08:00
resolved_addr . GetFileAddress ( ) ,
2014-12-20 03:20:44 +08:00
addr_module_sp - > GetFileSpec ( ) . GetFilename ( ) . AsCString ( " <Unknonw> " ) ) ;
2010-06-09 00:52:24 +08:00
else
2012-11-30 05:49:15 +08:00
error . SetErrorStringWithFormat ( " 0x% " PRIx64 " can't be resolved " , resolved_addr . GetFileAddress ( ) ) ;
2010-06-09 00:52:24 +08:00
}
2010-07-01 07:03:03 +08:00
else
2010-06-09 00:52:24 +08:00
{
2011-01-07 09:57:07 +08:00
bytes_read = m_process_sp - > ReadMemory ( load_addr , dst , dst_len , error ) ;
2010-06-09 00:52:24 +08:00
if ( bytes_read ! = dst_len )
{
if ( error . Success ( ) )
{
if ( bytes_read = = 0 )
2012-11-30 05:49:15 +08:00
error . SetErrorStringWithFormat ( " read memory from 0x% " PRIx64 " failed " , load_addr ) ;
2010-06-09 00:52:24 +08:00
else
2012-11-30 05:49:15 +08:00
error . SetErrorStringWithFormat ( " only % " PRIu64 " of % " PRIu64 " bytes were read from memory at 0x% " PRIx64 , ( uint64_t ) bytes_read , ( uint64_t ) dst_len , load_addr ) ;
2010-06-09 00:52:24 +08:00
}
}
2010-07-01 07:03:03 +08:00
if ( bytes_read )
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
{
if ( load_addr_ptr )
* load_addr_ptr = load_addr ;
2010-07-01 07:03:03 +08:00
return bytes_read ;
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
}
2010-07-01 07:03:03 +08:00
// If the address is not section offset we have an address that
// doesn't resolve to any address in any currently loaded shared
2014-07-02 05:22:11 +08:00
// libraries and we failed to read memory so there isn't anything
2010-07-01 07:03:03 +08:00
// more we can do. If it is section offset, we might be able to
// read cached memory from the object file.
if ( ! resolved_addr . IsSectionOffset ( ) )
return 0 ;
2010-06-09 00:52:24 +08:00
}
}
2010-07-01 07:03:03 +08:00
2011-07-11 13:12:02 +08:00
if ( ! prefer_file_cache & & resolved_addr . IsSectionOffset ( ) )
2010-07-01 07:03:03 +08:00
{
2011-01-07 09:57:07 +08:00
// If we didn't already try and read from the object file cache, then
// try it after failing to read from the process.
return ReadMemoryFromFileCache ( resolved_addr , dst , dst_len , error ) ;
2010-07-01 07:03:03 +08:00
}
return 0 ;
2010-06-09 00:52:24 +08:00
}
2013-01-22 03:20:50 +08:00
size_t
Target : : ReadCStringFromMemory ( const Address & addr , std : : string & out_str , Error & error )
{
char buf [ 256 ] ;
out_str . clear ( ) ;
addr_t curr_addr = addr . GetLoadAddress ( this ) ;
Address address ( addr ) ;
while ( 1 )
{
size_t length = ReadCStringFromMemory ( address , buf , sizeof ( buf ) , error ) ;
if ( length = = 0 )
break ;
out_str . append ( buf , length ) ;
// If we got "length - 1" bytes, we didn't get the whole C string, we
// need to read some more characters
if ( length = = sizeof ( buf ) - 1 )
curr_addr + = length ;
else
break ;
address = Address ( curr_addr ) ;
}
return out_str . size ( ) ;
}
size_t
Target : : ReadCStringFromMemory ( const Address & addr , char * dst , size_t dst_max_len , Error & result_error )
{
size_t total_cstr_len = 0 ;
if ( dst & & dst_max_len )
{
result_error . Clear ( ) ;
// NULL out everything just to be safe
memset ( dst , 0 , dst_max_len ) ;
Error error ;
addr_t curr_addr = addr . GetLoadAddress ( this ) ;
Address address ( addr ) ;
2014-09-04 06:30:54 +08:00
// We could call m_process_sp->GetMemoryCacheLineSize() but I don't
// think this really needs to be tied to the memory cache subsystem's
// cache line size, so leave this as a fixed constant.
2013-01-22 03:20:50 +08:00
const size_t cache_line_size = 512 ;
2014-09-04 06:30:54 +08:00
2013-01-22 03:20:50 +08:00
size_t bytes_left = dst_max_len - 1 ;
char * curr_dst = dst ;
while ( bytes_left > 0 )
{
addr_t cache_line_bytes_left = cache_line_size - ( curr_addr % cache_line_size ) ;
addr_t bytes_to_read = std : : min < addr_t > ( bytes_left , cache_line_bytes_left ) ;
size_t bytes_read = ReadMemory ( address , false , curr_dst , bytes_to_read , error ) ;
if ( bytes_read = = 0 )
{
result_error = error ;
dst [ total_cstr_len ] = ' \0 ' ;
break ;
}
const size_t len = strlen ( curr_dst ) ;
total_cstr_len + = len ;
if ( len < bytes_to_read )
break ;
curr_dst + = bytes_read ;
curr_addr + = bytes_read ;
bytes_left - = bytes_read ;
address = Address ( curr_addr ) ;
}
}
else
{
if ( dst = = NULL )
result_error . SetErrorString ( " invalid arguments " ) ;
else
result_error . Clear ( ) ;
}
return total_cstr_len ;
}
2011-07-13 01:06:17 +08:00
size_t
Target : : ReadScalarIntegerFromMemory ( const Address & addr ,
bool prefer_file_cache ,
uint32_t byte_size ,
bool is_signed ,
Scalar & scalar ,
Error & error )
{
uint64_t uval ;
if ( byte_size < = sizeof ( uval ) )
{
size_t bytes_read = ReadMemory ( addr , prefer_file_cache , & uval , byte_size , error ) ;
if ( bytes_read = = byte_size )
{
DataExtractor data ( & uval , sizeof ( uval ) , m_arch . GetByteOrder ( ) , m_arch . GetAddressByteSize ( ) ) ;
2013-01-26 02:06:21 +08:00
lldb : : offset_t offset = 0 ;
2011-07-13 01:06:17 +08:00
if ( byte_size < = 4 )
scalar = data . GetMaxU32 ( & offset , byte_size ) ;
else
scalar = data . GetMaxU64 ( & offset , byte_size ) ;
if ( is_signed )
scalar . SignExtend ( byte_size * 8 ) ;
return bytes_read ;
}
}
else
{
error . SetErrorStringWithFormat ( " byte size of %u is too large for integer scalar type " , byte_size ) ;
}
return 0 ;
}
uint64_t
Target : : ReadUnsignedIntegerFromMemory ( const Address & addr ,
bool prefer_file_cache ,
size_t integer_byte_size ,
uint64_t fail_value ,
Error & error )
{
Scalar scalar ;
if ( ReadScalarIntegerFromMemory ( addr ,
prefer_file_cache ,
integer_byte_size ,
false ,
scalar ,
error ) )
return scalar . ULongLong ( fail_value ) ;
return fail_value ;
}
bool
Target : : ReadPointerFromMemory ( const Address & addr ,
bool prefer_file_cache ,
Error & error ,
Address & pointer_addr )
{
Scalar scalar ;
if ( ReadScalarIntegerFromMemory ( addr ,
prefer_file_cache ,
m_arch . GetAddressByteSize ( ) ,
false ,
scalar ,
error ) )
{
addr_t pointer_vm_addr = scalar . ULongLong ( LLDB_INVALID_ADDRESS ) ;
if ( pointer_vm_addr ! = LLDB_INVALID_ADDRESS )
{
2013-12-06 09:12:00 +08:00
SectionLoadList & section_load_list = GetSectionLoadList ( ) ;
if ( section_load_list . IsEmpty ( ) )
2011-07-13 01:06:17 +08:00
{
// No sections are loaded, so we must assume we are not running
// yet and anything we are given is a file address.
m_images . ResolveFileAddress ( pointer_vm_addr , pointer_addr ) ;
}
else
{
2014-07-02 05:22:11 +08:00
// We have at least one section loaded. This can be because
2011-07-13 01:06:17 +08:00
// we have manually loaded some sections with "target modules load ..."
// or because we have have a live process that has sections loaded
// through the dynamic loader
2013-12-06 09:12:00 +08:00
section_load_list . ResolveLoadAddress ( pointer_vm_addr , pointer_addr ) ;
2011-07-13 01:06:17 +08:00
}
// We weren't able to resolve the pointer value, so just return
// an address with no section
if ( ! pointer_addr . IsValid ( ) )
pointer_addr . SetOffset ( pointer_vm_addr ) ;
return true ;
}
}
return false ;
}
2010-06-09 00:52:24 +08:00
ModuleSP
2012-02-26 13:51:37 +08:00
Target : : GetSharedModule ( const ModuleSpec & module_spec , Error * error_ptr )
2010-06-09 00:52:24 +08:00
{
ModuleSP module_sp ;
Error error ;
2012-05-18 02:38:42 +08:00
// First see if we already have this module in our module list. If we do, then we're done, we don't need
// to consult the shared modules list. But only do this if we are passed a UUID.
2012-04-27 08:58:27 +08:00
2012-05-18 02:38:42 +08:00
if ( module_spec . GetUUID ( ) . IsValid ( ) )
module_sp = m_images . FindFirstModule ( module_spec ) ;
2012-04-27 08:58:27 +08:00
if ( ! module_sp )
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
{
2012-05-18 02:38:42 +08:00
ModuleSP old_module_sp ; // This will get filled in if we have a new version of the library
bool did_create_module = false ;
// If there are image search path entries, try to use them first to acquire a suitable image.
if ( m_image_search_paths . GetSize ( ) )
2012-04-27 08:58:27 +08:00
{
2012-05-18 02:38:42 +08:00
ModuleSpec transformed_spec ( module_spec ) ;
if ( m_image_search_paths . RemapPath ( module_spec . GetFileSpec ( ) . GetDirectory ( ) , transformed_spec . GetFileSpec ( ) . GetDirectory ( ) ) )
{
transformed_spec . GetFileSpec ( ) . GetFilename ( ) = module_spec . GetFileSpec ( ) . GetFilename ( ) ;
error = ModuleList : : GetSharedModule ( transformed_spec ,
module_sp ,
2012-08-23 02:39:03 +08:00
& GetExecutableSearchPaths ( ) ,
2012-05-18 02:38:42 +08:00
& old_module_sp ,
& did_create_module ) ;
}
2012-04-27 08:58:27 +08:00
}
2012-05-18 02:38:42 +08:00
2012-04-27 08:58:27 +08:00
if ( ! module_sp )
{
2012-05-18 02:38:42 +08:00
// If we have a UUID, we can check our global shared module list in case
// we already have it. If we don't have a valid UUID, then we can't since
// the path in "module_spec" will be a platform path, and we will need to
// let the platform find that file. For example, we could be asking for
// "/usr/lib/dyld" and if we do not have a UUID, we don't want to pick
// the local copy of "/usr/lib/dyld" since our platform could be a remote
// platform that has its own "/usr/lib/dyld" in an SDK or in a local file
// cache.
if ( module_spec . GetUUID ( ) . IsValid ( ) )
2012-04-27 08:58:27 +08:00
{
2012-05-18 02:38:42 +08:00
// We have a UUID, it is OK to check the global module list...
error = ModuleList : : GetSharedModule ( module_spec ,
module_sp ,
2012-08-23 02:39:03 +08:00
& GetExecutableSearchPaths ( ) ,
2012-08-23 01:17:09 +08:00
& old_module_sp ,
2012-05-18 02:38:42 +08:00
& did_create_module ) ;
2012-04-27 08:58:27 +08:00
}
2012-05-18 02:38:42 +08:00
if ( ! module_sp )
2012-04-27 08:58:27 +08:00
{
2012-05-18 02:38:42 +08:00
// The platform is responsible for finding and caching an appropriate
// module in the shared module cache.
if ( m_platform_sp )
{
2015-03-24 19:15:23 +08:00
error = m_platform_sp - > GetSharedModule ( module_spec ,
m_process_sp . get ( ) ,
module_sp ,
2012-08-23 02:39:03 +08:00
& GetExecutableSearchPaths ( ) ,
2012-08-23 01:17:09 +08:00
& old_module_sp ,
2012-05-18 02:38:42 +08:00
& did_create_module ) ;
}
else
{
error . SetErrorString ( " no platform is currently set " ) ;
}
2012-04-27 08:58:27 +08:00
}
}
2010-06-09 00:52:24 +08:00
2012-05-18 02:38:42 +08:00
// We found a module that wasn't in our target list. Let's make sure that there wasn't an equivalent
// module in the list already, and if there was, let's remove it.
if ( module_sp )
2010-06-09 00:52:24 +08:00
{
2012-11-30 06:16:27 +08:00
ObjectFile * objfile = module_sp - > GetObjectFile ( ) ;
if ( objfile )
2012-05-18 02:38:42 +08:00
{
2012-11-30 06:16:27 +08:00
switch ( objfile - > GetType ( ) )
{
case ObjectFile : : eTypeCoreFile : /// A core file that has a checkpoint of a program's execution state
case ObjectFile : : eTypeExecutable : /// A normal executable
case ObjectFile : : eTypeDynamicLinker : /// The platform's dynamic linker executable
case ObjectFile : : eTypeObjectFile : /// An intermediate object file
case ObjectFile : : eTypeSharedLibrary : /// A shared library that can be used during execution
break ;
case ObjectFile : : eTypeDebugInfo : /// An object file that contains only debug information
if ( error_ptr )
error_ptr - > SetErrorString ( " debug info files aren't valid target modules, please specify an executable " ) ;
return ModuleSP ( ) ;
case ObjectFile : : eTypeStubLibrary : /// A library that can be linked against but not used for execution
if ( error_ptr )
error_ptr - > SetErrorString ( " stub libraries aren't valid target modules, please specify an executable " ) ;
return ModuleSP ( ) ;
default :
if ( error_ptr )
error_ptr - > SetErrorString ( " unsupported file type, please specify an executable " ) ;
return ModuleSP ( ) ;
}
// GetSharedModule is not guaranteed to find the old shared module, for instance
// in the common case where you pass in the UUID, it is only going to find the one
// module matching the UUID. In fact, it has no good way to know what the "old module"
// relevant to this target is, since there might be many copies of a module with this file spec
// in various running debug sessions, but only one of them will belong to this target.
// So let's remove the UUID from the module list, and look in the target's module list.
// Only do this if there is SOMETHING else in the module spec...
if ( ! old_module_sp )
2012-05-18 02:38:42 +08:00
{
2012-11-30 06:16:27 +08:00
if ( module_spec . GetUUID ( ) . IsValid ( ) & & ! module_spec . GetFileSpec ( ) . GetFilename ( ) . IsEmpty ( ) & & ! module_spec . GetFileSpec ( ) . GetDirectory ( ) . IsEmpty ( ) )
2012-05-18 02:38:42 +08:00
{
2012-11-30 06:16:27 +08:00
ModuleSpec module_spec_copy ( module_spec . GetFileSpec ( ) ) ;
module_spec_copy . GetUUID ( ) . Clear ( ) ;
ModuleList found_modules ;
size_t num_found = m_images . FindModules ( module_spec_copy , found_modules ) ;
if ( num_found = = 1 )
{
old_module_sp = found_modules . GetModuleAtIndex ( 0 ) ;
}
2012-05-18 02:38:42 +08:00
}
}
2012-11-30 06:16:27 +08:00
if ( old_module_sp & & m_images . GetIndexForModule ( old_module_sp . get ( ) ) ! = LLDB_INVALID_INDEX32 )
{
m_images . ReplaceModule ( old_module_sp , module_sp ) ;
Module * old_module_ptr = old_module_sp . get ( ) ;
old_module_sp . reset ( ) ;
ModuleList : : RemoveSharedModuleIfOrphaned ( old_module_ptr ) ;
}
else
m_images . Append ( module_sp ) ;
2012-05-18 02:38:42 +08:00
}
2014-04-08 07:50:17 +08:00
else
module_sp . reset ( ) ;
2010-06-09 00:52:24 +08:00
}
}
if ( error_ptr )
* error_ptr = error ;
return module_sp ;
}
2012-02-18 13:35:26 +08:00
TargetSP
2010-06-09 00:52:24 +08:00
Target : : CalculateTarget ( )
{
2012-02-18 13:35:26 +08:00
return shared_from_this ( ) ;
2010-06-09 00:52:24 +08:00
}
2012-02-18 13:35:26 +08:00
ProcessSP
2010-06-09 00:52:24 +08:00
Target : : CalculateProcess ( )
{
2012-02-18 13:35:26 +08:00
return ProcessSP ( ) ;
2010-06-09 00:52:24 +08:00
}
2012-02-18 13:35:26 +08:00
ThreadSP
2010-06-09 00:52:24 +08:00
Target : : CalculateThread ( )
{
2012-02-18 13:35:26 +08:00
return ThreadSP ( ) ;
2010-06-09 00:52:24 +08:00
}
2013-11-04 17:33:30 +08:00
StackFrameSP
Target : : CalculateStackFrame ( )
2010-06-09 00:52:24 +08:00
{
2013-11-04 17:33:30 +08:00
return StackFrameSP ( ) ;
2010-06-09 00:52:24 +08:00
}
void
2010-10-04 09:05:56 +08:00
Target : : CalculateExecutionContext ( ExecutionContext & exe_ctx )
2010-06-09 00:52:24 +08:00
{
2011-09-22 12:58:26 +08:00
exe_ctx . Clear ( ) ;
exe_ctx . SetTargetPtr ( this ) ;
2010-06-09 00:52:24 +08:00
}
PathMappingList &
Target : : GetImageSearchPathList ( )
{
return m_image_search_paths ;
}
void
Target : : ImageSearchPathsChanged
(
const PathMappingList & path_list ,
void * baton
)
{
Target * target = ( Target * ) baton ;
2011-08-11 10:48:45 +08:00
ModuleSP exe_module_sp ( target - > GetExecutableModule ( ) ) ;
if ( exe_module_sp )
target - > SetExecutableModule ( exe_module_sp , true ) ;
2010-06-09 00:52:24 +08:00
}
2015-09-16 05:13:50 +08:00
TypeSystem *
2015-10-03 02:40:30 +08:00
Target : : GetScratchTypeSystemForLanguage ( Error * error , lldb : : LanguageType language , bool create_on_demand )
2015-09-16 05:13:50 +08:00
{
2015-10-09 05:04:34 +08:00
if ( ! m_valid )
return nullptr ;
2015-10-03 02:40:30 +08:00
if ( error )
{
error - > Clear ( ) ;
}
2015-10-02 00:28:02 +08:00
if ( language = = eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all assembly code
2015-10-03 02:40:30 +08:00
| | language = = eLanguageTypeUnknown )
{
2015-10-10 02:01:10 +08:00
std : : set < lldb : : LanguageType > languages_for_types ;
std : : set < lldb : : LanguageType > languages_for_expressions ;
Language : : GetLanguagesSupportingTypeSystems ( languages_for_types , languages_for_expressions ) ;
if ( languages_for_expressions . count ( eLanguageTypeC ) )
{
language = eLanguageTypeC ; // LLDB's default. Override by setting the target language.
}
else
{
if ( languages_for_expressions . empty ( ) )
{
return nullptr ;
}
else
{
language = * languages_for_expressions . begin ( ) ;
}
}
2015-10-02 00:28:02 +08:00
}
2015-10-09 05:04:34 +08:00
return m_scratch_type_system_map . GetTypeSystemForLanguage ( language , this , create_on_demand ) ;
2015-10-02 00:28:02 +08:00
}
PersistentExpressionState *
Target : : GetPersistentExpressionStateForLanguage ( lldb : : LanguageType language )
{
2015-10-03 02:40:30 +08:00
TypeSystem * type_system = GetScratchTypeSystemForLanguage ( nullptr , language , true ) ;
2015-10-02 00:28:02 +08:00
if ( type_system )
{
return type_system - > GetPersistentExpressionState ( ) ;
}
2015-09-16 05:13:50 +08:00
else
2015-10-02 00:28:02 +08:00
{
return nullptr ;
}
2015-09-16 05:13:50 +08:00
}
UserExpression *
Target : : GetUserExpressionForLanguage ( const char * expr ,
2015-10-03 02:40:30 +08:00
const char * expr_prefix ,
lldb : : LanguageType language ,
Expression : : ResultType desired_type ,
Error & error )
2015-09-16 05:13:50 +08:00
{
2015-10-03 02:40:30 +08:00
Error type_system_error ;
TypeSystem * type_system = GetScratchTypeSystemForLanguage ( & type_system_error , language ) ;
2015-09-16 05:13:50 +08:00
UserExpression * user_expr = nullptr ;
if ( ! type_system )
{
2015-10-03 02:40:30 +08:00
error . SetErrorStringWithFormat ( " Could not find type system for language %s: %s " , Language : : GetNameForLanguageType ( language ) , type_system_error . AsCString ( ) ) ;
2015-09-16 05:13:50 +08:00
return nullptr ;
}
user_expr = type_system - > GetUserExpression ( expr , expr_prefix , language , desired_type ) ;
if ( ! user_expr )
error . SetErrorStringWithFormat ( " Could not create an expression for language %s " , Language : : GetNameForLanguageType ( language ) ) ;
return user_expr ;
}
FunctionCaller *
Target : : GetFunctionCallerForLanguage ( lldb : : LanguageType language ,
const CompilerType & return_type ,
const Address & function_address ,
const ValueList & arg_value_list ,
const char * name ,
Error & error )
{
2015-10-03 02:40:30 +08:00
Error type_system_error ;
TypeSystem * type_system = GetScratchTypeSystemForLanguage ( & type_system_error , language ) ;
2015-09-16 05:13:50 +08:00
FunctionCaller * persistent_fn = nullptr ;
if ( ! type_system )
{
2015-10-03 02:40:30 +08:00
error . SetErrorStringWithFormat ( " Could not find type system for language %s: %s " , Language : : GetNameForLanguageType ( language ) , type_system_error . AsCString ( ) ) ;
2015-09-16 05:13:50 +08:00
return persistent_fn ;
}
persistent_fn = type_system - > GetFunctionCaller ( return_type , function_address , arg_value_list , name ) ;
if ( ! persistent_fn )
error . SetErrorStringWithFormat ( " Could not create an expression for language %s " , Language : : GetNameForLanguageType ( language ) ) ;
return persistent_fn ;
}
UtilityFunction *
Target : : GetUtilityFunctionForLanguage ( const char * text ,
lldb : : LanguageType language ,
const char * name ,
Error & error )
{
2015-10-03 02:40:30 +08:00
Error type_system_error ;
TypeSystem * type_system = GetScratchTypeSystemForLanguage ( & type_system_error , language ) ;
2015-09-16 05:13:50 +08:00
UtilityFunction * utility_fn = nullptr ;
if ( ! type_system )
{
2015-10-03 02:40:30 +08:00
error . SetErrorStringWithFormat ( " Could not find type system for language %s: %s " , Language : : GetNameForLanguageType ( language ) , type_system_error . AsCString ( ) ) ;
2015-09-16 05:13:50 +08:00
return utility_fn ;
}
utility_fn = type_system - > GetUtilityFunction ( text , name ) ;
if ( ! utility_fn )
error . SetErrorStringWithFormat ( " Could not create an expression for language %s " , Language : : GetNameForLanguageType ( language ) ) ;
return utility_fn ;
}
2010-06-09 00:52:24 +08:00
ClangASTContext *
2011-12-01 07:18:53 +08:00
Target : : GetScratchClangASTContext ( bool create_on_demand )
2010-06-09 00:52:24 +08:00
{
2015-10-09 05:04:34 +08:00
if ( m_valid )
2015-10-02 00:28:02 +08:00
{
2015-10-09 05:04:34 +08:00
if ( TypeSystem * type_system = GetScratchTypeSystemForLanguage ( nullptr , eLanguageTypeC , create_on_demand ) )
return llvm : : dyn_cast < ClangASTContext > ( type_system ) ;
2011-11-16 06:27:19 +08:00
}
2015-10-09 05:04:34 +08:00
return nullptr ;
2015-10-02 00:28:02 +08:00
}
2010-09-21 04:44:43 +08:00
2011-11-17 02:20:47 +08:00
ClangASTImporter *
Target : : GetClangASTImporter ( )
{
2015-10-09 05:04:34 +08:00
if ( m_valid )
2011-11-17 02:20:47 +08:00
{
2015-10-09 05:04:34 +08:00
ClangASTImporter * ast_importer = m_ast_importer_ap . get ( ) ;
if ( ! ast_importer )
{
ast_importer = new ClangASTImporter ( ) ;
m_ast_importer_ap . reset ( ast_importer ) ;
}
return ast_importer ;
2011-11-17 02:20:47 +08:00
}
2015-10-09 05:04:34 +08:00
return nullptr ;
2011-11-17 02:20:47 +08:00
}
2010-11-19 07:32:35 +08:00
void
2011-03-11 06:14:10 +08:00
Target : : SettingsInitialize ( )
2010-09-21 04:44:43 +08:00
{
2012-08-23 02:39:03 +08:00
Process : : SettingsInitialize ( ) ;
2010-11-19 07:32:35 +08:00
}
2010-09-21 04:44:43 +08:00
2010-11-19 07:32:35 +08:00
void
2011-03-11 06:14:10 +08:00
Target : : SettingsTerminate ( )
2010-11-19 07:32:35 +08:00
{
2012-08-23 02:39:03 +08:00
Process : : SettingsTerminate ( ) ;
}
2010-09-21 04:44:43 +08:00
2012-02-14 07:10:39 +08:00
FileSpecList
Target : : GetDefaultExecutableSearchPaths ( )
{
2012-08-23 01:17:09 +08:00
TargetPropertiesSP properties_sp ( Target : : GetGlobalProperties ( ) ) ;
if ( properties_sp )
return properties_sp - > GetExecutableSearchPaths ( ) ;
2012-02-14 07:10:39 +08:00
return FileSpecList ( ) ;
}
2013-07-02 03:45:50 +08:00
FileSpecList
Target : : GetDefaultDebugFileSearchPaths ( )
{
TargetPropertiesSP properties_sp ( Target : : GetGlobalProperties ( ) ) ;
if ( properties_sp )
return properties_sp - > GetDebugFileSearchPaths ( ) ;
return FileSpecList ( ) ;
}
2015-04-03 23:39:47 +08:00
FileSpecList
Target : : GetDefaultClangModuleSearchPaths ( )
{
TargetPropertiesSP properties_sp ( Target : : GetGlobalProperties ( ) ) ;
if ( properties_sp )
return properties_sp - > GetClangModuleSearchPaths ( ) ;
return FileSpecList ( ) ;
}
2010-09-21 04:44:43 +08:00
ArchSpec
Target : : GetDefaultArchitecture ( )
{
2012-08-23 01:17:09 +08:00
TargetPropertiesSP properties_sp ( Target : : GetGlobalProperties ( ) ) ;
if ( properties_sp )
return properties_sp - > GetDefaultArchitecture ( ) ;
2012-05-15 10:44:13 +08:00
return ArchSpec ( ) ;
2010-09-21 04:44:43 +08:00
}
void
2012-08-23 01:17:09 +08:00
Target : : SetDefaultArchitecture ( const ArchSpec & arch )
2010-09-21 04:44:43 +08:00
{
2012-08-23 01:17:09 +08:00
TargetPropertiesSP properties_sp ( Target : : GetGlobalProperties ( ) ) ;
if ( properties_sp )
2012-12-12 10:23:56 +08:00
{
LogIfAnyCategoriesSet ( LIBLLDB_LOG_TARGET , " Target::SetDefaultArchitecture setting target's default architecture to %s (%s) " , arch . GetArchitectureName ( ) , arch . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
2012-08-23 01:17:09 +08:00
return properties_sp - > SetDefaultArchitecture ( arch ) ;
2012-12-12 10:23:56 +08:00
}
2010-09-21 04:44:43 +08:00
}
2010-10-04 09:05:56 +08:00
Target *
Target : : GetTargetFromContexts ( const ExecutionContext * exe_ctx_ptr , const SymbolContext * sc_ptr )
{
// The target can either exist in the "process" of ExecutionContext, or in
// the "target_sp" member of SymbolContext. This accessor helper function
// will get the target from one of these locations.
Target * target = NULL ;
if ( sc_ptr ! = NULL )
target = sc_ptr - > target_sp . get ( ) ;
2011-09-22 12:58:26 +08:00
if ( target = = NULL & & exe_ctx_ptr )
target = exe_ctx_ptr - > GetTargetPtr ( ) ;
2010-10-04 09:05:56 +08:00
return target ;
}
2014-05-05 10:26:40 +08:00
ExpressionResults
2010-12-14 10:59:59 +08:00
Target : : EvaluateExpression
(
const char * expr_cstr ,
2013-11-04 17:33:30 +08:00
StackFrame * frame ,
2012-07-17 07:10:35 +08:00
lldb : : ValueObjectSP & result_valobj_sp ,
2012-09-06 04:41:26 +08:00
const EvaluateExpressionOptions & options
2010-12-14 10:59:59 +08:00
)
{
2012-09-19 01:43:16 +08:00
result_valobj_sp . reset ( ) ;
2014-05-05 10:47:44 +08:00
ExpressionResults execution_results = eExpressionSetupError ;
2010-12-14 10:59:59 +08:00
2011-12-08 10:13:16 +08:00
if ( expr_cstr = = NULL | | expr_cstr [ 0 ] = = ' \0 ' )
return execution_results ;
2011-05-12 10:06:14 +08:00
// We shouldn't run stop hooks in expressions.
// Be sure to reset this if you return anywhere within this function.
bool old_suppress_value = m_suppress_stop_hooks ;
m_suppress_stop_hooks = true ;
2010-12-14 10:59:59 +08:00
ExecutionContext exe_ctx ;
2013-01-12 10:04:23 +08:00
2010-12-14 10:59:59 +08:00
if ( frame )
{
frame - > CalculateExecutionContext ( exe_ctx ) ;
}
else if ( m_process_sp )
{
m_process_sp - > CalculateExecutionContext ( exe_ctx ) ;
}
else
{
CalculateExecutionContext ( exe_ctx ) ;
}
2013-01-12 10:04:23 +08:00
// Make sure we aren't just trying to see the value of a persistent
// variable (something like "$0")
2015-09-05 04:49:51 +08:00
lldb : : ExpressionVariableSP persistent_var_sp ;
2013-01-12 10:04:23 +08:00
// Only check for persistent variables the expression starts with a '$'
if ( expr_cstr [ 0 ] = = ' $ ' )
2015-10-03 02:40:30 +08:00
persistent_var_sp = GetScratchTypeSystemForLanguage ( nullptr , eLanguageTypeC ) - > GetPersistentExpressionState ( ) - > GetVariable ( expr_cstr ) ;
2013-01-12 10:04:23 +08:00
if ( persistent_var_sp )
2010-12-14 10:59:59 +08:00
{
2013-01-12 10:04:23 +08:00
result_valobj_sp = persistent_var_sp - > GetValueObject ( ) ;
2014-05-05 10:47:44 +08:00
execution_results = eExpressionCompleted ;
2010-12-14 10:59:59 +08:00
}
else
{
2013-01-12 10:04:23 +08:00
const char * prefix = GetExpressionPrefixContentsAsCString ( ) ;
2013-11-05 03:35:17 +08:00
Error error ;
2015-09-16 05:13:50 +08:00
execution_results = UserExpression : : Evaluate ( exe_ctx ,
options ,
expr_cstr ,
prefix ,
result_valobj_sp ,
error ) ;
2010-12-14 10:59:59 +08:00
}
2011-05-12 10:06:14 +08:00
m_suppress_stop_hooks = old_suppress_value ;
2010-12-14 10:59:59 +08:00
return execution_results ;
}
2015-10-09 05:04:34 +08:00
2015-10-01 03:57:57 +08:00
lldb : : ExpressionVariableSP
Target : : GetPersistentVariable ( const ConstString & name )
2015-03-04 03:23:09 +08:00
{
2015-10-09 05:04:34 +08:00
lldb : : ExpressionVariableSP variable_sp ;
m_scratch_type_system_map . ForEach ( [ this , name , & variable_sp ] ( TypeSystem * type_system ) - > bool
2015-10-01 03:57:57 +08:00
{
2015-10-09 05:04:34 +08:00
if ( PersistentExpressionState * persistent_state = type_system - > GetPersistentExpressionState ( ) )
2015-10-01 03:57:57 +08:00
{
2015-10-09 05:04:34 +08:00
variable_sp = persistent_state - > GetVariable ( name ) ;
if ( variable_sp )
return false ; // Stop iterating the ForEach
2015-10-01 03:57:57 +08:00
}
2015-10-09 05:04:34 +08:00
return true ; // Keep iterating the ForEach
} ) ;
return variable_sp ;
2015-03-04 03:23:09 +08:00
}
2015-10-02 00:28:02 +08:00
lldb : : addr_t
Target : : GetPersistentSymbol ( const ConstString & name )
{
2015-10-09 05:04:34 +08:00
lldb : : addr_t address = LLDB_INVALID_ADDRESS ;
2015-10-02 00:28:02 +08:00
2015-10-09 05:04:34 +08:00
m_scratch_type_system_map . ForEach ( [ this , name , & address ] ( TypeSystem * type_system ) - > bool
2015-10-02 00:28:02 +08:00
{
2015-10-09 05:04:34 +08:00
if ( PersistentExpressionState * persistent_state = type_system - > GetPersistentExpressionState ( ) )
2015-10-02 00:28:02 +08:00
{
2015-10-09 05:04:34 +08:00
address = persistent_state - > LookupSymbol ( name ) ;
if ( address ! = LLDB_INVALID_ADDRESS )
return false ; // Stop iterating the ForEach
2015-10-02 00:28:02 +08:00
}
2015-10-09 05:04:34 +08:00
return true ; // Keep iterating the ForEach
} ) ;
return address ;
2015-10-02 00:28:02 +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
lldb : : addr_t
Target : : GetCallableLoadAddress ( lldb : : addr_t load_addr , AddressClass addr_class ) const
{
addr_t code_addr = load_addr ;
switch ( m_arch . GetMachine ( ) )
{
2015-09-22 14:36:56 +08:00
case llvm : : Triple : : mips :
case llvm : : Triple : : mipsel :
case llvm : : Triple : : mips64 :
case llvm : : Triple : : mips64el :
switch ( addr_class )
{
case eAddressClassData :
case eAddressClassDebug :
return LLDB_INVALID_ADDRESS ;
case eAddressClassUnknown :
case eAddressClassInvalid :
case eAddressClassCode :
case eAddressClassCodeAlternateISA :
case eAddressClassRuntime :
if ( ( code_addr & 2ull ) | | ( addr_class = = eAddressClassCodeAlternateISA ) )
code_addr | = 1ull ;
break ;
}
break ;
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
case llvm : : Triple : : arm :
case llvm : : Triple : : thumb :
switch ( addr_class )
{
case eAddressClassData :
case eAddressClassDebug :
return LLDB_INVALID_ADDRESS ;
case eAddressClassUnknown :
case eAddressClassInvalid :
case eAddressClassCode :
case eAddressClassCodeAlternateISA :
case eAddressClassRuntime :
// Check if bit zero it no set?
if ( ( code_addr & 1ull ) = = 0 )
{
// Bit zero isn't set, check if the address is a multiple of 2?
if ( code_addr & 2ull )
{
// The address is a multiple of 2 so it must be thumb, set bit zero
code_addr | = 1ull ;
}
else if ( addr_class = = eAddressClassCodeAlternateISA )
{
// We checked the address and the address claims to be the alternate ISA
// which means thumb, so set bit zero.
code_addr | = 1ull ;
}
}
break ;
}
break ;
default :
break ;
}
return code_addr ;
}
lldb : : addr_t
Target : : GetOpcodeLoadAddress ( lldb : : addr_t load_addr , AddressClass addr_class ) const
{
addr_t opcode_addr = load_addr ;
switch ( m_arch . GetMachine ( ) )
{
2015-09-22 14:36:56 +08:00
case llvm : : Triple : : mips :
case llvm : : Triple : : mipsel :
case llvm : : Triple : : mips64 :
case llvm : : Triple : : mips64el :
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
case llvm : : Triple : : arm :
case llvm : : Triple : : thumb :
switch ( addr_class )
{
case eAddressClassData :
case eAddressClassDebug :
return LLDB_INVALID_ADDRESS ;
case eAddressClassInvalid :
case eAddressClassUnknown :
case eAddressClassCode :
case eAddressClassCodeAlternateISA :
case eAddressClassRuntime :
opcode_addr & = ~ ( 1ull ) ;
break ;
}
break ;
default :
break ;
}
return opcode_addr ;
}
2015-08-26 14:04:54 +08:00
lldb : : addr_t
Target : : GetBreakableLoadAddress ( lldb : : addr_t addr )
{
addr_t breakable_addr = addr ;
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_BREAKPOINTS ) ) ;
switch ( m_arch . GetMachine ( ) )
{
default :
break ;
case llvm : : Triple : : mips :
case llvm : : Triple : : mipsel :
case llvm : : Triple : : mips64 :
case llvm : : Triple : : mips64el :
{
addr_t function_start = 0 ;
addr_t current_offset = 0 ;
uint32_t loop_count = 0 ;
Address resolved_addr ;
uint32_t arch_flags = m_arch . GetFlags ( ) ;
bool IsMips16 = arch_flags & ArchSpec : : eMIPSAse_mips16 ;
bool IsMicromips = arch_flags & ArchSpec : : eMIPSAse_micromips ;
SectionLoadList & section_load_list = GetSectionLoadList ( ) ;
if ( section_load_list . IsEmpty ( ) )
// No sections are loaded, so we must assume we are not running yet
// and need to operate only on file address.
m_images . ResolveFileAddress ( addr , resolved_addr ) ;
else
section_load_list . ResolveLoadAddress ( addr , resolved_addr ) ;
// Get the function boundaries to make sure we don't scan back before the beginning of the current function.
ModuleSP temp_addr_module_sp ( resolved_addr . GetModule ( ) ) ;
if ( temp_addr_module_sp )
{
SymbolContext sc ;
uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol ;
2015-08-27 06:57:51 +08:00
temp_addr_module_sp - > ResolveSymbolContextForAddress ( resolved_addr , resolve_scope , sc ) ;
2015-08-26 14:04:54 +08:00
if ( sc . function )
{
function_start = sc . function - > GetAddressRange ( ) . GetBaseAddress ( ) . GetLoadAddress ( this ) ;
if ( function_start = = LLDB_INVALID_ADDRESS )
function_start = sc . function - > GetAddressRange ( ) . GetBaseAddress ( ) . GetFileAddress ( ) ;
}
else if ( sc . symbol )
{
Address sym_addr = sc . symbol - > GetAddress ( ) ;
function_start = sym_addr . GetFileAddress ( ) ;
}
current_offset = addr - function_start ;
}
// If breakpoint address is start of function then we dont have to do anything.
if ( current_offset = = 0 )
return breakable_addr ;
else
loop_count = current_offset / 2 ;
if ( loop_count > 3 )
{
// Scan previous 6 bytes
if ( IsMips16 | IsMicromips )
loop_count = 3 ;
// For mips-only, instructions are always 4 bytes, so scan previous 4 bytes only.
else
loop_count = 2 ;
}
// Create Disassembler Instance
lldb : : DisassemblerSP disasm_sp ( Disassembler : : FindPlugin ( m_arch , NULL , NULL ) ) ;
ExecutionContext exe_ctx ;
CalculateExecutionContext ( exe_ctx ) ;
InstructionList instruction_list ;
InstructionSP prev_insn ;
bool prefer_file_cache = true ; // Read from file
uint32_t inst_to_choose = 0 ;
for ( uint32_t i = 1 ; i < = loop_count ; i + + )
{
// Adjust the address to read from.
resolved_addr . Slide ( - 2 ) ;
AddressRange range ( resolved_addr , i * 2 ) ;
uint32_t insn_size = 0 ;
2015-08-27 06:57:51 +08:00
disasm_sp - > ParseInstructions ( & exe_ctx , range , NULL , prefer_file_cache ) ;
2015-08-26 14:04:54 +08:00
uint32_t num_insns = disasm_sp - > GetInstructionList ( ) . GetSize ( ) ;
if ( num_insns )
{
prev_insn = disasm_sp - > GetInstructionList ( ) . GetInstructionAtIndex ( 0 ) ;
insn_size = prev_insn - > GetOpcode ( ) . GetByteSize ( ) ;
if ( i = = 1 & & insn_size = = 2 )
{
// This looks like a valid 2-byte instruction (but it could be a part of upper 4 byte instruction).
instruction_list . Append ( prev_insn ) ;
inst_to_choose = 1 ;
}
else if ( i = = 2 )
{
// Here we may get one 4-byte instruction or two 2-byte instructions.
if ( num_insns = = 2 )
{
// Looks like there are two 2-byte instructions above our breakpoint target address.
// Now the upper 2-byte instruction is either a valid 2-byte instruction or could be a part of it's upper 4-byte instruction.
// In both cases we don't care because in this case lower 2-byte instruction is definitely a valid instruction
// and whatever i=1 iteration has found out is true.
inst_to_choose = 1 ;
break ;
}
else if ( insn_size = = 4 )
{
// This instruction claims its a valid 4-byte instruction. But it could be a part of it's upper 4-byte instruction.
// Lets try scanning upper 2 bytes to verify this.
instruction_list . Append ( prev_insn ) ;
inst_to_choose = 2 ;
}
}
else if ( i = = 3 )
{
if ( insn_size = = 4 )
// FIXME: We reached here that means instruction at [target - 4] has already claimed to be a 4-byte instruction,
// and now instruction at [target - 6] is also claiming that it's a 4-byte instruction. This can not be true.
// In this case we can not decide the valid previous instruction so we let lldb set the breakpoint at the address given by user.
inst_to_choose = 0 ;
else
// This is straight-forward
inst_to_choose = 2 ;
break ;
}
}
else
{
// Decode failed, bytes do not form a valid instruction. So whatever previous iteration has found out is true.
if ( i > 1 )
{
inst_to_choose = i - 1 ;
break ;
}
}
}
// Check if we are able to find any valid instruction.
if ( inst_to_choose )
{
if ( inst_to_choose > instruction_list . GetSize ( ) )
inst_to_choose - - ;
prev_insn = instruction_list . GetInstructionAtIndex ( inst_to_choose - 1 ) ;
if ( prev_insn - > HasDelaySlot ( ) )
{
uint32_t shift_size = prev_insn - > GetOpcode ( ) . GetByteSize ( ) ;
// Adjust the breakable address
breakable_addr = addr - shift_size ;
if ( log )
log - > Printf ( " Target::%s Breakpoint at 0x%8.8 " PRIx64 " is adjusted to 0x%8.8 " PRIx64 " due to delay slot \n " , __FUNCTION__ , addr , breakable_addr ) ;
}
}
break ;
}
}
return breakable_addr ;
}
2013-03-19 08:20:55 +08:00
SourceManager &
Target : : GetSourceManager ( )
{
if ( m_source_manager_ap . get ( ) = = NULL )
m_source_manager_ap . reset ( new SourceManager ( shared_from_this ( ) ) ) ;
return * m_source_manager_ap ;
}
2014-12-05 09:21:59 +08:00
ClangModulesDeclVendor *
Target : : GetClangModulesDeclVendor ( )
{
static Mutex s_clang_modules_decl_vendor_mutex ; // If this is contended we can make it per-target
{
Mutex : : Locker clang_modules_decl_vendor_locker ( s_clang_modules_decl_vendor_mutex ) ;
if ( ! m_clang_modules_decl_vendor_ap )
{
m_clang_modules_decl_vendor_ap . reset ( ClangModulesDeclVendor : : Create ( * this ) ) ;
}
}
return m_clang_modules_decl_vendor_ap . get ( ) ;
}
2013-03-19 08:20:55 +08:00
2014-01-28 07:43:24 +08:00
Target : : StopHookSP
Target : : CreateStopHook ( )
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
{
lldb : : user_id_t new_uid = + + m_stop_hook_next_id ;
2014-01-28 07:43:24 +08:00
Target : : StopHookSP stop_hook_sp ( new StopHook ( shared_from_this ( ) , new_uid ) ) ;
m_stop_hooks [ new_uid ] = stop_hook_sp ;
return stop_hook_sp ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
}
bool
Target : : RemoveStopHookByID ( lldb : : user_id_t user_id )
{
size_t num_removed ;
num_removed = m_stop_hooks . erase ( user_id ) ;
if ( num_removed = = 0 )
return false ;
else
return true ;
}
void
Target : : RemoveAllStopHooks ( )
{
m_stop_hooks . clear ( ) ;
}
Target : : StopHookSP
Target : : GetStopHookByID ( lldb : : user_id_t user_id )
{
StopHookSP found_hook ;
StopHookCollection : : iterator specified_hook_iter ;
specified_hook_iter = m_stop_hooks . find ( user_id ) ;
if ( specified_hook_iter ! = m_stop_hooks . end ( ) )
found_hook = ( * specified_hook_iter ) . second ;
return found_hook ;
}
bool
Target : : SetStopHookActiveStateByID ( lldb : : user_id_t user_id , bool active_state )
{
StopHookCollection : : iterator specified_hook_iter ;
specified_hook_iter = m_stop_hooks . find ( user_id ) ;
if ( specified_hook_iter = = m_stop_hooks . end ( ) )
return false ;
( * specified_hook_iter ) . second - > SetIsActive ( active_state ) ;
return true ;
}
void
Target : : SetAllStopHooksActiveState ( bool active_state )
{
StopHookCollection : : iterator pos , end = m_stop_hooks . end ( ) ;
for ( pos = m_stop_hooks . begin ( ) ; pos ! = end ; pos + + )
{
( * pos ) . second - > SetIsActive ( active_state ) ;
}
}
void
Target : : RunStopHooks ( )
{
2011-05-12 10:06:14 +08:00
if ( m_suppress_stop_hooks )
return ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
if ( ! m_process_sp )
return ;
2012-08-04 06:24:48 +08:00
// <rdar://problem/12027563> make sure we check that we are not stopped because of us running a user expression
// since in that case we do not want to run the stop-hooks
if ( m_process_sp - > GetModIDRef ( ) . IsLastResumeForUserExpression ( ) )
return ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
if ( m_stop_hooks . empty ( ) )
return ;
StopHookCollection : : iterator pos , end = m_stop_hooks . end ( ) ;
// If there aren't any active stop hooks, don't bother either:
bool any_active_hooks = false ;
for ( pos = m_stop_hooks . begin ( ) ; pos ! = end ; pos + + )
{
if ( ( * pos ) . second - > IsActive ( ) )
{
any_active_hooks = true ;
break ;
}
}
if ( ! any_active_hooks )
return ;
CommandReturnObject result ;
std : : vector < ExecutionContext > exc_ctx_with_reasons ;
std : : vector < SymbolContext > sym_ctx_with_reasons ;
ThreadList & cur_threadlist = m_process_sp - > GetThreadList ( ) ;
size_t num_threads = cur_threadlist . GetSize ( ) ;
for ( size_t i = 0 ; i < num_threads ; i + + )
{
lldb : : ThreadSP cur_thread_sp = cur_threadlist . GetThreadAtIndex ( i ) ;
if ( cur_thread_sp - > ThreadStoppedForAReason ( ) )
{
2013-11-04 17:33:30 +08:00
lldb : : StackFrameSP cur_frame_sp = cur_thread_sp - > GetStackFrameAtIndex ( 0 ) ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
exc_ctx_with_reasons . push_back ( ExecutionContext ( m_process_sp . get ( ) , cur_thread_sp . get ( ) , cur_frame_sp . get ( ) ) ) ;
sym_ctx_with_reasons . push_back ( cur_frame_sp - > GetSymbolContext ( eSymbolContextEverything ) ) ;
}
}
// If no threads stopped for a reason, don't run the stop-hooks.
size_t num_exe_ctx = exc_ctx_with_reasons . size ( ) ;
if ( num_exe_ctx = = 0 )
return ;
2011-06-03 07:58:26 +08:00
result . SetImmediateOutputStream ( m_debugger . GetAsyncOutputStream ( ) ) ;
result . SetImmediateErrorStream ( m_debugger . GetAsyncErrorStream ( ) ) ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
bool keep_going = true ;
bool hooks_ran = false ;
2011-03-22 09:47:27 +08:00
bool print_hook_header ;
bool print_thread_header ;
if ( num_exe_ctx = = 1 )
print_thread_header = false ;
else
print_thread_header = true ;
if ( m_stop_hooks . size ( ) = = 1 )
print_hook_header = false ;
else
print_hook_header = true ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
for ( pos = m_stop_hooks . begin ( ) ; keep_going & & pos ! = end ; pos + + )
{
// result.Clear();
StopHookSP cur_hook_sp = ( * pos ) . second ;
if ( ! cur_hook_sp - > IsActive ( ) )
continue ;
bool any_thread_matched = false ;
for ( size_t i = 0 ; keep_going & & i < num_exe_ctx ; i + + )
{
if ( ( cur_hook_sp - > GetSpecifier ( ) = = NULL
| | cur_hook_sp - > GetSpecifier ( ) - > SymbolContextMatches ( sym_ctx_with_reasons [ i ] ) )
& & ( cur_hook_sp - > GetThreadSpecifier ( ) = = NULL
2012-03-08 06:03:04 +08:00
| | cur_hook_sp - > GetThreadSpecifier ( ) - > ThreadPassesBasicTests ( exc_ctx_with_reasons [ i ] . GetThreadRef ( ) ) ) )
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
{
if ( ! hooks_ran )
{
hooks_ran = true ;
}
2011-03-22 09:47:27 +08:00
if ( print_hook_header & & ! any_thread_matched )
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
{
2011-10-25 07:01:06 +08:00
const char * cmd = ( cur_hook_sp - > GetCommands ( ) . GetSize ( ) = = 1 ?
cur_hook_sp - > GetCommands ( ) . GetStringAtIndex ( 0 ) :
NULL ) ;
if ( cmd )
2012-11-30 05:49:15 +08:00
result . AppendMessageWithFormat ( " \n - Hook % " PRIu64 " (%s) \n " , cur_hook_sp - > GetID ( ) , cmd ) ;
2011-10-25 07:01:06 +08:00
else
2012-11-30 05:49:15 +08:00
result . AppendMessageWithFormat ( " \n - Hook % " PRIu64 " \n " , cur_hook_sp - > GetID ( ) ) ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
any_thread_matched = true ;
}
2011-03-22 09:47:27 +08:00
if ( print_thread_header )
2011-09-22 12:58:26 +08:00
result . AppendMessageWithFormat ( " -- Thread %d \n " , exc_ctx_with_reasons [ i ] . GetThreadPtr ( ) - > GetIndexID ( ) ) ;
2014-10-11 08:38:27 +08:00
CommandInterpreterRunOptions options ;
options . SetStopOnContinue ( true ) ;
options . SetStopOnError ( true ) ;
options . SetEchoCommands ( false ) ;
options . SetPrintResults ( true ) ;
options . SetAddToHistory ( false ) ;
GetDebugger ( ) . GetCommandInterpreter ( ) . HandleCommands ( cur_hook_sp - > GetCommands ( ) ,
& exc_ctx_with_reasons [ i ] ,
options ,
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
result ) ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
// If the command started the target going again, we should bag out of
// running the stop hooks.
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
if ( ( result . GetStatus ( ) = = eReturnStatusSuccessContinuingNoResult ) | |
( result . GetStatus ( ) = = eReturnStatusSuccessContinuingResult ) )
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
{
2012-11-30 05:49:15 +08:00
result . AppendMessageWithFormat ( " Aborting stop hooks, hook % " PRIu64 " set the program running. " , cur_hook_sp - > GetID ( ) ) ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
keep_going = false ;
}
}
}
}
2011-09-23 08:42:55 +08:00
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.
As part of this it introduces a new Stream class,
StreamAsynchronousIO. A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast. When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string. When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.
Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.
I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired. I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).
llvm-svn: 130721
2011-05-03 04:41:46 +08:00
result . GetImmediateOutputStream ( ) - > Flush ( ) ;
result . GetImmediateErrorStream ( ) - > Flush ( ) ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
}
2013-11-21 05:07:01 +08:00
const TargetPropertiesSP &
Target : : GetGlobalProperties ( )
{
static TargetPropertiesSP g_settings_sp ;
if ( ! g_settings_sp )
{
g_settings_sp . reset ( new TargetProperties ( NULL ) ) ;
}
return g_settings_sp ;
}
Error
Target : : Install ( ProcessLaunchInfo * launch_info )
{
Error error ;
PlatformSP platform_sp ( GetPlatform ( ) ) ;
if ( platform_sp )
{
if ( platform_sp - > IsRemote ( ) )
{
if ( platform_sp - > IsConnected ( ) )
{
// Install all files that have an install path, and always install the
// main executable when connected to a remote platform
const ModuleList & modules = GetImages ( ) ;
const size_t num_images = modules . GetSize ( ) ;
for ( size_t idx = 0 ; idx < num_images ; + + idx )
{
const bool is_main_executable = idx = = 0 ;
ModuleSP module_sp ( modules . GetModuleAtIndex ( idx ) ) ;
if ( module_sp )
{
FileSpec local_file ( module_sp - > GetFileSpec ( ) ) ;
if ( local_file )
{
FileSpec remote_file ( module_sp - > GetRemoteInstallFileSpec ( ) ) ;
if ( ! remote_file )
{
if ( is_main_executable ) // TODO: add setting for always installing main executable???
{
// Always install the main executable
2015-05-30 03:52:29 +08:00
remote_file = platform_sp - > GetRemoteWorkingDirectory ( ) ;
remote_file . AppendPathComponent ( module_sp - > GetFileSpec ( ) . GetFilename ( ) . GetCString ( ) ) ;
2013-11-21 05:07:01 +08:00
}
}
if ( remote_file )
{
error = platform_sp - > Install ( local_file , remote_file ) ;
if ( error . Success ( ) )
{
module_sp - > SetPlatformFileSpec ( remote_file ) ;
if ( is_main_executable )
{
2015-05-30 03:52:29 +08:00
platform_sp - > SetFilePermissions ( remote_file , 0700 ) ;
2013-11-21 05:07:01 +08:00
if ( launch_info )
launch_info - > SetExecutableFile ( remote_file , false ) ;
}
}
else
break ;
}
}
}
}
}
}
}
return error ;
}
2011-07-08 08:48:09 +08:00
2013-12-06 09:12:00 +08:00
bool
Target : : ResolveLoadAddress ( addr_t load_addr , Address & so_addr , uint32_t stop_id )
{
return m_section_load_history . ResolveLoadAddress ( stop_id , load_addr , so_addr ) ;
}
2014-10-22 15:22:56 +08:00
bool
Target : : ResolveFileAddress ( lldb : : addr_t file_addr , Address & resolved_addr )
{
return m_images . ResolveFileAddress ( file_addr , resolved_addr ) ;
}
2013-12-06 09:12:00 +08:00
bool
Target : : SetSectionLoadAddress ( const SectionSP & section_sp , addr_t new_section_load_addr , bool warn_multiple )
{
const addr_t old_section_load_addr = m_section_load_history . GetSectionLoadAddress ( SectionLoadHistory : : eStopIDNow , section_sp ) ;
if ( old_section_load_addr ! = new_section_load_addr )
{
uint32_t stop_id = 0 ;
ProcessSP process_sp ( GetProcessSP ( ) ) ;
if ( process_sp )
stop_id = process_sp - > GetStopID ( ) ;
else
stop_id = m_section_load_history . GetLastStopID ( ) ;
if ( m_section_load_history . SetSectionLoadAddress ( stop_id , section_sp , new_section_load_addr , warn_multiple ) )
return true ; // Return true if the section load address was changed...
}
return false ; // Return false to indicate nothing changed
}
2014-11-18 03:39:20 +08:00
size_t
Target : : UnloadModuleSections ( const ModuleList & module_list )
{
size_t section_unload_count = 0 ;
size_t num_modules = module_list . GetSize ( ) ;
for ( size_t i = 0 ; i < num_modules ; + + i )
{
section_unload_count + = UnloadModuleSections ( module_list . GetModuleAtIndex ( i ) ) ;
}
return section_unload_count ;
}
size_t
Target : : UnloadModuleSections ( const lldb : : ModuleSP & module_sp )
{
uint32_t stop_id = 0 ;
ProcessSP process_sp ( GetProcessSP ( ) ) ;
if ( process_sp )
stop_id = process_sp - > GetStopID ( ) ;
else
stop_id = m_section_load_history . GetLastStopID ( ) ;
SectionList * sections = module_sp - > GetSectionList ( ) ;
size_t section_unload_count = 0 ;
if ( sections )
{
const uint32_t num_sections = sections - > GetNumSections ( 0 ) ;
for ( uint32_t i = 0 ; i < num_sections ; + + i )
{
section_unload_count + = m_section_load_history . SetSectionUnloaded ( stop_id , sections - > GetSectionAtIndex ( i ) ) ;
}
}
return section_unload_count ;
}
2013-12-06 09:12:00 +08:00
bool
Target : : SetSectionUnloaded ( const lldb : : SectionSP & section_sp )
{
uint32_t stop_id = 0 ;
ProcessSP process_sp ( GetProcessSP ( ) ) ;
if ( process_sp )
stop_id = process_sp - > GetStopID ( ) ;
else
stop_id = m_section_load_history . GetLastStopID ( ) ;
return m_section_load_history . SetSectionUnloaded ( stop_id , section_sp ) ;
}
bool
Target : : SetSectionUnloaded ( const lldb : : SectionSP & section_sp , addr_t load_addr )
{
uint32_t stop_id = 0 ;
ProcessSP process_sp ( GetProcessSP ( ) ) ;
if ( process_sp )
stop_id = process_sp - > GetStopID ( ) ;
else
stop_id = m_section_load_history . GetLastStopID ( ) ;
return m_section_load_history . SetSectionUnloaded ( stop_id , section_sp , load_addr ) ;
}
void
Target : : ClearAllLoadedSections ( )
{
m_section_load_history . Clear ( ) ;
}
2013-12-14 01:20:18 +08:00
Error
2014-11-18 03:39:20 +08:00
Target : : Launch ( ProcessLaunchInfo & launch_info , Stream * stream )
2013-12-14 01:20:18 +08:00
{
Error error ;
2014-10-09 09:02:08 +08:00
Log * log ( lldb_private : : GetLogIfAllCategoriesSet ( LIBLLDB_LOG_TARGET ) ) ;
if ( log )
log - > Printf ( " Target::%s() called for %s " , __FUNCTION__ , launch_info . GetExecutableFile ( ) . GetPath ( ) . c_str ( ) ) ;
2013-12-14 01:20:18 +08:00
StateType state = eStateInvalid ;
2013-12-18 10:06:45 +08:00
// Scope to temporarily get the process state in case someone has manually
// remotely connected already to a process and we can skip the platform
// launching.
{
ProcessSP process_sp ( GetProcessSP ( ) ) ;
if ( process_sp )
2014-10-09 09:02:08 +08:00
{
2013-12-18 10:06:45 +08:00
state = process_sp - > GetState ( ) ;
2014-10-09 09:02:08 +08:00
if ( log )
log - > Printf ( " Target::%s the process exists, and its current state is %s " , __FUNCTION__ , StateAsCString ( state ) ) ;
}
else
{
if ( log )
log - > Printf ( " Target::%s the process instance doesn't currently exist. " , __FUNCTION__ ) ;
}
2013-12-18 10:06:45 +08:00
}
2013-12-14 01:20:18 +08:00
launch_info . GetFlags ( ) . Set ( eLaunchFlagDebug ) ;
// Get the value of synchronous execution here. If you wait till after you have started to
// run, then you could have hit a breakpoint, whose command might switch the value, and
// then you'll pick up that incorrect value.
Debugger & debugger = GetDebugger ( ) ;
const bool synchronous_execution = debugger . GetCommandInterpreter ( ) . GetSynchronous ( ) ;
PlatformSP platform_sp ( GetPlatform ( ) ) ;
// Finalize the file actions, and if none were given, default to opening
// up a pseudo terminal
const bool default_to_use_pty = platform_sp ? platform_sp - > IsHost ( ) : false ;
2014-10-12 05:42:09 +08:00
if ( log )
log - > Printf ( " Target::%s have platform=%s, platform_sp->IsHost()=%s, default_to_use_pty=%s " ,
__FUNCTION__ ,
platform_sp ? " true " : " false " ,
platform_sp ? ( platform_sp - > IsHost ( ) ? " true " : " false " ) : " n/a " ,
default_to_use_pty ? " true " : " false " ) ;
2013-12-14 01:20:18 +08:00
launch_info . FinalizeFileActions ( this , default_to_use_pty ) ;
if ( state = = eStateConnected )
{
if ( launch_info . GetFlags ( ) . Test ( eLaunchFlagLaunchInTTY ) )
{
error . SetErrorString ( " can't launch in tty when launching through a remote connection " ) ;
return error ;
}
}
if ( ! launch_info . GetArchitecture ( ) . IsValid ( ) )
launch_info . GetArchitecture ( ) = GetArchitecture ( ) ;
2014-07-23 07:41:36 +08:00
// If we're not already connected to the process, and if we have a platform that can launch a process for debugging, go ahead and do that here.
2013-12-14 01:20:18 +08:00
if ( state ! = eStateConnected & & platform_sp & & platform_sp - > CanDebugProcess ( ) )
{
2014-10-09 09:02:08 +08:00
if ( log )
log - > Printf ( " Target::%s asking the platform to debug the process " , __FUNCTION__ ) ;
2015-05-23 11:54:53 +08:00
// Get a weak pointer to the previous process if we have one
ProcessWP process_wp ;
if ( m_process_sp )
process_wp = m_process_sp ;
2013-12-14 01:20:18 +08:00
m_process_sp = GetPlatform ( ) - > DebugProcess ( launch_info ,
debugger ,
this ,
error ) ;
2015-05-23 11:54:53 +08:00
// Cleanup the old process since someone might still have a strong
// reference to this process and we would like to allow it to cleanup
// as much as it can without the object being destroyed. We try to
// lock the shared pointer and if that works, then someone else still
// has a strong reference to the process.
ProcessSP old_process_sp ( process_wp . lock ( ) ) ;
if ( old_process_sp )
old_process_sp - > Finalize ( ) ;
2013-12-14 01:20:18 +08:00
}
else
{
2014-10-09 09:02:08 +08:00
if ( log )
log - > Printf ( " Target::%s the platform doesn't know how to debug a process, getting a process plugin to do this for us. " , __FUNCTION__ ) ;
2013-12-14 01:20:18 +08:00
if ( state = = eStateConnected )
{
assert ( m_process_sp ) ;
}
else
{
2014-07-23 07:41:36 +08:00
// Use a Process plugin to construct the process.
2013-12-14 01:20:18 +08:00
const char * plugin_name = launch_info . GetProcessPluginName ( ) ;
2014-11-18 03:39:20 +08:00
CreateProcess ( launch_info . GetListenerForProcess ( debugger ) , plugin_name , NULL ) ;
2013-12-14 01:20:18 +08:00
}
2014-07-23 07:41:36 +08:00
// Since we didn't have a platform launch the process, launch it here.
2013-12-14 01:20:18 +08:00
if ( m_process_sp )
error = m_process_sp - > Launch ( launch_info ) ;
}
if ( ! m_process_sp )
{
if ( error . Success ( ) )
error . SetErrorString ( " failed to launch or debug process " ) ;
return error ;
}
if ( error . Success ( ) )
{
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-24 05:16:25 +08:00
if ( synchronous_execution | | launch_info . GetFlags ( ) . Test ( eLaunchFlagStopAtEntry ) = = false )
2013-12-14 01:20:18 +08:00
{
2014-01-28 07:43:24 +08:00
ListenerSP hijack_listener_sp ( launch_info . GetHijackListener ( ) ) ;
2015-03-27 04:41:14 +08:00
if ( ! hijack_listener_sp )
{
hijack_listener_sp . reset ( new Listener ( " lldb.Target.Launch.hijack " ) ) ;
launch_info . SetHijackListener ( hijack_listener_sp ) ;
m_process_sp - > HijackProcessEvents ( hijack_listener_sp . get ( ) ) ;
}
2014-10-09 09:02:08 +08:00
2015-05-20 18:15:47 +08:00
StateType state = m_process_sp - > WaitForProcessToStop ( NULL , NULL , false , hijack_listener_sp . get ( ) , NULL ) ;
2013-12-14 01:20:18 +08:00
if ( state = = eStateStopped )
{
2015-03-27 04:41:14 +08:00
if ( ! launch_info . GetFlags ( ) . Test ( eLaunchFlagStopAtEntry ) )
2013-12-14 01:20:18 +08:00
{
2015-03-27 04:41:14 +08:00
if ( synchronous_execution )
2013-12-14 01:20:18 +08:00
{
2015-03-27 04:41:14 +08:00
error = m_process_sp - > PrivateResume ( ) ;
if ( error . Success ( ) )
2013-12-14 01:20:18 +08:00
{
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-24 05:16:25 +08:00
state = m_process_sp - > WaitForProcessToStop ( NULL , NULL , true , hijack_listener_sp . get ( ) , stream ) ;
const bool must_be_alive = false ; // eStateExited is ok, so this must be false
if ( ! StateIsStoppedState ( state , must_be_alive ) )
{
error . SetErrorStringWithFormat ( " process isn't stopped: %s " , StateAsCString ( state ) ) ;
}
2013-12-14 01:20:18 +08:00
}
}
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-24 05:16:25 +08:00
else
2015-03-27 04:41:14 +08:00
{
m_process_sp - > RestoreProcessEvents ( ) ;
error = m_process_sp - > PrivateResume ( ) ;
}
if ( ! error . Success ( ) )
Fix Target::Launch in case of synchronous execution
Summary: This patch fixes Target::Launch in case of synchronous execution.
Test Plan:
# Create file with source commands:
```
$ cat start_script
target create ~/p/hello
process launch -s
continue
```
# Run lldb and execute "command source -c 0 -s 0 start_script":
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92028 stopped
* thread #1: tid = 0x26731, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb) Process 92028 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
'
` - it's \ni=1
j=2
x=3
y=4
argc: /Users/IliaK/p/hello
argc: (null)
Process 92028 resuming
Process 92028 exited with status = 0 (0x00000000)
(lldb)
```
was:
```
$ bin/lldb
(lldb) command source -c 0 -s 0 start_script
Executing commands in '/Users/IliaK/p/llvm/build_ninja/start_script'.
(lldb) target create ~/p/hello
Current executable set to '~/p/hello' (x86_64).
(lldb) process launch -s
Process 92100 launched: '/Users/IliaK/p/hello' (x86_64)
(lldb) continue
error: Process must be launched.
Process 92100 stopped
* thread #1: tid = 0x2699a, 0x00007fff5fc01000 dyld`_dyld_start, stop reason = signal SIGSTOP
frame #0: 0x00007fff5fc01000 dyld`_dyld_start
dyld`_dyld_start:
-> 0x7fff5fc01000 <+0>: popq %rdi
0x7fff5fc01001 <+1>: pushq $0x0
0x7fff5fc01003 <+3>: movq %rsp, %rbp
0x7fff5fc01006 <+6>: andq $-0x10, %rsp
(lldb)
```
Reviewers: jingham, clayborg
Reviewed By: clayborg
Subscribers: labath, lldb-commits, clayborg, jingham
Differential Revision: http://reviews.llvm.org/D8541
llvm-svn: 233022
2015-03-24 05:16:25 +08:00
{
Error error2 ;
error2 . SetErrorStringWithFormat ( " process resume at entry point failed: %s " , error . AsCString ( ) ) ;
error = error2 ;
}
2013-12-14 01:20:18 +08:00
}
}
2014-05-01 04:29:09 +08:00
else if ( state = = eStateExited )
{
2014-10-21 01:46:43 +08:00
bool with_shell = ! ! launch_info . GetShell ( ) ;
2014-05-01 04:29:09 +08:00
const int exit_status = m_process_sp - > GetExitStatus ( ) ;
const char * exit_desc = m_process_sp - > GetExitDescription ( ) ;
# define LAUNCH_SHELL_MESSAGE "\n'r' and 'run' are aliases that default to launching through a shell.\nTry launching without going through a shell by using 'process launch'."
if ( exit_desc & & exit_desc [ 0 ] )
{
if ( with_shell )
error . SetErrorStringWithFormat ( " process exited with status %i (%s) " LAUNCH_SHELL_MESSAGE , exit_status , exit_desc ) ;
else
error . SetErrorStringWithFormat ( " process exited with status %i (%s) " , exit_status , exit_desc ) ;
}
else
{
if ( with_shell )
error . SetErrorStringWithFormat ( " process exited with status %i " LAUNCH_SHELL_MESSAGE , exit_status ) ;
else
error . SetErrorStringWithFormat ( " process exited with status %i " , exit_status ) ;
}
}
2013-12-14 01:20:18 +08:00
else
{
error . SetErrorStringWithFormat ( " initial process state wasn't stopped: %s " , StateAsCString ( state ) ) ;
}
}
2014-01-28 07:43:24 +08:00
m_process_sp - > RestoreProcessEvents ( ) ;
2013-12-14 01:20:18 +08:00
}
else
{
2014-01-28 07:43:24 +08:00
Error error2 ;
2013-12-14 01:20:18 +08:00
error2 . SetErrorStringWithFormat ( " process launch failed: %s " , error . AsCString ( ) ) ;
2014-01-28 07:43:24 +08:00
error = error2 ;
2013-12-14 01:20:18 +08:00
}
return error ;
}
2015-02-11 06:49:57 +08:00
Error
Target : : Attach ( ProcessAttachInfo & attach_info , Stream * stream )
{
auto state = eStateInvalid ;
auto process_sp = GetProcessSP ( ) ;
if ( process_sp )
{
state = process_sp - > GetState ( ) ;
if ( process_sp - > IsAlive ( ) & & state ! = eStateConnected )
{
if ( state = = eStateAttaching )
return Error ( " process attach is in progress " ) ;
return Error ( " a process is already being debugged " ) ;
}
}
const ModuleSP old_exec_module_sp = GetExecutableModule ( ) ;
// If no process info was specified, then use the target executable
// name as the process to attach to by default
if ( ! attach_info . ProcessInfoSpecified ( ) )
{
if ( old_exec_module_sp )
attach_info . GetExecutableFile ( ) . GetFilename ( ) = old_exec_module_sp - > GetPlatformFileSpec ( ) . GetFilename ( ) ;
if ( ! attach_info . ProcessInfoSpecified ( ) )
{
return Error ( " no process specified, create a target with a file, or specify the --pid or --name " ) ;
}
}
const auto platform_sp = GetDebugger ( ) . GetPlatformList ( ) . GetSelectedPlatform ( ) ;
2015-10-06 06:58:37 +08:00
ListenerSP hijack_listener_sp ;
const bool async = attach_info . GetAsync ( ) ;
if ( async = = false )
{
hijack_listener_sp . reset ( new Listener ( " lldb.Target.Attach.attach.hijack " ) ) ;
attach_info . SetHijackListener ( hijack_listener_sp ) ;
}
2015-02-11 06:49:57 +08:00
Error error ;
if ( state ! = eStateConnected & & platform_sp ! = nullptr & & platform_sp - > CanDebugProcess ( ) )
{
SetPlatform ( platform_sp ) ;
process_sp = platform_sp - > Attach ( attach_info , GetDebugger ( ) , this , error ) ;
}
else
{
if ( state ! = eStateConnected )
{
const char * plugin_name = attach_info . GetProcessPluginName ( ) ;
process_sp = CreateProcess ( attach_info . GetListenerForProcess ( GetDebugger ( ) ) , plugin_name , nullptr ) ;
if ( process_sp = = nullptr )
{
error . SetErrorStringWithFormat ( " failed to create process using plugin %s " , ( plugin_name ) ? plugin_name : " null " ) ;
return error ;
}
}
2015-10-06 06:58:37 +08:00
if ( hijack_listener_sp )
process_sp - > HijackProcessEvents ( hijack_listener_sp . get ( ) ) ;
2015-02-11 06:49:57 +08:00
error = process_sp - > Attach ( attach_info ) ;
}
2015-10-20 08:14:20 +08:00
if ( error . Success ( ) & & process_sp )
2015-02-11 06:49:57 +08:00
{
2015-10-20 08:14:20 +08:00
if ( async )
2015-02-11 06:49:57 +08:00
{
2015-10-20 08:14:20 +08:00
process_sp - > RestoreProcessEvents ( ) ;
}
else
{
state = process_sp - > WaitForProcessToStop ( nullptr , nullptr , false , attach_info . GetHijackListener ( ) . get ( ) , stream ) ;
process_sp - > RestoreProcessEvents ( ) ;
if ( state ! = eStateStopped )
{
const char * exit_desc = process_sp - > GetExitDescription ( ) ;
if ( exit_desc )
error . SetErrorStringWithFormat ( " %s " , exit_desc ) ;
else
error . SetErrorString ( " process did not stop (no such process or permission problem?) " ) ;
process_sp - > Destroy ( false ) ;
}
2015-02-11 06:49:57 +08:00
}
}
return error ;
}
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
//--------------------------------------------------------------
2013-11-21 05:07:01 +08:00
// Target::StopHook
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
//--------------------------------------------------------------
Target : : StopHook : : StopHook ( lldb : : TargetSP target_sp , lldb : : user_id_t uid ) :
UserID ( uid ) ,
m_target_sp ( target_sp ) ,
m_commands ( ) ,
m_specifier_sp ( ) ,
2013-04-19 02:10:51 +08:00
m_thread_spec_ap ( ) ,
2011-04-12 03:41:40 +08:00
m_active ( true )
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
{
}
Target : : StopHook : : StopHook ( const StopHook & rhs ) :
UserID ( rhs . GetID ( ) ) ,
m_target_sp ( rhs . m_target_sp ) ,
m_commands ( rhs . m_commands ) ,
m_specifier_sp ( rhs . m_specifier_sp ) ,
2013-04-19 02:10:51 +08:00
m_thread_spec_ap ( ) ,
2011-04-12 03:41:40 +08:00
m_active ( rhs . m_active )
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
{
if ( rhs . m_thread_spec_ap . get ( ) ! = NULL )
m_thread_spec_ap . reset ( new ThreadSpec ( * rhs . m_thread_spec_ap . get ( ) ) ) ;
}
Target : : StopHook : : ~ StopHook ( )
{
}
2015-03-04 03:23:09 +08:00
void
Target : : StopHook : : SetSpecifier ( SymbolContextSpecifier * specifier )
{
m_specifier_sp . reset ( specifier ) ;
}
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
void
Target : : StopHook : : SetThreadSpecifier ( ThreadSpec * specifier )
{
m_thread_spec_ap . reset ( specifier ) ;
}
void
Target : : StopHook : : GetDescription ( Stream * s , lldb : : DescriptionLevel level ) const
{
int indent_level = s - > GetIndentLevel ( ) ;
s - > SetIndentLevel ( indent_level + 2 ) ;
2012-11-30 05:49:15 +08:00
s - > Printf ( " Hook: % " PRIu64 " \n " , GetID ( ) ) ;
Add a first pass at a "stop hook" mechanism. This allows you to add commands that get run every time the debugger stops, whether due to a breakpoint, the end of a step, interrupt, etc. You can also specify in which context you want the stop hook to run, for instance only on a particular thread, or only in a particular shared library, function, file, line range within a file.
Still need to add "in methods of a class" to the specifiers, and the ability to write the stop hooks in the Scripting language as well as in the Command Language.
llvm-svn: 127457
2011-03-11 11:53:59 +08:00
if ( m_active )
s - > Indent ( " State: enabled \n " ) ;
else
s - > Indent ( " State: disabled \n " ) ;
if ( m_specifier_sp )
{
s - > Indent ( ) ;
s - > PutCString ( " Specifier: \n " ) ;
s - > SetIndentLevel ( indent_level + 4 ) ;
m_specifier_sp - > GetDescription ( s , level ) ;
s - > SetIndentLevel ( indent_level + 2 ) ;
}
if ( m_thread_spec_ap . get ( ) ! = NULL )
{
StreamString tmp ;
s - > Indent ( " Thread: \n " ) ;
m_thread_spec_ap - > GetDescription ( & tmp , level ) ;
s - > SetIndentLevel ( indent_level + 4 ) ;
s - > Indent ( tmp . GetData ( ) ) ;
s - > PutCString ( " \n " ) ;
s - > SetIndentLevel ( indent_level + 2 ) ;
}
s - > Indent ( " Commands: \n " ) ;
s - > SetIndentLevel ( indent_level + 4 ) ;
uint32_t num_commands = m_commands . GetSize ( ) ;
for ( uint32_t i = 0 ; i < num_commands ; i + + )
{
s - > Indent ( m_commands . GetStringAtIndex ( i ) ) ;
s - > PutCString ( " \n " ) ;
}
s - > SetIndentLevel ( indent_level ) ;
}
2012-08-23 01:17:09 +08:00
//--------------------------------------------------------------
// class TargetProperties
//--------------------------------------------------------------
2010-09-21 04:44:43 +08:00
2012-08-23 01:17:09 +08:00
OptionEnumValueElement
lldb_private : : g_dynamic_value_types [ ] =
{
{ eNoDynamicValues , " no-dynamic-values " , " Don't calculate the dynamic type of values " } ,
{ eDynamicCanRunTarget , " run-target " , " Calculate the dynamic type of values even if you have to run the target. " } ,
{ eDynamicDontRunTarget , " no-run-target " , " Calculate the dynamic type of values, but don't run the target. " } ,
{ 0 , NULL , NULL }
} ;
2011-02-18 09:44:25 +08:00
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
static OptionEnumValueElement
g_inline_breakpoint_enums [ ] =
{
{ eInlineBreakpointsNever , " never " , " Never look for inline breakpoint locations (fastest). This setting should only be used if you know that no inlining occurs in your programs. " } ,
{ eInlineBreakpointsHeaders , " headers " , " Only check for inline breakpoint locations when setting breakpoints in header files, but not when setting breakpoint in implementation source files (default). " } ,
{ eInlineBreakpointsAlways , " always " , " Always look for inline breakpoint locations when setting file and line breakpoints (slower but most accurate). " } ,
{ 0 , NULL , NULL }
} ;
2013-03-02 08:26:47 +08:00
typedef enum x86DisassemblyFlavor
{
eX86DisFlavorDefault ,
eX86DisFlavorIntel ,
eX86DisFlavorATT
} x86DisassemblyFlavor ;
static OptionEnumValueElement
g_x86_dis_flavor_value_types [ ] =
{
{ eX86DisFlavorDefault , " default " , " Disassembler default (currently att). " } ,
{ eX86DisFlavorIntel , " intel " , " Intel disassembler flavor. " } ,
{ eX86DisFlavorATT , " att " , " AT&T disassembler flavor. " } ,
{ 0 , NULL , NULL }
} ;
2013-08-08 05:54:09 +08:00
static OptionEnumValueElement
g_hex_immediate_style_values [ ] =
{
{ Disassembler : : eHexStyleC , " c " , " C-style (0xffff). " } ,
{ Disassembler : : eHexStyleAsm , " asm " , " Asm-style (0ffffh). " } ,
{ 0 , NULL , NULL }
} ;
2013-05-22 04:13:34 +08:00
static OptionEnumValueElement
g_load_script_from_sym_file_values [ ] =
{
{ eLoadScriptFromSymFileTrue , " true " , " Load debug scripts inside symbol files " } ,
{ eLoadScriptFromSymFileFalse , " false " , " Do not load debug scripts inside symbol files. " } ,
{ eLoadScriptFromSymFileWarn , " warn " , " Warn about debug scripts inside symbol files but do not load them. " } ,
{ 0 , NULL , NULL }
} ;
2013-08-13 09:42:25 +08:00
static OptionEnumValueElement
g_memory_module_load_level_values [ ] =
{
2013-08-14 05:32:34 +08:00
{ eMemoryModuleLoadLevelMinimal , " minimal " , " Load minimal information when loading modules from memory. Currently this setting loads sections only. " } ,
2013-08-13 09:42:25 +08:00
{ eMemoryModuleLoadLevelPartial , " partial " , " Load partial information when loading modules from memory. Currently this setting loads sections and function bounds. " } ,
{ eMemoryModuleLoadLevelComplete , " complete " , " Load complete information when loading modules from memory. Currently this setting loads sections and all symbols. " } ,
{ 0 , NULL , NULL }
} ;
2012-08-23 01:17:09 +08:00
static PropertyDefinition
g_properties [ ] =
{
{ " default-arch " , OptionValue : : eTypeArch , true , 0 , NULL , NULL , " Default architecture to choose, when there's a choice. " } ,
2015-05-18 21:41:01 +08:00
{ " move-to-nearest-code " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Move breakpoints to nearest code. " } ,
2015-07-31 06:10:08 +08:00
{ " language " , OptionValue : : eTypeLanguage , false , eLanguageTypeUnknown , NULL , NULL , " The language to use when interpreting expressions entered in commands. " } ,
2012-08-23 01:17:09 +08:00
{ " expr-prefix " , OptionValue : : eTypeFileSpec , false , 0 , NULL , NULL , " Path to a file containing expressions to be prepended to all expressions. " } ,
2015-01-09 08:47:24 +08:00
{ " prefer-dynamic-value " , OptionValue : : eTypeEnum , false , eDynamicDontRunTarget , NULL , g_dynamic_value_types , " Should printed values be shown as their dynamic value. " } ,
2012-08-23 01:17:09 +08:00
{ " enable-synthetic-value " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Should synthetic values be used by default whenever available. " } ,
{ " skip-prologue " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Skip function prologues when setting breakpoints by name. " } ,
2015-09-16 02:03:00 +08:00
{ " source-map " , OptionValue : : eTypePathMap , false , 0 , NULL , NULL , " Source path remappings are used to track the change of location between a source file when built, and "
2012-08-23 01:17:09 +08:00
" where it exists on the current system. It consists of an array of duples, the first element of each duple is "
" some part (starting at the root) of the path to the file when it was built, "
" and the second is where the remainder of the original build hierarchy is rooted on the local system. "
" Each element of the array is checked in order and the first one that results in a match wins. " } ,
{ " exec-search-paths " , OptionValue : : eTypeFileSpecList , false , 0 , NULL , NULL , " Executable search paths to use when locating executable files whose paths don't match the local file system. " } ,
2013-07-02 03:45:50 +08:00
{ " debug-file-search-paths " , OptionValue : : eTypeFileSpecList , false , 0 , NULL , NULL , " List of directories to be searched when locating debug symbol files. " } ,
2015-04-03 23:39:47 +08:00
{ " clang-module-search-paths " , OptionValue : : eTypeFileSpecList , false , 0 , NULL , NULL , " List of directories to be searched when locating modules for Clang. " } ,
2015-04-21 00:31:29 +08:00
{ " auto-import-clang-modules " , OptionValue : : eTypeBoolean , false , false , NULL , NULL , " Automatically load Clang modules referred to by the program. " } ,
2012-08-23 01:17:09 +08:00
{ " max-children-count " , OptionValue : : eTypeSInt64 , false , 256 , NULL , NULL , " Maximum number of children to expand in any level of depth. " } ,
{ " max-string-summary-length " , OptionValue : : eTypeSInt64 , false , 1024 , NULL , NULL , " Maximum number of characters to show when using %s in summary strings. " } ,
2013-06-05 06:54:16 +08:00
{ " max-memory-read-size " , OptionValue : : eTypeSInt64 , false , 1024 , NULL , NULL , " Maximum number of bytes that 'memory read' will fetch before --force must be specified. " } ,
2012-08-23 01:17:09 +08:00
{ " breakpoints-use-platform-avoid-list " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Consult the platform module avoid list when setting non-module specific breakpoints. " } ,
2012-10-18 06:57:12 +08:00
{ " arg0 " , OptionValue : : eTypeString , false , 0 , NULL , NULL , " The first argument passed to the program in the argument array which can be different from the executable itself. " } ,
{ " run-args " , OptionValue : : eTypeArgs , false , 0 , NULL , NULL , " A list containing all the arguments to be passed to the executable when it is run. Note that this does NOT include the argv[0] which is in target.arg0. " } ,
2012-08-23 01:17:09 +08:00
{ " env-vars " , OptionValue : : eTypeDictionary , false , OptionValue : : eTypeString , NULL , NULL , " A list of all the environment variables to be passed to the executable's environment, and their values. " } ,
{ " inherit-env " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Inherit the environment from the process that is running LLDB. " } ,
{ " input-path " , OptionValue : : eTypeFileSpec , false , 0 , NULL , NULL , " The file/path to be used by the executable program for reading its standard input. " } ,
{ " output-path " , OptionValue : : eTypeFileSpec , false , 0 , NULL , NULL , " The file/path to be used by the executable program for writing its standard output. " } ,
{ " error-path " , OptionValue : : eTypeFileSpec , false , 0 , NULL , NULL , " The file/path to be used by the executable program for writing its standard error. " } ,
2014-06-25 10:32:56 +08:00
{ " detach-on-error " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " debugserver will detach (rather than killing) a process if it loses connection with lldb. " } ,
2012-08-23 01:17:09 +08:00
{ " disable-aslr " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Disable Address Space Layout Randomization (ASLR) " } ,
{ " disable-stdio " , OptionValue : : eTypeBoolean , false , false , NULL , NULL , " Disable stdin/stdout for process (e.g. for a GUI application) " } ,
2014-09-25 03:59:13 +08:00
{ " inline-breakpoint-strategy " , OptionValue : : eTypeEnum , false , eInlineBreakpointsAlways , NULL , g_inline_breakpoint_enums , " The strategy to use when settings breakpoints by file and line. "
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
" Breakpoint locations can end up being inlined by the compiler, so that a compile unit 'a.c' might contain an inlined function from another source file. "
2015-06-17 05:39:56 +08:00
" Usually this is limited to breakpoint locations from inlined functions from header or other include files, or more accurately non-implementation source files. "
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
" Sometimes code might #include implementation files and cause inlined breakpoint locations in inlined implementation files. "
2014-09-25 03:59:13 +08:00
" Always checking for inlined breakpoint locations can be expensive (memory and time), so if you have a project with many headers "
" and find that setting breakpoints is slow, then you can change this setting to headers. "
" This setting allows you to control exactly which strategy is used when setting "
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
" file and line breakpoints. " } ,
2013-03-02 08:26:47 +08:00
// FIXME: This is the wrong way to do per-architecture settings, but we don't have a general per architecture settings system in place yet.
{ " x86-disassembly-flavor " , OptionValue : : eTypeEnum , false , eX86DisFlavorDefault , NULL , g_x86_dis_flavor_value_types , " The default disassembly flavor to use for x86 or x86-64 targets. " } ,
2013-08-08 05:54:09 +08:00
{ " use-hex-immediates " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Show immediates in disassembly as hexadecimal. " } ,
{ " hex-immediate-style " , OptionValue : : eTypeEnum , false , Disassembler : : eHexStyleC , NULL , g_hex_immediate_style_values , " Which style to use for printing hexadecimal disassembly values. " } ,
2013-04-04 09:38:54 +08:00
{ " use-fast-stepping " , OptionValue : : eTypeBoolean , false , true , NULL , NULL , " Use a fast stepping algorithm based on running from branch to branch rather than instruction single-stepping. " } ,
2013-05-22 04:13:34 +08:00
{ " load-script-from-symbol-file " , OptionValue : : eTypeEnum , false , eLoadScriptFromSymFileWarn , NULL , g_load_script_from_sym_file_values , " Allow LLDB to load scripting resources embedded in symbol files when available. " } ,
2013-08-14 05:32:34 +08:00
{ " memory-module-load-level " , OptionValue : : eTypeEnum , false , eMemoryModuleLoadLevelComplete , NULL , g_memory_module_load_level_values ,
" Loading modules from memory can be slow as reading the symbol tables and other data can take a long time depending on your connection to the debug target. "
" This setting helps users control how much information gets loaded when loading modules from memory. "
" 'complete' is the default value for this setting which will load all sections and symbols by reading them from memory (slowest, most accurate). "
" 'partial' will load sections and attempt to find function bounds without downloading the symbol table (faster, still accurate, missing symbol names). "
" 'minimal' is the fastest setting and will load section data with no symbols, but should rarely be used as stack frames in these memory regions will be inaccurate and not provide any context (fastest). " } ,
2013-12-07 05:59:52 +08:00
{ " display-expression-in-crashlogs " , OptionValue : : eTypeBoolean , false , false , NULL , NULL , " Expressions that crash will show up in crash logs if the host system supports executable specific crash log strings and this setting is set to true. " } ,
2014-02-14 13:06:49 +08:00
{ " trap-handler-names " , OptionValue : : eTypeArray , true , OptionValue : : eTypeString , NULL , NULL , " A list of trap handler function names, e.g. a common Unix user process one is _sigtramp. " } ,
2015-02-11 10:35:39 +08:00
{ " display-runtime-support-values " , OptionValue : : eTypeBoolean , false , false , NULL , NULL , " If true, LLDB will show variables that are meant to support the operation of a language's runtime support. " } ,
2015-05-13 17:18:18 +08:00
{ " non-stop-mode " , OptionValue : : eTypeBoolean , false , 0 , NULL , NULL , " Disable lock-step debugging, instead control threads independently. " } ,
2012-08-23 01:17:09 +08:00
{ NULL , OptionValue : : eTypeInvalid , false , 0 , NULL , NULL , NULL }
} ;
2015-02-11 10:35:39 +08:00
2012-08-23 01:17:09 +08:00
enum
{
ePropertyDefaultArch ,
2015-05-18 21:41:01 +08:00
ePropertyMoveToNearestCode ,
2015-07-22 06:05:07 +08:00
ePropertyLanguage ,
2012-08-23 01:17:09 +08:00
ePropertyExprPrefix ,
ePropertyPreferDynamic ,
ePropertyEnableSynthetic ,
ePropertySkipPrologue ,
ePropertySourceMap ,
ePropertyExecutableSearchPaths ,
2013-07-02 03:45:50 +08:00
ePropertyDebugFileSearchPaths ,
2015-04-03 23:39:47 +08:00
ePropertyClangModuleSearchPaths ,
2015-04-21 00:31:29 +08:00
ePropertyAutoImportClangModules ,
2012-08-23 01:17:09 +08:00
ePropertyMaxChildrenCount ,
ePropertyMaxSummaryLength ,
2013-06-05 06:54:16 +08:00
ePropertyMaxMemReadSize ,
2012-08-23 01:17:09 +08:00
ePropertyBreakpointUseAvoidList ,
2012-10-18 06:57:12 +08:00
ePropertyArg0 ,
2012-08-23 01:17:09 +08:00
ePropertyRunArgs ,
ePropertyEnvVars ,
ePropertyInheritEnv ,
ePropertyInputPath ,
ePropertyOutputPath ,
ePropertyErrorPath ,
2014-06-25 10:32:56 +08:00
ePropertyDetachOnError ,
2012-08-23 01:17:09 +08:00
ePropertyDisableASLR ,
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
ePropertyDisableSTDIO ,
2013-03-02 08:26:47 +08:00
ePropertyInlineStrategy ,
2013-03-14 01:58:04 +08:00
ePropertyDisassemblyFlavor ,
2013-08-08 05:54:09 +08:00
ePropertyUseHexImmediates ,
ePropertyHexImmediateStyle ,
2013-05-14 01:03:52 +08:00
ePropertyUseFastStepping ,
2013-05-21 08:00:30 +08:00
ePropertyLoadScriptFromSymbolFile ,
2013-12-07 05:59:52 +08:00
ePropertyMemoryModuleLoadLevel ,
2014-02-14 13:06:49 +08:00
ePropertyDisplayExpressionsInCrashlogs ,
2015-02-11 10:35:39 +08:00
ePropertyTrapHandlerNames ,
2015-05-13 17:18:18 +08:00
ePropertyDisplayRuntimeSupportValues ,
ePropertyNonStopModeEnabled
2012-08-23 01:17:09 +08:00
} ;
2011-02-18 09:44:25 +08:00
2012-08-23 01:17:09 +08:00
class TargetOptionValueProperties : public OptionValueProperties
2011-02-18 09:44:25 +08:00
{
2012-08-23 01:17:09 +08:00
public :
TargetOptionValueProperties ( const ConstString & name ) :
OptionValueProperties ( name ) ,
m_target ( NULL ) ,
m_got_host_env ( false )
{
}
2011-02-18 09:44:25 +08:00
2012-08-23 01:17:09 +08:00
// This constructor is used when creating TargetOptionValueProperties when it
// is part of a new lldb_private::Target instance. It will copy all current
// global property values as needed
TargetOptionValueProperties ( Target * target , const TargetPropertiesSP & target_properties_sp ) :
OptionValueProperties ( * target_properties_sp - > GetValueProperties ( ) ) ,
m_target ( target ) ,
m_got_host_env ( false )
{
}
2011-02-18 09:44:25 +08:00
2012-08-23 01:17:09 +08:00
virtual const Property *
GetPropertyAtIndex ( const ExecutionContext * exe_ctx , bool will_modify , uint32_t idx ) const
{
2014-07-02 05:22:11 +08:00
// When getting the value for a key from the target options, we will always
2012-08-23 01:17:09 +08:00
// try and grab the setting from the current target if there is one. Else we just
// use the one from this instance.
if ( idx = = ePropertyEnvVars )
GetHostEnvironmentIfNeeded ( ) ;
if ( exe_ctx )
{
Target * target = exe_ctx - > GetTargetPtr ( ) ;
if ( target )
{
TargetOptionValueProperties * target_properties = static_cast < TargetOptionValueProperties * > ( target - > GetValueProperties ( ) . get ( ) ) ;
if ( this ! = target_properties )
return target_properties - > ProtectedGetPropertyAtIndex ( idx ) ;
}
}
return ProtectedGetPropertyAtIndex ( idx ) ;
}
2013-05-21 06:29:23 +08:00
lldb : : TargetSP
GetTargetSP ( )
{
return m_target - > shared_from_this ( ) ;
}
2012-08-23 01:17:09 +08:00
protected :
void
GetHostEnvironmentIfNeeded ( ) const
{
if ( ! m_got_host_env )
{
if ( m_target )
{
m_got_host_env = true ;
const uint32_t idx = ePropertyInheritEnv ;
if ( GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) )
{
PlatformSP platform_sp ( m_target - > GetPlatform ( ) ) ;
if ( platform_sp )
{
StringList env ;
if ( platform_sp - > GetEnvironment ( env ) )
{
OptionValueDictionary * env_dict = GetPropertyAtIndexAsOptionValueDictionary ( NULL , ePropertyEnvVars ) ;
if ( env_dict )
{
const bool can_replace = false ;
const size_t envc = env . GetSize ( ) ;
for ( size_t idx = 0 ; idx < envc ; idx + + )
{
const char * env_entry = env . GetStringAtIndex ( idx ) ;
if ( env_entry )
{
const char * equal_pos = : : strchr ( env_entry , ' = ' ) ;
ConstString key ;
// It is ok to have environment variables with no values
const char * value = NULL ;
if ( equal_pos )
{
key . SetCStringWithLength ( env_entry , equal_pos - env_entry ) ;
if ( equal_pos [ 1 ] )
value = equal_pos + 1 ;
}
else
{
key . SetCString ( env_entry ) ;
}
// Don't allow existing keys to be replaced with ones we get from the platform environment
env_dict - > SetValueForKey ( key , OptionValueSP ( new OptionValueString ( value ) ) , can_replace ) ;
}
}
}
}
}
}
}
}
}
Target * m_target ;
mutable bool m_got_host_env ;
} ;
2011-04-16 08:01:13 +08:00
2013-11-21 05:07:01 +08:00
//----------------------------------------------------------------------
// TargetProperties
//----------------------------------------------------------------------
2012-08-23 01:17:09 +08:00
TargetProperties : : TargetProperties ( Target * target ) :
2015-02-13 22:31:06 +08:00
Properties ( ) ,
m_launch_info ( )
2012-03-27 10:35:13 +08:00
{
2012-08-23 01:17:09 +08:00
if ( target )
{
m_collection_sp . reset ( new TargetOptionValueProperties ( target , Target : : GetGlobalProperties ( ) ) ) ;
2015-02-13 22:31:06 +08:00
// Set callbacks to update launch_info whenever "settins set" updated any of these properties
m_collection_sp - > SetValueChangedCallback ( ePropertyArg0 , TargetProperties : : Arg0ValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyRunArgs , TargetProperties : : RunArgsValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyEnvVars , TargetProperties : : EnvVarsValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyInputPath , TargetProperties : : InputPathValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyOutputPath , TargetProperties : : OutputPathValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyErrorPath , TargetProperties : : ErrorPathValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyDetachOnError , TargetProperties : : DetachOnErrorValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyDisableASLR , TargetProperties : : DisableASLRValueChangedCallback , this ) ;
m_collection_sp - > SetValueChangedCallback ( ePropertyDisableSTDIO , TargetProperties : : DisableSTDIOValueChangedCallback , this ) ;
// Update m_launch_info once it was created
Arg0ValueChangedCallback ( this , NULL ) ;
RunArgsValueChangedCallback ( this , NULL ) ;
//EnvVarsValueChangedCallback(this, NULL); // FIXME: cause segfault in Target::GetPlatform()
InputPathValueChangedCallback ( this , NULL ) ;
OutputPathValueChangedCallback ( this , NULL ) ;
ErrorPathValueChangedCallback ( this , NULL ) ;
DetachOnErrorValueChangedCallback ( this , NULL ) ;
DisableASLRValueChangedCallback ( this , NULL ) ;
DisableSTDIOValueChangedCallback ( this , NULL ) ;
2012-08-23 01:17:09 +08:00
}
else
{
m_collection_sp . reset ( new TargetOptionValueProperties ( ConstString ( " target " ) ) ) ;
m_collection_sp - > Initialize ( g_properties ) ;
m_collection_sp - > AppendProperty ( ConstString ( " process " ) ,
ConstString ( " Settings specify to processes. " ) ,
true ,
Process : : GetGlobalProperties ( ) - > GetValueProperties ( ) ) ;
}
2015-02-13 22:31:06 +08:00
2012-03-27 10:35:13 +08:00
}
2012-08-23 01:17:09 +08:00
TargetProperties : : ~ TargetProperties ( )
2011-04-23 10:04:55 +08:00
{
}
2012-08-23 01:17:09 +08:00
ArchSpec
TargetProperties : : GetDefaultArchitecture ( ) const
2012-02-14 07:10:39 +08:00
{
2012-08-23 01:17:09 +08:00
OptionValueArch * value = m_collection_sp - > GetPropertyAtIndexAsOptionValueArch ( NULL , ePropertyDefaultArch ) ;
if ( value )
return value - > GetCurrentValue ( ) ;
return ArchSpec ( ) ;
2012-02-14 07:10:39 +08:00
}
2012-08-23 01:17:09 +08:00
void
TargetProperties : : SetDefaultArchitecture ( const ArchSpec & arch )
2011-04-22 11:55:06 +08:00
{
2012-08-23 01:17:09 +08:00
OptionValueArch * value = m_collection_sp - > GetPropertyAtIndexAsOptionValueArch ( NULL , ePropertyDefaultArch ) ;
if ( value )
return value - > SetCurrentValue ( arch , true ) ;
2011-04-22 11:55:06 +08:00
}
2015-05-18 21:41:01 +08:00
bool
TargetProperties : : GetMoveToNearestCode ( ) const
{
const uint32_t idx = ePropertyMoveToNearestCode ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
}
2012-08-23 01:17:09 +08:00
lldb : : DynamicValueType
TargetProperties : : GetPreferDynamicValue ( ) const
2011-08-12 10:00:06 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyPreferDynamic ;
return ( lldb : : DynamicValueType ) m_collection_sp - > GetPropertyAtIndexAsEnumeration ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
2011-08-12 10:00:06 +08:00
}
2011-04-22 11:55:06 +08:00
2015-05-16 02:40:24 +08:00
bool
TargetProperties : : SetPreferDynamicValue ( lldb : : DynamicValueType d )
{
const uint32_t idx = ePropertyPreferDynamic ;
return m_collection_sp - > SetPropertyAtIndexAsEnumeration ( NULL , idx , d ) ;
}
2012-08-23 01:17:09 +08:00
bool
TargetProperties : : GetDisableASLR ( ) const
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyDisableASLR ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
}
2011-04-22 11:55:06 +08:00
2012-08-23 01:17:09 +08:00
void
TargetProperties : : SetDisableASLR ( bool b )
2011-10-29 07:14:11 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyDisableASLR ;
m_collection_sp - > SetPropertyAtIndexAsBoolean ( NULL , idx , b ) ;
2011-10-29 07:14:11 +08:00
}
2014-06-25 10:32:56 +08:00
bool
TargetProperties : : GetDetachOnError ( ) const
{
const uint32_t idx = ePropertyDetachOnError ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
}
void
TargetProperties : : SetDetachOnError ( bool b )
{
const uint32_t idx = ePropertyDetachOnError ;
m_collection_sp - > SetPropertyAtIndexAsBoolean ( NULL , idx , b ) ;
}
2012-08-23 01:17:09 +08:00
bool
TargetProperties : : GetDisableSTDIO ( ) const
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyDisableSTDIO ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
2011-11-08 10:43:13 +08:00
}
2012-08-23 01:17:09 +08:00
void
TargetProperties : : SetDisableSTDIO ( bool b )
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyDisableSTDIO ;
m_collection_sp - > SetPropertyAtIndexAsBoolean ( NULL , idx , b ) ;
2011-11-08 10:43:13 +08:00
}
2013-03-02 08:26:47 +08:00
const char *
TargetProperties : : GetDisassemblyFlavor ( ) const
{
const uint32_t idx = ePropertyDisassemblyFlavor ;
const char * return_value ;
x86DisassemblyFlavor flavor_value = ( x86DisassemblyFlavor ) m_collection_sp - > GetPropertyAtIndexAsEnumeration ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
return_value = g_x86_dis_flavor_value_types [ flavor_value ] . string_value ;
return return_value ;
}
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
InlineStrategy
TargetProperties : : GetInlineStrategy ( ) const
{
const uint32_t idx = ePropertyInlineStrategy ;
return ( InlineStrategy ) m_collection_sp - > GetPropertyAtIndexAsEnumeration ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
}
2012-10-18 06:57:12 +08:00
const char *
TargetProperties : : GetArg0 ( ) const
{
const uint32_t idx = ePropertyArg0 ;
return m_collection_sp - > GetPropertyAtIndexAsString ( NULL , idx , NULL ) ;
}
void
TargetProperties : : SetArg0 ( const char * arg )
{
const uint32_t idx = ePropertyArg0 ;
m_collection_sp - > SetPropertyAtIndexAsString ( NULL , idx , arg ) ;
2015-03-26 08:15:24 +08:00
m_launch_info . SetArg0 ( arg ) ;
2012-10-18 06:57:12 +08:00
}
2012-08-23 01:17:09 +08:00
bool
TargetProperties : : GetRunArguments ( Args & args ) const
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyRunArgs ;
return m_collection_sp - > GetPropertyAtIndexAsArgs ( NULL , idx , args ) ;
2011-11-08 10:43:13 +08:00
}
2012-08-23 01:17:09 +08:00
void
TargetProperties : : SetRunArguments ( const Args & args )
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyRunArgs ;
m_collection_sp - > SetPropertyAtIndexFromArgs ( NULL , idx , args ) ;
2015-03-26 08:15:24 +08:00
m_launch_info . GetArguments ( ) = args ;
2011-11-08 10:43:13 +08:00
}
2012-08-23 01:17:09 +08:00
size_t
TargetProperties : : GetEnvironmentAsArgs ( Args & env ) const
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyEnvVars ;
return m_collection_sp - > GetPropertyAtIndexAsArgs ( NULL , idx , env ) ;
2011-11-08 10:43:13 +08:00
}
2015-02-13 22:31:06 +08:00
void
TargetProperties : : SetEnvironmentFromArgs ( const Args & env )
{
const uint32_t idx = ePropertyEnvVars ;
m_collection_sp - > SetPropertyAtIndexFromArgs ( NULL , idx , env ) ;
2015-03-26 08:15:24 +08:00
m_launch_info . GetEnvironmentEntries ( ) = env ;
2015-02-13 22:31:06 +08:00
}
2012-08-23 01:17:09 +08:00
bool
TargetProperties : : GetSkipPrologue ( ) const
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertySkipPrologue ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
2011-11-08 10:43:13 +08:00
}
2012-08-23 01:17:09 +08:00
PathMappingList &
TargetProperties : : GetSourcePathMap ( ) const
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertySourceMap ;
OptionValuePathMappings * option_value = m_collection_sp - > GetPropertyAtIndexAsOptionValuePathMappings ( NULL , false , idx ) ;
assert ( option_value ) ;
return option_value - > GetCurrentValue ( ) ;
2011-11-08 10:43:13 +08:00
}
2012-08-23 01:17:09 +08:00
FileSpecList &
2012-08-23 02:39:03 +08:00
TargetProperties : : GetExecutableSearchPaths ( )
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyExecutableSearchPaths ;
OptionValueFileSpecList * option_value = m_collection_sp - > GetPropertyAtIndexAsOptionValueFileSpecList ( NULL , false , idx ) ;
assert ( option_value ) ;
return option_value - > GetCurrentValue ( ) ;
2011-11-08 10:43:13 +08:00
}
2011-10-29 07:14:11 +08:00
2013-07-02 03:45:50 +08:00
FileSpecList &
TargetProperties : : GetDebugFileSearchPaths ( )
{
const uint32_t idx = ePropertyDebugFileSearchPaths ;
OptionValueFileSpecList * option_value = m_collection_sp - > GetPropertyAtIndexAsOptionValueFileSpecList ( NULL , false , idx ) ;
2015-04-03 23:39:47 +08:00
assert ( option_value ) ;
return option_value - > GetCurrentValue ( ) ;
}
FileSpecList &
TargetProperties : : GetClangModuleSearchPaths ( )
{
const uint32_t idx = ePropertyClangModuleSearchPaths ;
OptionValueFileSpecList * option_value = m_collection_sp - > GetPropertyAtIndexAsOptionValueFileSpecList ( NULL , false , idx ) ;
2013-07-02 03:45:50 +08:00
assert ( option_value ) ;
return option_value - > GetCurrentValue ( ) ;
}
2015-04-21 00:31:29 +08:00
bool
TargetProperties : : GetEnableAutoImportClangModules ( ) const
{
const uint32_t idx = ePropertyAutoImportClangModules ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
}
2010-09-21 04:44:43 +08:00
bool
2012-08-23 01:17:09 +08:00
TargetProperties : : GetEnableSyntheticValue ( ) const
2010-09-21 04:44:43 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyEnableSynthetic ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
2010-09-21 04:44:43 +08:00
}
2012-08-23 01:17:09 +08:00
uint32_t
TargetProperties : : GetMaximumNumberOfChildrenToDisplay ( ) const
2010-09-21 04:44:43 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyMaxChildrenCount ;
return m_collection_sp - > GetPropertyAtIndexAsSInt64 ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
2010-09-21 04:44:43 +08:00
}
2012-08-23 01:17:09 +08:00
uint32_t
TargetProperties : : GetMaximumSizeOfStringSummary ( ) const
{
const uint32_t idx = ePropertyMaxSummaryLength ;
return m_collection_sp - > GetPropertyAtIndexAsSInt64 ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
}
2010-09-21 04:44:43 +08:00
2013-06-05 06:54:16 +08:00
uint32_t
TargetProperties : : GetMaximumMemReadSize ( ) const
{
const uint32_t idx = ePropertyMaxMemReadSize ;
return m_collection_sp - > GetPropertyAtIndexAsSInt64 ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
}
2012-08-23 01:17:09 +08:00
FileSpec
TargetProperties : : GetStandardInputPath ( ) const
{
const uint32_t idx = ePropertyInputPath ;
return m_collection_sp - > GetPropertyAtIndexAsFileSpec ( NULL , idx ) ;
2010-09-21 04:44:43 +08:00
}
void
2012-08-23 01:17:09 +08:00
TargetProperties : : SetStandardInputPath ( const char * p )
{
const uint32_t idx = ePropertyInputPath ;
m_collection_sp - > SetPropertyAtIndexAsString ( NULL , idx , p ) ;
}
2011-04-23 10:04:55 +08:00
2012-08-23 01:17:09 +08:00
FileSpec
TargetProperties : : GetStandardOutputPath ( ) const
{
const uint32_t idx = ePropertyOutputPath ;
return m_collection_sp - > GetPropertyAtIndexAsFileSpec ( NULL , idx ) ;
2010-09-21 04:44:43 +08:00
}
void
2012-08-23 01:17:09 +08:00
TargetProperties : : SetStandardOutputPath ( const char * p )
2010-09-21 04:44:43 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyOutputPath ;
m_collection_sp - > SetPropertyAtIndexAsString ( NULL , idx , p ) ;
2010-09-21 04:44:43 +08:00
}
2012-08-23 01:17:09 +08:00
FileSpec
TargetProperties : : GetStandardErrorPath ( ) const
2010-09-21 04:44:43 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyErrorPath ;
return m_collection_sp - > GetPropertyAtIndexAsFileSpec ( NULL , idx ) ;
2010-09-21 04:44:43 +08:00
}
2015-07-22 06:05:07 +08:00
LanguageType
TargetProperties : : GetLanguage ( ) const
{
OptionValueLanguage * value = m_collection_sp - > GetPropertyAtIndexAsOptionValueLanguage ( NULL , ePropertyLanguage ) ;
if ( value )
return value - > GetCurrentValue ( ) ;
return LanguageType ( ) ;
}
2012-08-23 02:39:03 +08:00
const char *
TargetProperties : : GetExpressionPrefixContentsAsCString ( )
{
const uint32_t idx = ePropertyExprPrefix ;
OptionValueFileSpec * file = m_collection_sp - > GetPropertyAtIndexAsOptionValueFileSpec ( NULL , false , idx ) ;
if ( file )
2012-08-23 05:21:16 +08:00
{
2012-08-31 02:15:10 +08:00
const bool null_terminate = true ;
DataBufferSP data_sp ( file - > GetFileContents ( null_terminate ) ) ;
2012-08-23 05:21:16 +08:00
if ( data_sp )
return ( const char * ) data_sp - > GetBytes ( ) ;
}
2012-08-23 02:39:03 +08:00
return NULL ;
}
2011-11-08 10:43:13 +08:00
void
2012-08-23 01:17:09 +08:00
TargetProperties : : SetStandardErrorPath ( const char * p )
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyErrorPath ;
m_collection_sp - > SetPropertyAtIndexAsString ( NULL , idx , p ) ;
2011-11-08 10:43:13 +08:00
}
2012-08-23 01:17:09 +08:00
bool
TargetProperties : : GetBreakpointsConsultPlatformAvoidList ( )
2011-11-08 10:43:13 +08:00
{
2012-08-23 01:17:09 +08:00
const uint32_t idx = ePropertyBreakpointUseAvoidList ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
2011-11-08 10:43:13 +08:00
}
2013-08-08 05:54:09 +08:00
bool
TargetProperties : : GetUseHexImmediates ( ) const
{
const uint32_t idx = ePropertyUseHexImmediates ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
}
2013-03-14 01:58:04 +08:00
bool
TargetProperties : : GetUseFastStepping ( ) const
{
const uint32_t idx = ePropertyUseFastStepping ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
}
2013-12-07 05:59:52 +08:00
bool
TargetProperties : : GetDisplayExpressionsInCrashlogs ( ) const
{
const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , g_properties [ idx ] . default_uint_value ! = 0 ) ;
}
2013-05-22 04:13:34 +08:00
LoadScriptFromSymFile
2013-05-14 01:03:52 +08:00
TargetProperties : : GetLoadScriptFromSymbolFile ( ) const
{
const uint32_t idx = ePropertyLoadScriptFromSymbolFile ;
2013-05-22 04:13:34 +08:00
return ( LoadScriptFromSymFile ) m_collection_sp - > GetPropertyAtIndexAsEnumeration ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
2013-05-14 01:03:52 +08:00
}
2013-08-08 05:54:09 +08:00
Disassembler : : HexImmediateStyle
TargetProperties : : GetHexImmediateStyle ( ) const
{
const uint32_t idx = ePropertyHexImmediateStyle ;
return ( Disassembler : : HexImmediateStyle ) m_collection_sp - > GetPropertyAtIndexAsEnumeration ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
}
2013-08-13 09:42:25 +08:00
MemoryModuleLoadLevel
TargetProperties : : GetMemoryModuleLoadLevel ( ) const
{
const uint32_t idx = ePropertyMemoryModuleLoadLevel ;
return ( MemoryModuleLoadLevel ) m_collection_sp - > GetPropertyAtIndexAsEnumeration ( NULL , idx , g_properties [ idx ] . default_uint_value ) ;
}
2014-02-14 13:06:49 +08:00
bool
TargetProperties : : GetUserSpecifiedTrapHandlerNames ( Args & args ) const
{
const uint32_t idx = ePropertyTrapHandlerNames ;
return m_collection_sp - > GetPropertyAtIndexAsArgs ( NULL , idx , args ) ;
}
2013-08-13 09:42:25 +08:00
2014-02-14 13:06:49 +08:00
void
TargetProperties : : SetUserSpecifiedTrapHandlerNames ( const Args & args )
{
const uint32_t idx = ePropertyTrapHandlerNames ;
m_collection_sp - > SetPropertyAtIndexFromArgs ( NULL , idx , args ) ;
}
2010-09-21 04:44:43 +08:00
2015-02-11 10:35:39 +08:00
bool
TargetProperties : : GetDisplayRuntimeSupportValues ( ) const
{
const uint32_t idx = ePropertyDisplayRuntimeSupportValues ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , false ) ;
}
void
TargetProperties : : SetDisplayRuntimeSupportValues ( bool b )
{
const uint32_t idx = ePropertyDisplayRuntimeSupportValues ;
m_collection_sp - > SetPropertyAtIndexAsBoolean ( NULL , idx , b ) ;
}
2015-05-13 17:18:18 +08:00
bool
TargetProperties : : GetNonStopModeEnabled ( ) const
{
const uint32_t idx = ePropertyNonStopModeEnabled ;
return m_collection_sp - > GetPropertyAtIndexAsBoolean ( NULL , idx , false ) ;
}
2015-06-24 23:14:26 +08:00
void
TargetProperties : : SetNonStopModeEnabled ( bool b )
{
const uint32_t idx = ePropertyNonStopModeEnabled ;
m_collection_sp - > SetPropertyAtIndexAsBoolean ( NULL , idx , b ) ;
}
2015-02-13 22:31:06 +08:00
const ProcessLaunchInfo &
2015-02-14 01:07:55 +08:00
TargetProperties : : GetProcessLaunchInfo ( )
2015-02-13 22:31:06 +08:00
{
2015-02-14 01:07:55 +08:00
m_launch_info . SetArg0 ( GetArg0 ( ) ) ; // FIXME: Arg0 callback doesn't work
2015-02-13 22:31:06 +08:00
return m_launch_info ;
}
void
TargetProperties : : SetProcessLaunchInfo ( const ProcessLaunchInfo & launch_info )
{
m_launch_info = launch_info ;
SetArg0 ( launch_info . GetArg0 ( ) ) ;
SetRunArguments ( launch_info . GetArguments ( ) ) ;
SetEnvironmentFromArgs ( launch_info . GetEnvironmentEntries ( ) ) ;
const FileAction * input_file_action = launch_info . GetFileActionForFD ( STDIN_FILENO ) ;
if ( input_file_action )
{
const char * input_path = input_file_action - > GetPath ( ) ;
if ( input_path )
SetStandardInputPath ( input_path ) ;
}
const FileAction * output_file_action = launch_info . GetFileActionForFD ( STDOUT_FILENO ) ;
if ( output_file_action )
{
const char * output_path = output_file_action - > GetPath ( ) ;
if ( output_path )
SetStandardOutputPath ( output_path ) ;
}
const FileAction * error_file_action = launch_info . GetFileActionForFD ( STDERR_FILENO ) ;
if ( error_file_action )
{
const char * error_path = error_file_action - > GetPath ( ) ;
if ( error_path )
SetStandardErrorPath ( error_path ) ;
}
SetDetachOnError ( launch_info . GetFlags ( ) . Test ( lldb : : eLaunchFlagDetachOnError ) ) ;
SetDisableASLR ( launch_info . GetFlags ( ) . Test ( lldb : : eLaunchFlagDisableASLR ) ) ;
SetDisableSTDIO ( launch_info . GetFlags ( ) . Test ( lldb : : eLaunchFlagDisableSTDIO ) ) ;
}
void
TargetProperties : : Arg0ValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
this_ - > m_launch_info . SetArg0 ( this_ - > GetArg0 ( ) ) ;
}
void
TargetProperties : : RunArgsValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
Args args ;
if ( this_ - > GetRunArguments ( args ) )
this_ - > m_launch_info . GetArguments ( ) = args ;
}
void
TargetProperties : : EnvVarsValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
Args args ;
if ( this_ - > GetEnvironmentAsArgs ( args ) )
this_ - > m_launch_info . GetEnvironmentEntries ( ) = args ;
}
void
TargetProperties : : InputPathValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
2015-05-30 03:52:29 +08:00
this_ - > m_launch_info . AppendOpenFileAction ( STDIN_FILENO , this_ - > GetStandardInputPath ( ) , true , false ) ;
2015-02-13 22:31:06 +08:00
}
void
TargetProperties : : OutputPathValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
2015-05-30 03:52:29 +08:00
this_ - > m_launch_info . AppendOpenFileAction ( STDOUT_FILENO , this_ - > GetStandardOutputPath ( ) , false , true ) ;
2015-02-13 22:31:06 +08:00
}
void
TargetProperties : : ErrorPathValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
2015-05-30 03:52:29 +08:00
this_ - > m_launch_info . AppendOpenFileAction ( STDERR_FILENO , this_ - > GetStandardErrorPath ( ) , false , true ) ;
2015-02-13 22:31:06 +08:00
}
void
TargetProperties : : DetachOnErrorValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
if ( this_ - > GetDetachOnError ( ) )
this_ - > m_launch_info . GetFlags ( ) . Set ( lldb : : eLaunchFlagDetachOnError ) ;
else
this_ - > m_launch_info . GetFlags ( ) . Clear ( lldb : : eLaunchFlagDetachOnError ) ;
}
void
TargetProperties : : DisableASLRValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
if ( this_ - > GetDisableASLR ( ) )
this_ - > m_launch_info . GetFlags ( ) . Set ( lldb : : eLaunchFlagDisableASLR ) ;
else
this_ - > m_launch_info . GetFlags ( ) . Clear ( lldb : : eLaunchFlagDisableASLR ) ;
}
void
TargetProperties : : DisableSTDIOValueChangedCallback ( void * target_property_ptr , OptionValue * )
{
TargetProperties * this_ = reinterpret_cast < TargetProperties * > ( target_property_ptr ) ;
if ( this_ - > GetDisableSTDIO ( ) )
this_ - > m_launch_info . GetFlags ( ) . Set ( lldb : : eLaunchFlagDisableSTDIO ) ;
else
this_ - > m_launch_info . GetFlags ( ) . Clear ( lldb : : eLaunchFlagDisableSTDIO ) ;
}
Add =shlibs-added/=shlibs-removed notifications (MI)
Summary:
This patch adds =shlibs-added/=shlibs-removed notifications in lldb-mi. In more detail:
# Add Target::ModulesDidLoad/ModulesDidUnload notifications
# Improve Target::TargetEventData:
## Refactoring
## Move it back to include/lldb/Target/Target.h
## Add Target::{GetModuleListFromEvent,GetModuleList}; Add Target::m_module_list
# Add SBModule::{GetSymbolVendorMainFileSpec,GetObjectFileHeaderAddress}
# Add SBTarget::{EventIsTaretEvent,GetTargetFromEvent,GetNumModulesFromEvent,GetModuleAtIndexFromEvent}
All tests pass on OS X.
Reviewers: abidh, zturner, jingham, clayborg
Reviewed By: clayborg
Subscribers: jingham, zturner, lldb-commits, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D8201
llvm-svn: 231858
2015-03-11 05:59:55 +08:00
//----------------------------------------------------------------------
// Target::TargetEventData
//----------------------------------------------------------------------
Target : : TargetEventData : : TargetEventData ( const lldb : : TargetSP & target_sp ) :
EventData ( ) ,
m_target_sp ( target_sp ) ,
m_module_list ( )
{
}
Target : : TargetEventData : : TargetEventData ( const lldb : : TargetSP & target_sp , const ModuleList & module_list ) :
EventData ( ) ,
m_target_sp ( target_sp ) ,
m_module_list ( module_list )
{
}
Target : : TargetEventData : : ~ TargetEventData ( )
{
}
const ConstString &
Target : : TargetEventData : : GetFlavorString ( )
{
static ConstString g_flavor ( " Target::TargetEventData " ) ;
return g_flavor ;
}
void
Target : : TargetEventData : : Dump ( Stream * s ) const
{
}
const Target : : TargetEventData *
Target : : TargetEventData : : GetEventDataFromEvent ( const Event * event_ptr )
{
if ( event_ptr )
{
const EventData * event_data = event_ptr - > GetData ( ) ;
if ( event_data & & event_data - > GetFlavor ( ) = = TargetEventData : : GetFlavorString ( ) )
return static_cast < const TargetEventData * > ( event_ptr - > GetData ( ) ) ;
}
return NULL ;
}
TargetSP
Target : : TargetEventData : : GetTargetFromEvent ( const Event * event_ptr )
{
TargetSP target_sp ;
const TargetEventData * event_data = GetEventDataFromEvent ( event_ptr ) ;
if ( event_data )
target_sp = event_data - > m_target_sp ;
return target_sp ;
}
ModuleList
Target : : TargetEventData : : GetModuleListFromEvent ( const Event * event_ptr )
{
ModuleList module_list ;
const TargetEventData * event_data = GetEventDataFromEvent ( event_ptr ) ;
if ( event_data )
module_list = event_data - > m_module_list ;
return module_list ;
}