[Lldb-commits] [lldb] r137536 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectRegister.h include/lldb/Interpreter/CommandInterpreter.h source/API/SBDebugger.cpp source/API/SBError.cpp source/API/SBValue.cpp source/Breakpoint/BreakpointSite.cpp source/Core/ValueObject.cpp source/Core/ValueObjectChild.cpp source/Core/ValueObjectRegister.cpp source/Interpreter/CommandInterpreter.cpp source/Target/ThreadPlanCallFunction.cpp
Jim Ingham
jingham at apple.com
Fri Aug 12 16:34:31 PDT 2011
Author: jingham
Date: Fri Aug 12 18:34:31 2011
New Revision: 137536
URL: http://llvm.org/viewvc/llvm-project?rev=137536&view=rev
Log:
Make ValueObject::SetValueFromCString work correctly.
Also change the SourceInitFile to look for .lldb-<APPNAME> and source that
preferentially if it exists.
Also made the breakpoint site report its address as well as its breakpoint number
when it gets hit and can't find any the associated locations (usually because the
breakpoint got disabled or deleted programmatically between the time it was hit
and reported.)
Changed ThreadPlanCallFunction to initialize the ivar m_func in the initializers of the
constructor, rather than waiting to initialize till later on in the function.
Fixed a bug where if you make an SBError and the ask it Success, it returns false.
Fixed ValueObject::ResolveValue so that it resolves a temporary value, rather than
overwriting the one in the value object.
Modified:
lldb/trunk/include/lldb/API/SBDebugger.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectRegister.h
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBError.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Breakpoint/BreakpointSite.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectChild.cpp
lldb/trunk/source/Core/ValueObjectRegister.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Aug 12 18:34:31 2011
@@ -55,6 +55,9 @@
SkipLLDBInitFiles (bool b);
void
+ SkipAppInitFiles (bool b);
+
+ void
SetInputFileHandle (FILE *f, bool transfer_ownership);
void
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Aug 12 18:34:31 2011
@@ -343,6 +343,9 @@
return m_update_point.GetExecutionContextScope();
}
+ void
+ SetNeedsUpdate ();
+
virtual ~ValueObject();
//------------------------------------------------------------------
@@ -543,9 +546,6 @@
DataExtractor &
GetDataExtractor ();
- bool
- Write ();
-
lldb::ValueObjectSP
GetSP ()
{
Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Fri Aug 12 18:34:31 2011
@@ -156,6 +156,9 @@
virtual uint32_t
CalculateNumChildren();
+
+ virtual bool
+ SetValueFromCString (const char *value_str);
protected:
virtual bool
Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Fri Aug 12 18:34:31 2011
@@ -346,6 +346,12 @@
m_skip_lldbinit_files = skip_lldbinit_files;
}
+ void
+ SkipAppInitFiles (bool skip_app_init_files)
+ {
+ m_skip_app_init_files = m_skip_lldbinit_files;
+ }
+
bool
GetSynchronous ();
@@ -433,6 +439,7 @@
ExecutionContext m_exe_ctx; // The current execution context to use when handling commands
bool m_synchronous_execution;
bool m_skip_lldbinit_files;
+ bool m_skip_app_init_files;
CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten).
CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands
CommandObject::CommandMap m_user_dict; // Stores user-defined commands
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Fri Aug 12 18:34:31 2011
@@ -149,6 +149,13 @@
m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b);
}
+void
+SBDebugger::SkipAppInitFiles (bool b)
+{
+ if (m_opaque_sp)
+ m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles (b);
+}
+
// Shouldn't really be settable after initialization as this could cause lots of problems; don't want users
// trying to switch modes in the middle of a debugging session.
void
Modified: lldb/trunk/source/API/SBError.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBError.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/API/SBError.cpp (original)
+++ lldb/trunk/source/API/SBError.cpp Fri Aug 12 18:34:31 2011
@@ -86,7 +86,7 @@
SBError::Success () const
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- bool ret_value = false;
+ bool ret_value = true;
if (m_opaque_ap.get())
ret_value = m_opaque_ap->Success();
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Fri Aug 12 18:34:31 2011
@@ -629,6 +629,7 @@
int64_t
SBValue::GetValueAsSigned(SBError& error, int64_t fail_value)
{
+ error.Clear();
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
@@ -650,6 +651,7 @@
uint64_t
SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value)
{
+ error.Clear();
if (m_opaque_sp)
{
if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Modified: lldb/trunk/source/Breakpoint/BreakpointSite.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointSite.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointSite.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointSite.cpp Fri Aug 12 18:34:31 2011
@@ -95,7 +95,7 @@
BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
if (level != lldb::eDescriptionLevelBrief)
- s->Printf ("breakpoint site: %d ", GetID());
+ s->Printf ("breakpoint site: %d at 0x%8.8llx", GetID(), GetLoadAddress());
m_owners.GetDescription (s, level);
}
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Aug 12 18:34:31 2011
@@ -252,6 +252,15 @@
}
}
+void
+ValueObject::SetNeedsUpdate ()
+{
+ m_update_point.SetNeedsUpdate();
+ // We have to clear the value string here so ConstResult children will notice if their values are
+ // changed by hand (i.e. with SetValueAsCString).
+ m_value_str.clear();
+}
+
DataExtractor &
ValueObject::GetDataExtractor ()
{
@@ -338,7 +347,8 @@
ExecutionContextScope *exe_scope = GetExecutionContextScope();
if (exe_scope)
exe_scope->CalculateExecutionContext(exe_ctx);
- scalar = m_value.ResolveValue(&exe_ctx, GetClangAST ());
+ Value tmp_value(m_value);
+ scalar = tmp_value.ResolveValue(&exe_ctx, GetClangAST ());
return scalar.IsValid();
}
else
@@ -1220,104 +1230,83 @@
uint32_t count = 0;
lldb::Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count);
- char *end = NULL;
const size_t byte_size = GetByteSize();
- switch (encoding)
- {
- case eEncodingInvalid:
- return false;
- case eEncodingUint:
- if (byte_size > sizeof(unsigned long long))
- {
- return false;
- }
- else
+ Value::ValueType value_type = m_value.GetValueType();
+
+ if (value_type == Value::eValueTypeScalar)
+ {
+ // If the value is already a scalar, then let the scalar change itself:
+ m_value.GetScalar().SetValueFromCString (value_str, encoding, byte_size);
+ }
+ else if (byte_size <= Scalar::GetMaxByteSize())
+ {
+ // If the value fits in a scalar, then make a new scalar and again let the
+ // scalar code do the conversion, then figure out where to put the new value.
+ Scalar new_scalar;
+ Error error;
+ error = new_scalar.SetValueFromCString (value_str, encoding, byte_size);
+ if (error.Success())
{
- unsigned long long ull_val = strtoull(value_str, &end, 0);
- if (end && *end != '\0')
- return false;
- Value::ValueType value_type = m_value.GetValueType();
switch (value_type)
{
- case Value::eValueTypeLoadAddress:
- case Value::eValueTypeHostAddress:
- // The value in these cases lives in the data. So update the data:
-
- break;
- case Value::eValueTypeScalar:
- m_value.GetScalar() = ull_val;
+ case Value::eValueTypeLoadAddress:
+ {
+ // If it is a load address, then the scalar value is the storage location
+ // of the data, and we have to shove this value down to that load location.
+ ProcessSP process_sp = GetUpdatePoint().GetProcessSP();
+ if (process_sp)
+ {
+ lldb::addr_t target_addr = m_value.GetScalar().GetRawBits64(LLDB_INVALID_ADDRESS);
+ size_t bytes_written = process_sp->WriteScalarToMemory (target_addr,
+ new_scalar,
+ byte_size,
+ error);
+ if (!error.Success() || bytes_written != byte_size)
+ return false;
+ }
+ }
break;
- case Value::eValueTypeFileAddress:
- // Try to convert the file address to a load address and then write the new value there.
+ case Value::eValueTypeHostAddress:
+ {
+ // If it is a host address, then we stuff the scalar as a DataBuffer into the Value's data.
+ DataExtractor new_data;
+ new_data.SetByteOrder (m_data.GetByteOrder());
+
+ DataBufferSP buffer_sp (new DataBufferHeap(byte_size, 0));
+ m_data.SetData(buffer_sp, 0);
+ bool success = new_scalar.GetData(new_data);
+ if (success)
+ {
+ new_data.CopyByteOrderedData(0,
+ byte_size,
+ const_cast<uint8_t *>(m_data.GetDataStart()),
+ byte_size,
+ m_data.GetByteOrder());
+ }
+ m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
+
+ }
break;
+ case Value::eValueTypeFileAddress:
+ case Value::eValueTypeScalar:
+ break;
}
- // Limit the bytes in our m_data appropriately.
- m_value.GetScalar().GetData (m_data, byte_size);
- }
- break;
-
- case eEncodingSint:
- if (byte_size > sizeof(long long))
- {
- return false;
}
else
{
- long long sll_val = strtoll(value_str, &end, 0);
- if (end && *end != '\0')
- return false;
- m_value.GetScalar() = sll_val;
- // Limit the bytes in our m_data appropriately.
- m_value.GetScalar().GetData (m_data, byte_size);
- }
- break;
-
- case eEncodingIEEE754:
- {
- const off_t byte_offset = GetByteOffset();
- uint8_t *dst = const_cast<uint8_t *>(m_data.PeekData(byte_offset, byte_size));
- if (dst != NULL)
- {
- // We are decoding a float into host byte order below, so make
- // sure m_data knows what it contains.
- m_data.SetByteOrder(lldb::endian::InlHostByteOrder());
- const size_t converted_byte_size = ClangASTContext::ConvertStringToFloatValue (
- GetClangAST(),
- GetClangType(),
- value_str,
- dst,
- byte_size);
-
- if (converted_byte_size == byte_size)
- {
- }
- }
+ return false;
}
- break;
-
- case eEncodingVector:
- return false;
-
- default:
+ }
+ else
+ {
+ // We don't support setting things bigger than a scalar at present.
return false;
}
-
- // If we have made it here the value is in m_data and we should write it
- // out to the target
- return Write ();
-}
-
-bool
-ValueObject::Write ()
-{
- // Clear the update ID so the next time we try and read the value
- // we try and read it again.
- m_update_point.SetNeedsUpdate();
-
- // TODO: when Value has a method to write a value back, call it from here.
- return false;
-
+
+ // If we have reached this point, then we have successfully changed the value.
+ SetNeedsUpdate();
+ return true;
}
lldb::LanguageType
Modified: lldb/trunk/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectChild.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectChild.cpp Fri Aug 12 18:34:31 2011
@@ -150,7 +150,7 @@
else
{
// Set this object's scalar value to the address of its
- // value be adding its byte offset to the parent address
+ // value by adding its byte offset to the parent address
m_value.GetScalar() += GetByteOffset();
}
}
Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectRegister.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectRegister.cpp Fri Aug 12 18:34:31 2011
@@ -385,4 +385,22 @@
return false;
}
+bool
+ValueObjectRegister::SetValueFromCString (const char *value_str)
+{
+ // The new value will be in the m_data. Copy that into our register value.
+ Error error = m_reg_value.SetValueFromCString (&m_reg_info, value_str);
+ if (error.Success())
+ {
+ if (m_reg_ctx_sp->WriteRegister (&m_reg_info, m_reg_value))
+ {
+ SetNeedsUpdate();
+ return true;
+ }
+ else
+ return false;
+ }
+ else
+ return false;
+}
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Aug 12 18:34:31 2011
@@ -68,6 +68,7 @@
m_debugger (debugger),
m_synchronous_execution (synchronous_execution),
m_skip_lldbinit_files (false),
+ m_skip_app_init_files (false),
m_script_interpreter_ap (),
m_comment_char ('#'),
m_repeat_char ('!'),
@@ -1762,11 +1763,37 @@
CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result)
{
// Don't parse any .lldbinit files if we were asked not to
- if (m_skip_lldbinit_files)
+ if (m_skip_lldbinit_files && m_skip_app_init_files)
return;
const char *init_file_path = in_cwd ? "./.lldbinit" : "~/.lldbinit";
- FileSpec init_file (init_file_path, true);
+
+ std::string app_specific_init;
+
+ if (!m_skip_app_init_files)
+ {
+ FileSpec host_spec = Host::GetProgramFileSpec();
+ const char *host_name = host_spec.GetFilename().AsCString();
+
+ if (host_name != NULL && strcmp (host_name, "lldb") != 0)
+ {
+ app_specific_init += init_file_path;
+ app_specific_init += "-";
+ app_specific_init += host_name;
+ }
+ }
+
+ FileSpec init_file;
+ if (!app_specific_init.empty())
+ {
+ init_file.SetFile (app_specific_init.c_str(), true);
+ }
+
+ if (!m_skip_lldbinit_files && !init_file.Exists())
+ {
+ init_file.SetFile (init_file_path, true);
+ }
+
// If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting
// of the commands back to any appropriate listener (see CommandObjectSource::Execute for more details).
Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=137536&r1=137535&r2=137536&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Fri Aug 12 18:34:31 2011
@@ -45,6 +45,7 @@
ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
m_valid (false),
m_stop_other_threads (stop_other_threads),
+ m_function_addr (function),
m_function_sp (NULL),
m_process (thread.GetProcess()),
m_thread (thread),
@@ -108,7 +109,6 @@
// Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
thread.SetStopInfoToNothing();
- m_function_addr = function;
addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
if (this_arg && cmd_arg)
@@ -161,6 +161,7 @@
ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
m_valid (false),
m_stop_other_threads (stop_other_threads),
+ m_function_addr (function),
m_function_sp(NULL),
m_process (thread.GetProcess()),
m_thread (thread),
@@ -224,7 +225,6 @@
// Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
thread.SetStopInfoToNothing();
- m_function_addr = function;
addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
if (!abi->PrepareTrivialCall (thread,
More information about the lldb-commits
mailing list