[Lldb-commits] [lldb] r166262 - in /lldb/trunk: include/lldb/Core/Stream.h include/lldb/Target/Target.h source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h source/Target/Target.cpp
Jason Molenda
jmolenda at apple.com
Thu Oct 18 20:40:46 PDT 2012
Author: jmolenda
Date: Thu Oct 18 22:40:45 2012
New Revision: 166262
URL: http://llvm.org/viewvc/llvm-project?rev=166262&view=rev
Log:
Add a new target setting to disable automatic loading of kext images
in a kernel debug session:
settings set target.disable-kext-loading true
<rdar://problem/12490623>
Modified:
lldb/trunk/include/lldb/Core/Stream.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
lldb/trunk/source/Target/Target.cpp
Modified: lldb/trunk/include/lldb/Core/Stream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Stream.h?rev=166262&r1=166261&r2=166262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Stream.h (original)
+++ lldb/trunk/include/lldb/Core/Stream.h Thu Oct 18 22:40:45 2012
@@ -179,7 +179,7 @@
int
PutPointer (void *ptr);
- // Append \a src_len bytes from \a s to the stream as hex characters
+ // Append \a src_len bytes from \a src to the stream as hex characters
// (two ascii characters per byte of input data)
int
PutBytesAsRawHex8 (const void *src,
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=166262&r1=166261&r2=166262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Thu Oct 18 22:40:45 2012
@@ -139,6 +139,12 @@
const char *
GetExpressionPrefixContentsAsCString ();
+
+ bool
+ GetDisableKextLoading () const;
+
+ void
+ SetDisableKextLoading (bool b);
};
typedef STD_SHARED_PTR(TargetProperties) TargetPropertiesSP;
Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=166262&r1=166261&r2=166262&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Thu Oct 18 22:40:45 2012
@@ -188,7 +188,14 @@
Target &target = process->GetTarget();
ModuleSP memory_module_sp;
- // Use the memory module as the module if we have one...
+
+ // If this is a kext and the user asked us to ignore kexts, don't try to load it.
+ if (kernel_image == false && target.GetDisableKextLoading() == true)
+ {
+ return false;
+ }
+
+ // Use the memory module as the module if we have one
if (address != LLDB_INVALID_ADDRESS)
{
FileSpec file_spec;
@@ -395,6 +402,7 @@
{
m_kernel.Clear(false);
m_kernel.module_sp = m_process->GetTarget().GetExecutableModule();
+ m_kernel.kernel_image = true;
ConstString kernel_name("mach_kernel");
if (m_kernel.module_sp.get()
Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h?rev=166262&r1=166261&r2=166262&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h Thu Oct 18 22:40:45 2012
@@ -136,7 +136,7 @@
char name[KERNEL_MODULE_MAX_NAME];
lldb::ModuleSP module_sp;
uint32_t load_process_stop_id;
- lldb_private::UUID uuid; // UUID for this dylib if it has one, else all zeros
+ lldb_private::UUID uuid; // UUID for this dylib if it has one, else all zeros
lldb_private::Address so_address; // The section offset address for this kext in case it can be read from object files
uint64_t address;
uint64_t size;
@@ -144,6 +144,7 @@
uint32_t load_tag;
uint32_t flags;
uint64_t reference_list;
+ bool kernel_image; // true if this is the kernel, false if this is a kext
OSKextLoadedKextSummary() :
module_sp (),
@@ -155,7 +156,8 @@
version (0),
load_tag (0),
flags (0),
- reference_list (0)
+ reference_list (0),
+ kernel_image (false)
{
name[0] = '\0';
}
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=166262&r1=166261&r2=166262&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Oct 18 22:40:45 2012
@@ -2167,6 +2167,7 @@
"Always checking for inlined breakpoint locations can be expensive (memory and time), so we try to minimize the "
"times we look for inlined locations. This setting allows you to control exactly which strategy is used when settings "
"file and line breakpoints." },
+ { "disable-kext-loading" , OptionValue::eTypeBoolean , false, false , NULL, NULL, "Disable kext image loading in a Darwin kernel debug session" },
{ NULL , OptionValue::eTypeInvalid , false, 0 , NULL, NULL, NULL }
};
enum
@@ -2190,7 +2191,8 @@
ePropertyErrorPath,
ePropertyDisableASLR,
ePropertyDisableSTDIO,
- ePropertyInlineStrategy
+ ePropertyInlineStrategy,
+ ePropertyDisableKextLoading
};
@@ -2518,6 +2520,20 @@
return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
}
+bool
+TargetProperties::GetDisableKextLoading () const
+{
+ const uint32_t idx = ePropertyDisableKextLoading;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
+}
+
+void
+TargetProperties::SetDisableKextLoading (bool b)
+{
+ const uint32_t idx = ePropertyDisableKextLoading;
+ m_collection_sp->SetPropertyAtIndexAsBoolean (NULL, idx, b);
+}
+
const TargetPropertiesSP &
Target::GetGlobalProperties()
{
More information about the lldb-commits
mailing list