From gclayton at apple.com Mon Feb 7 11:41:11 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 07 Feb 2011 17:41:11 -0000 Subject: [Lldb-commits] [lldb] r125008 - /lldb/trunk/source/Core/FileSpec.cpp Message-ID: <20110207174111.54F152A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 11:41:11 2011 New Revision: 125008 URL: http://llvm.org/viewvc/llvm-project?rev=125008&view=rev Log: Posix compatability patch from Jai Menon to avoid uses dirent struct members that aren't always available (sometimes d_namlen or d_reclen). Now strlen is used to avoid such issues. Modified: lldb/trunk/source/Core/FileSpec.cpp Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=125008&r1=125007&r2=125008&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Mon Feb 7 11:41:11 2011 @@ -12,6 +12,7 @@ #include #include #include +#include #if LLDB_CONFIG_TILDE_RESOLVES_TO_USER #include @@ -837,10 +838,12 @@ // Only search directories if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) { - if (dp->d_namlen == 1 && dp->d_name[0] == '.') + size_t len = strlen(dp->d_name); + + if (len == 1 && dp->d_name[0] == '.') continue; - if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.') + if (len == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.') continue; } From gclayton at apple.com Mon Feb 7 11:43:47 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 07 Feb 2011 17:43:47 -0000 Subject: [Lldb-commits] [lldb] r125015 - in /lldb/trunk: include/lldb/Core/ArchSpec.h source/Host/common/Host.cpp Message-ID: <20110207174347.AD0882A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 11:43:47 2011 New Revision: 125015 URL: http://llvm.org/viewvc/llvm-project?rev=125015&view=rev Log: Added a "ArchSpec::SetElfArch()" that was removed by a previous patch and avoid using RTLD_FIRST with dlopen to keep things compatible with other *NIX variants. Patch from Jai Menon. Modified: lldb/trunk/include/lldb/Core/ArchSpec.h lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/include/lldb/Core/ArchSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=125015&r1=125014&r2=125015&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ArchSpec.h (original) +++ lldb/trunk/include/lldb/Core/ArchSpec.h Mon Feb 7 11:43:47 2011 @@ -269,6 +269,14 @@ m_sub = sub; } + void + SetElfArch (uint32_t cpu, uint32_t sub) + { + m_type = lldb::eArchTypeELF; + m_cpu = cpu; + m_sub = sub; + } + //------------------------------------------------------------------ /// Returns the default endianness of the architecture. /// Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125015&r1=125014&r2=125015&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Mon Feb 7 11:43:47 2011 @@ -25,6 +25,8 @@ #include #include #include +#elif defined (__linux__) +#include #endif using namespace lldb; @@ -243,7 +245,7 @@ } } #elif defined (__linux__) - g_host_arch.SetArch(7u, 144u); + g_host_arch.SetElfArch(7u, 144u); #endif } return g_host_arch; @@ -648,7 +650,11 @@ char path[PATH_MAX]; if (file_spec.GetPath(path, sizeof(path))) { +#if defined (__linux__) + dynamic_library_handle = ::dlopen (path, RTLD_LAZY | RTLD_GLOBAL); +#else dynamic_library_handle = ::dlopen (path, RTLD_LAZY | RTLD_GLOBAL | RTLD_FIRST); +#endif if (dynamic_library_handle) { error.Clear(); From gclayton at apple.com Mon Feb 7 11:44:33 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 07 Feb 2011 17:44:33 -0000 Subject: [Lldb-commits] [lldb] r125016 - /lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Message-ID: <20110207174433.47B182A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 11:44:33 2011 New Revision: 125016 URL: http://llvm.org/viewvc/llvm-project?rev=125016&view=rev Log: Namespace patch for linux builds from Jai Menon. Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp?rev=125016&r1=125015&r2=125016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Mon Feb 7 11:44:33 2011 @@ -14,6 +14,7 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Scalar.h" #include "lldb/Target/Thread.h" +#include "lldb/Host/Endian.h" #include "ProcessLinux.h" #include "ProcessMonitor.h" @@ -500,7 +501,7 @@ } if (status) - data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), endian::InlHostByteOrder()); + data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), lldb::endian::InlHostByteOrder()); return status; } From gclayton at apple.com Mon Feb 7 13:04:59 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 07 Feb 2011 19:04:59 -0000 Subject: [Lldb-commits] [lldb] r125024 - in /lldb/trunk: include/lldb/Core/TTYState.h source/Core/Debugger.cpp source/Core/TTYState.cpp source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110207190459.1BD352A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 13:04:58 2011 New Revision: 125024 URL: http://llvm.org/viewvc/llvm-project?rev=125024&view=rev Log: More termios fixes from Kirk Beitz. Modified: lldb/trunk/include/lldb/Core/TTYState.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/TTYState.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/Core/TTYState.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/TTYState.h?rev=125024&r1=125023&r2=125024&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/TTYState.h (original) +++ lldb/trunk/include/lldb/Core/TTYState.h Mon Feb 7 13:04:58 2011 @@ -11,8 +11,9 @@ #define liblldb_TTYState_h_ #if defined(__cplusplus) +#if LLDB_CONFIG_TERMIOS_SUPPORTED #include -#include +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED #include "lldb/lldb-private.h" @@ -121,7 +122,9 @@ int m_fd; ///< File descriptor of the TTY. int m_tflags; ///< Cached tflags information. int m_ttystate_err; ///< Error value from call to save tflags. +#if LLDB_CONFIG_TERMIOS_SUPPORTED struct termios m_ttystate; ///< Cached ttystate information. +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED lldb::pid_t m_process_group;///< Cached process group information. }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=125024&r1=125023&r2=125024&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Feb 7 13:04:58 2011 @@ -21,7 +21,9 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Thread.h" +#if LLDB_CONFIG_TERMIOS_SUPPORTED #include +#endif using namespace lldb; using namespace lldb_private; @@ -547,11 +549,12 @@ void Debugger::ActivateInputReader (const InputReaderSP &reader_sp) { +#if LLDB_CONFIG_TERMIOS_SUPPORTED FILE *in_fh = GetInputFileHandle(); if (in_fh) { - struct termios in_fh_termios; + struct termios in_fh_termios; int in_fd = fileno (in_fh); if (::tcgetattr(in_fd, &in_fh_termios) == 0) { @@ -578,6 +581,7 @@ ::tcsetattr (in_fd, TCSANOW, &in_fh_termios); } } +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED } void Modified: lldb/trunk/source/Core/TTYState.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/TTYState.cpp?rev=125024&r1=125023&r2=125024&view=diff ============================================================================== --- lldb/trunk/source/Core/TTYState.cpp (original) +++ lldb/trunk/source/Core/TTYState.cpp Mon Feb 7 13:04:58 2011 @@ -10,7 +10,7 @@ #include "lldb/Core/TTYState.h" #include #include -#include +#include using namespace lldb_private; @@ -21,7 +21,9 @@ m_fd(-1), m_tflags(-1), m_ttystate_err(-1), +#if LLDB_CONFIG_TERMIOS_SUPPORTED m_ttystate(), +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED m_process_group(-1) { } @@ -45,7 +47,9 @@ { m_fd = fd; m_tflags = ::fcntl (fd, F_GETFL, 0); +#if LLDB_CONFIG_TERMIOS_SUPPORTED m_ttystate_err = ::tcgetattr (fd, &m_ttystate); +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED if (save_process_group) m_process_group = ::tcgetpgrp (0); else @@ -74,8 +78,10 @@ if (TFlagsIsValid()) result = fcntl (m_fd, F_SETFL, m_tflags); +#if LLDB_CONFIG_TERMIOS_SUPPORTED if (TTYStateIsValid()) result = tcsetattr (m_fd, TCSANOW, &m_ttystate); +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED if (ProcessGroupIsValid()) { Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=125024&r1=125023&r2=125024&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Feb 7 13:04:58 2011 @@ -201,7 +201,9 @@ m_dbg_stdout (interpreter.GetDebugger().GetOutputFileHandle()), m_new_sysout (NULL), m_dictionary_name (interpreter.GetDebugger().GetInstanceName().AsCString()), +#if LLDB_CONFIG_TERMIOS_SUPPORTED m_termios (), +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED m_termios_valid (false), m_session_is_active (false), m_pty_slave_is_open (false), @@ -569,8 +571,10 @@ else input_fd = STDIN_FILENO; +#if LLDB_CONFIG_TERMIOS_SUPPORTED script_interpreter->m_termios_valid = ::tcgetattr (input_fd, &script_interpreter->m_termios) == 0; - +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + if (!CurrentThreadHasPythonLock()) { while (!GetPythonLock(1)) @@ -674,6 +678,7 @@ // Restore terminal settings if they were validly saved if (log) log->Printf ("ScriptInterpreterPython::InputReaderCallback, Done, closing down input reader."); +#if LLDB_CONFIG_TERMIOS_SUPPORTED if (script_interpreter->m_termios_valid) { int input_fd; @@ -685,6 +690,7 @@ ::tcsetattr (input_fd, TCSANOW, &script_interpreter->m_termios); } +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED script_interpreter->m_embedded_python_pty.CloseMasterFileDescriptor(); break; } @@ -1433,8 +1439,10 @@ int input_fd = STDIN_FILENO; +#if LLDB_CONFIG_TERMIOS_SUPPORTED struct termios stdin_termios; bool valid_termios = ::tcgetattr (input_fd, &stdin_termios) == 0; +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED // Find the module that owns this code and use that path we get to // set the PYTHONPATH appropriately. @@ -1511,9 +1519,11 @@ PyRun_SimpleString ("from termios import *"); Py_DECREF (pmod); } - + +#if LLDB_CONFIG_TERMIOS_SUPPORTED if (valid_termios) ::tcsetattr (input_fd, TCSANOW, &stdin_termios); +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED } void From gclayton at apple.com Mon Feb 7 13:22:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 07 Feb 2011 19:22:32 -0000 Subject: [Lldb-commits] [lldb] r125027 - in /lldb/trunk: include/lldb/Core/TTYState.h include/lldb/Host/Config.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Core/Debugger.cpp source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110207192232.E3A872A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 13:22:32 2011 New Revision: 125027 URL: http://llvm.org/viewvc/llvm-project?rev=125027&view=rev Log: More termios fixes. We need to currently make sure to include: #include "lldb/Host/Config.h" Or the LLDB_CONFIG_TERMIOS_SUPPORTED defined won't be set. I will fix all of this Termios stuff later today by moving lldb/Core/TTYState.* into the host layer and then we conditionalize all of this inside TTYState.cpp and then we get rid of LLDB_CONFIG_TERMIOS_SUPPORTED all together. Typically, when we start to see too many "#if LLDB_CONFIG_XXXX" preprocessor directives, this is a good indicator that something needs to be moved over to the host layer. TTYState can be modified to do all of the things that many areas of the code are currently doing, and it will avoid all of the preprocessor noise. Modified: lldb/trunk/include/lldb/Core/TTYState.h lldb/trunk/include/lldb/Host/Config.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/Core/TTYState.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/TTYState.h?rev=125027&r1=125026&r2=125027&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/TTYState.h (original) +++ lldb/trunk/include/lldb/Core/TTYState.h Mon Feb 7 13:22:32 2011 @@ -11,6 +11,8 @@ #define liblldb_TTYState_h_ #if defined(__cplusplus) +#include "lldb/Host/Config.h" + #if LLDB_CONFIG_TERMIOS_SUPPORTED #include #endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED Modified: lldb/trunk/include/lldb/Host/Config.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Config.h?rev=125027&r1=125026&r2=125027&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Config.h (original) +++ lldb/trunk/include/lldb/Host/Config.h Mon Feb 7 13:22:32 2011 @@ -32,4 +32,4 @@ #endif -#endif // #ifndef liblldb_Config_h_ \ No newline at end of file +#endif // #ifndef liblldb_Config_h_ Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=125027&r1=125026&r2=125027&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Mon Feb 7 13:22:32 2011 @@ -17,7 +17,11 @@ #include #endif +#include "lldb/Host/Config.h" + +#if LLDB_CONFIG_TERMIOS_SUPPORTED #include +#endif #include "lldb/lldb-private.h" #include "lldb/Interpreter/ScriptInterpreter.h" @@ -113,8 +117,10 @@ FILE *m_dbg_stdout; PyObject *m_new_sysout; std::string m_dictionary_name; +#if LLDB_CONFIG_TERMIOS_SUPPORTED struct termios m_termios; bool m_termios_valid; +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED bool m_session_is_active; bool m_pty_slave_is_open; bool m_valid_session; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=125027&r1=125026&r2=125027&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Feb 7 13:22:32 2011 @@ -14,6 +14,7 @@ #include "lldb/Core/State.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" +#include "lldb/Host/Config.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/TargetList.h" #include "lldb/Target/Process.h" @@ -554,7 +555,7 @@ if (in_fh) { - struct termios in_fh_termios; + struct termios in_fh_termios; int in_fd = fileno (in_fh); if (::tcgetattr(in_fd, &in_fh_termios) == 0) { Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=125027&r1=125026&r2=125027&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Feb 7 13:22:32 2011 @@ -203,8 +203,8 @@ m_dictionary_name (interpreter.GetDebugger().GetInstanceName().AsCString()), #if LLDB_CONFIG_TERMIOS_SUPPORTED m_termios (), -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED m_termios_valid (false), +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED m_session_is_active (false), m_pty_slave_is_open (false), m_valid_session (true) @@ -1434,12 +1434,10 @@ void ScriptInterpreterPython::Initialize () { - Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); - int input_fd = STDIN_FILENO; - #if LLDB_CONFIG_TERMIOS_SUPPORTED + int input_fd = STDIN_FILENO; struct termios stdin_termios; bool valid_termios = ::tcgetattr (input_fd, &stdin_termios) == 0; #endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED From jingham at apple.com Mon Feb 7 13:42:40 2011 From: jingham at apple.com (Jim Ingham) Date: Mon, 07 Feb 2011 19:42:40 -0000 Subject: [Lldb-commits] [lldb] r125031 - in /lldb/trunk: include/lldb/Core/FileSpec.h source/Core/FileSpec.cpp Message-ID: <20110207194240.27F232A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 13:42:39 2011 New Revision: 125031 URL: http://llvm.org/viewvc/llvm-project?rev=125031&view=rev Log: Include Config.h so we can get "~" resolved. Modified: lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/source/Core/FileSpec.cpp Modified: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=125031&r1=125030&r2=125031&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h Mon Feb 7 13:42:39 2011 @@ -15,6 +15,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/STLUtils.h" #include "lldb/Host/TimeValue.h" +#include "lldb/Host/Config.h" namespace lldb_private { Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=125031&r1=125030&r2=125031&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Mon Feb 7 13:42:39 2011 @@ -13,13 +13,13 @@ #include #include #include +#include +#include "lldb/Host/Config.h" // Have to include this before we test the define... #if LLDB_CONFIG_TILDE_RESOLVES_TO_USER #include #endif -#include - #include "llvm/ADT/StringRef.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" From johnny.chen at apple.com Mon Feb 7 14:11:47 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 07 Feb 2011 20:11:47 -0000 Subject: [Lldb-commits] [lldb] r125048 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110207201147.959052A6C12C@llvm.org> Author: johnny Date: Mon Feb 7 14:11:47 2011 New Revision: 125048 URL: http://llvm.org/viewvc/llvm-project?rev=125048&view=rev Log: Add EmulateInstructionARM::EmulateB entries to the g_arm_opcodes and g_thumb_opcodes tables. EmulateB() has empty impl. and needs to be filled in later. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125048&r1=125047&r2=125048&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 7 14:11:47 2011 @@ -1376,6 +1376,27 @@ return true; } +// Branch causes a branch to a target address. +bool +EmulateInstructionARM::EmulateB (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if (ConditionPassed()) + { + EncodingSpecificOperations(); + BranchWritePC(PC + imm32); + } +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + return false; +} + EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) { @@ -1425,7 +1446,12 @@ //---------------------------------------------------------------------- // Supervisor Call (previously Software Interrupt) //---------------------------------------------------------------------- - { 0x0f000000, 0x0f000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSVC, "svc #imm24"} + { 0x0f000000, 0x0f000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSVC, "svc #imm24"}, + + //---------------------------------------------------------------------- + // Branch instructions + //---------------------------------------------------------------------- + { 0x0f000000, 0x0a000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSVC, "b #imm24"} }; static const size_t k_num_arm_opcodes = sizeof(g_arm_opcodes)/sizeof(ARMOpcode); @@ -1496,7 +1522,16 @@ //---------------------------------------------------------------------- // If Then makes up to four following instructions conditional. //---------------------------------------------------------------------- - { 0xffffff00, 0x0000bf00, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateIT, "it{{{}}} "} + { 0xffffff00, 0x0000bf00, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateIT, "it{{{}}} "}, + + //---------------------------------------------------------------------- + // Branch instructions + //---------------------------------------------------------------------- + // To resolve ambiguity, "b #imm8" should come after "svc #imm8". + { 0xfffff000, 0x0000d000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateB, "b #imm8 (outside IT)"}, + { 0xffff8000, 0x0000e000, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateB, "b #imm11 (outside or last in IT)"}, + { 0xf800d000, 0x00008000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside IT)"}, + { 0xf800d000, 0x00009000, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside or last in IT)"} }; Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125048&r1=125047&r2=125048&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon Feb 7 14:11:47 2011 @@ -227,6 +227,9 @@ bool EmulateIT (ARMEncoding encoding); + bool + EmulateB (ARMEncoding encoding); + uint32_t m_arm_isa; Mode m_inst_mode; uint32_t m_inst_cpsr; From jingham at apple.com Mon Feb 7 14:51:42 2011 From: jingham at apple.com (Jim Ingham) Date: Mon, 07 Feb 2011 20:51:42 -0000 Subject: [Lldb-commits] [lldb] r125049 - /lldb/branches/apple/calcite/lldb/source/Target/StopInfo.cpp Message-ID: <20110207205142.19C312A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 14:51:41 2011 New Revision: 125049 URL: http://llvm.org/viewvc/llvm-project?rev=125049&view=rev Log: Prevent recursive calling of the breakpoint action. Can happen because we try to reset the stop info the the breakpoint hit when we get done with a function call, but if that happens under an action for this breakpoint, it will re-trigger the action on the way out. Modified: lldb/branches/apple/calcite/lldb/source/Target/StopInfo.cpp Modified: lldb/branches/apple/calcite/lldb/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Target/StopInfo.cpp?rev=125049&r1=125048&r2=125049&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Target/StopInfo.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Target/StopInfo.cpp Mon Feb 7 14:51:41 2011 @@ -59,7 +59,8 @@ StopInfo (thread, break_id), m_description(), m_should_stop (false), - m_should_stop_is_valid (false) + m_should_stop_is_valid (false), + m_should_perform_action (true) { } @@ -67,7 +68,8 @@ StopInfo (thread, break_id), m_description(), m_should_stop (should_stop), - m_should_stop_is_valid (true) + m_should_stop_is_valid (true), + m_should_perform_action (true) { } @@ -115,6 +117,10 @@ virtual void PerformAction (Event *event_ptr) { + if (!m_should_perform_action) + return; + m_should_perform_action = false; + BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value)); if (bp_site_sp) { @@ -189,6 +195,8 @@ std::string m_description; bool m_should_stop; bool m_should_stop_is_valid; + bool m_should_perform_action; // Since we are trying to preserve the "state" of the system even if we run functions + // etc. behind the users backs, we need to make sure we only REALLY perform the action once. }; From jingham at apple.com Mon Feb 7 14:55:13 2011 From: jingham at apple.com (Jim Ingham) Date: Mon, 07 Feb 2011 20:55:13 -0000 Subject: [Lldb-commits] [lldb] r125050 - in /lldb/branches/apple/calcite/lldb: include/lldb/Core/Broadcaster.h include/lldb/Core/Listener.h source/Core/Broadcaster.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110207205513.D58882A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 14:55:13 2011 New Revision: 125050 URL: http://llvm.org/viewvc/llvm-project?rev=125050&view=rev Log: The hijacking listeners have to be a stack, since you can end up calling a function (like ObjC method resolution) in order to implement calling another function. Modified: lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h?rev=125050&r1=125049&r2=125050&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h (original) +++ lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h Mon Feb 7 14:55:13 2011 @@ -222,8 +222,8 @@ bool IsHijackedForEvent (uint32_t event_mask) { - if (m_hijacking_listener) - return (event_mask & m_hijacking_mask) != 0; + if (m_hijacking_listeners.size() > 0) + return (event_mask & m_hijacking_masks.back()) != 0; return false; } @@ -251,8 +251,8 @@ event_names_map m_event_names; ///< Optionally define event names for readability and logging for each event bit collection m_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster. Mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners. - Listener *m_hijacking_listener; // A simple mechanism to intercept events in lieu of a real Listener collection stack. - uint32_t m_hijacking_mask; + std::vector m_hijacking_listeners; // A simple mechanism to intercept events in + std::vector m_hijacking_masks; private: //------------------------------------------------------------------ Modified: lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h?rev=125050&r1=125049&r2=125050&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h (original) +++ lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h Mon Feb 7 14:55:13 2011 @@ -46,6 +46,12 @@ void Clear (); + const char * + GetName () + { + return m_name.c_str(); + } + uint32_t StartListeningForEvents (Broadcaster* broadcaster, uint32_t event_mask); Modified: lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp?rev=125050&r1=125049&r2=125050&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp Mon Feb 7 14:55:13 2011 @@ -25,8 +25,8 @@ m_broadcaster_name (name), m_listeners (), m_listeners_mutex (Mutex::eMutexTypeRecursive), - m_hijacking_listener(NULL), - m_hijacking_mask(UINT32_MAX) + m_hijacking_listeners(), + m_hijacking_masks() { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) @@ -153,7 +153,7 @@ { Mutex::Locker locker (m_listeners_mutex); - if (m_hijacking_listener != NULL && event_type & m_hijacking_mask) + if (m_hijacking_listeners.size() > 0 && event_type & m_hijacking_masks.back()) return true; if (m_listeners.empty()) @@ -224,19 +224,22 @@ m_broadcaster_name.AsCString(""), event_description.GetData(), unique, - m_hijacking_listener); + m_hijacking_listeners.back()); } - if (m_hijacking_listener != NULL && m_hijacking_mask & event_type) + if (m_hijacking_listeners.size() > 0 && m_hijacking_masks.back() & event_type) { + Listener *hijacking_listener = m_hijacking_listeners.back(); // FIXME: REMOVE THIS EXTRA LOGGING LogSP log_process(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log_process) - log_process->Printf ("Hijacking event delivery for Broadcaster(\"%s\").", m_broadcaster_name.AsCString("")); + log_process->Printf ("Hijacking event delivery for Broadcaster(\"%s\") to Listener(\"%s\").", + m_broadcaster_name.AsCString(""), + hijacking_listener->GetName()); - if (unique && m_hijacking_listener->PeekAtNextEventForBroadcasterWithType (this, event_type)) + if (unique && hijacking_listener->PeekAtNextEventForBroadcasterWithType (this, event_type)) return; - m_hijacking_listener->AddEvent (event_sp); + hijacking_listener->AddEvent (event_sp); } else { @@ -276,13 +279,9 @@ Broadcaster::HijackBroadcaster (Listener *listener, uint32_t event_mask) { Mutex::Locker event_types_locker(m_listeners_mutex); - assert (m_hijacking_listener == NULL); - if (m_hijacking_listener != NULL) - return false; - - m_hijacking_listener = listener; - m_hijacking_mask = event_mask; + m_hijacking_listeners.push_back(listener); + m_hijacking_masks.push_back(event_mask); return true; } @@ -290,7 +289,7 @@ Broadcaster::RestoreBroadcaster () { Mutex::Locker event_types_locker(m_listeners_mutex); - m_hijacking_listener = NULL; - m_hijacking_mask = 0; + m_hijacking_listeners.pop_back(); + m_hijacking_masks.pop_back(); } Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125050&r1=125049&r2=125050&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Feb 7 14:55:13 2011 @@ -2361,6 +2361,7 @@ static const char *bp_names[] = { "start_wqthread", + "_pthread_wqthread", "_pthread_start", NULL }; @@ -2407,18 +2408,18 @@ bool ProcessGDBRemote::StopNoticingNewThreads() { + LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + if (log) + log->Printf ("Disabling new thread notification breakpoint."); + size_t num_bps = m_thread_observation_bps.size(); if (num_bps != 0) { for (int i = 0; i < num_bps; i++) { - LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); - lldb::BreakpointSP break_sp = m_target.GetBreakpointByID(m_thread_observation_bps[i]); if (break_sp) { - if (log) - log->Printf ("Disabling new thread notification breakpoint."); break_sp->SetEnabled(false); } } From gclayton at apple.com Mon Feb 7 17:24:47 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 07 Feb 2011 23:24:47 -0000 Subject: [Lldb-commits] [lldb] r125057 - in /lldb/trunk: include/lldb/Core/TTYState.h include/lldb/Host/Terminal.h include/lldb/Interpreter/ScriptInterpreterPython.h lldb.xcodeproj/project.pbxproj source/Core/Debugger.cpp source/Core/TTYState.cpp source/Host/common/Terminal.cpp source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110207232447.59C662A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 17:24:47 2011 New Revision: 125057 URL: http://llvm.org/viewvc/llvm-project?rev=125057&view=rev Log: Abtract terminal stuff into a new lldb_private::Terminal class where the implementation is hidden in the host layer. This avoids a slew of "#if LLDB_CONFIG_TERMIOS_SUPPORTED" statements in the code and keeps things cleaner. Added: lldb/trunk/include/lldb/Host/Terminal.h lldb/trunk/source/Host/common/Terminal.cpp Removed: lldb/trunk/include/lldb/Core/TTYState.h lldb/trunk/source/Core/TTYState.cpp Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Removed: lldb/trunk/include/lldb/Core/TTYState.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/TTYState.h?rev=125056&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/TTYState.h (original) +++ lldb/trunk/include/lldb/Core/TTYState.h (removed) @@ -1,207 +0,0 @@ -//===-- TTYState.h ----------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_TTYState_h_ -#define liblldb_TTYState_h_ -#if defined(__cplusplus) - -#include "lldb/Host/Config.h" - -#if LLDB_CONFIG_TERMIOS_SUPPORTED -#include -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED - -#include "lldb/lldb-private.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class TTYState TTYState.h "lldb/Core/TTYState.h" -/// @brief A TTY state managment class. -/// -/// This class can be used to remember the TTY state for a file -/// descriptor and later restore that state as it originally was. -//---------------------------------------------------------------------- -class TTYState -{ -public: - //------------------------------------------------------------------ - /// Default constructor - //------------------------------------------------------------------ - TTYState(); - - //------------------------------------------------------------------ - /// Destructor - //------------------------------------------------------------------ - ~TTYState(); - - //------------------------------------------------------------------ - /// Save the TTY state for \a fd. - /// - /// Save the current state of the TTY for the file descriptor "fd" - /// and if "save_process_group" is true, attempt to save the process - /// group info for the TTY. - /// - /// @param[in] fd - /// The file descriptor to save the state of. - /// - /// @param[in] save_process_group - /// If \b true, save the process group settings, else do not - /// save the process group setttings for a TTY. - /// - /// @return - /// Returns \b true if \a fd describes a TTY and if the state - /// was able to be saved, \b false otherwise. - //------------------------------------------------------------------ - bool - Save (int fd, bool save_process_group); - - //------------------------------------------------------------------ - /// Restore the TTY state to the cached state. - /// - /// Restore the state of the TTY using the cached values from a - /// previous call to TTYState::Save(int,bool). - /// - /// @return - /// Returns \b true if the TTY state was successfully restored, - /// \b false otherwise. - //------------------------------------------------------------------ - bool - Restore () const; - - //------------------------------------------------------------------ - /// Test for valid cached TTY state information. - /// - /// @return - /// Returns \b true if this object has valid saved TTY state - /// settings that can be used to restore a previous state, - /// \b false otherwise. - //------------------------------------------------------------------ - bool - IsValid() const; - -protected: - - //------------------------------------------------------------------ - /// Test if tflags is valid. - /// - /// @return - /// Returns \b true if \a m_tflags is valid and can be restored, - /// \b false otherwise. - //------------------------------------------------------------------ - bool - TFlagsIsValid() const; - - //------------------------------------------------------------------ - /// Test if ttystate is valid. - /// - /// @return - /// Returns \b true if \a m_ttystate is valid and can be - /// restored, \b false otherwise. - //------------------------------------------------------------------ - bool - TTYStateIsValid() const; - - //------------------------------------------------------------------ - /// Test if the process group information is valid. - /// - /// @return - /// Returns \b true if \a m_process_group is valid and can be - /// restored, \b false otherwise. - //------------------------------------------------------------------ - bool - ProcessGroupIsValid() const; - - //------------------------------------------------------------------ - // Member variables - //------------------------------------------------------------------ - int m_fd; ///< File descriptor of the TTY. - int m_tflags; ///< Cached tflags information. - int m_ttystate_err; ///< Error value from call to save tflags. -#if LLDB_CONFIG_TERMIOS_SUPPORTED - struct termios m_ttystate; ///< Cached ttystate information. -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED - lldb::pid_t m_process_group;///< Cached process group information. - -}; - -//---------------------------------------------------------------------- -/// @class TTYStateSwitcher TTYState.h "lldb/Core/TTYState.h" -/// @brief A TTY state switching class. -/// -/// This class can be used to remember 2 TTY states for a given file -/// descriptor and switch between the two states. -//---------------------------------------------------------------------- -class TTYStateSwitcher -{ -public: - //------------------------------------------------------------------ - /// Constructor - //------------------------------------------------------------------ - TTYStateSwitcher(); - - //------------------------------------------------------------------ - /// Destructor - //------------------------------------------------------------------ - ~TTYStateSwitcher(); - - //------------------------------------------------------------------ - /// Get the number of possible states to save. - /// - /// @return - /// The number of states that this TTY switcher object contains. - //------------------------------------------------------------------ - uint32_t - GetNumberOfStates() const; - - //------------------------------------------------------------------ - /// Restore the TTY state for state at index \a idx. - /// - /// @return - /// Returns \b true if the TTY state was successfully restored, - /// \b false otherwise. - //------------------------------------------------------------------ - bool - Restore (uint32_t idx) const; - - //------------------------------------------------------------------ - /// Save the TTY state information for the state at index \a idx. - /// The TTY state is saved for the file descriptor \a fd and - /// the process group information will also be saved if requested - /// by \a save_process_group. - /// - /// @param[in] idx - /// The index into the state array where the state should be - /// saved. - /// - /// @param[in] fd - /// The file descriptor for which to save the settings. - /// - /// @param[in] save_process_group - /// If \b true, save the process group information for the TTY. - /// - /// @return - /// Returns \b true if the save was successful, \b false - /// otherwise. - //------------------------------------------------------------------ - bool - Save (uint32_t idx, int fd, bool save_process_group); - -protected: - //------------------------------------------------------------------ - // Member variables - //------------------------------------------------------------------ - mutable uint32_t m_currentState; ///< The currently active TTY state index. - TTYState m_ttystates[2]; ///< The array of TTY states that holds saved TTY info. -}; - -} // namespace lldb_private - -#endif // #if defined(__cplusplus) -#endif // #ifndef liblldb_TTYState_h_ Added: lldb/trunk/include/lldb/Host/Terminal.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Terminal.h?rev=125057&view=auto ============================================================================== --- lldb/trunk/include/lldb/Host/Terminal.h (added) +++ lldb/trunk/include/lldb/Host/Terminal.h Mon Feb 7 17:24:47 2011 @@ -0,0 +1,251 @@ +//===-- Terminal.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_Terminal_h_ +#define liblldb_Terminal_h_ +#if defined(__cplusplus) + +#include "lldb/lldb-private.h" + +struct termios; + +namespace lldb_private { + +class Terminal +{ +public: + + Terminal (int fd = -1) : + m_fd (fd) + { + } + + ~Terminal () + { + } + + bool + IsATerminal () const; + + int + GetFileDescriptor () const + { + return m_fd; + } + + void + SetFileDescriptor (int fd) + { + m_fd = fd; + } + + bool + FileDescriptorIsValid () const + { + return m_fd != -1; + } + + void + Clear () + { + m_fd = -1; + } + + bool + SetEcho (bool enabled); + + bool + SetCanonical (bool enabled); + +protected: + int m_fd; // This may or may not be a terminal file descriptor +}; + + +//---------------------------------------------------------------------- +/// @class State Terminal.h "lldb/Host/Terminal.h" +/// @brief A terminal state saving/restoring class. +/// +/// This class can be used to remember the terminal state for a file +/// descriptor and later restore that state as it originally was. +//---------------------------------------------------------------------- +class TerminalState +{ +public: + //------------------------------------------------------------------ + /// Default constructor + //------------------------------------------------------------------ + TerminalState(); + + //------------------------------------------------------------------ + /// Destructor + //------------------------------------------------------------------ + ~TerminalState(); + + //------------------------------------------------------------------ + /// Save the TTY state for \a fd. + /// + /// Save the current state of the TTY for the file descriptor "fd" + /// and if "save_process_group" is true, attempt to save the process + /// group info for the TTY. + /// + /// @param[in] fd + /// The file descriptor to save the state of. + /// + /// @param[in] save_process_group + /// If \b true, save the process group settings, else do not + /// save the process group setttings for a TTY. + /// + /// @return + /// Returns \b true if \a fd describes a TTY and if the state + /// was able to be saved, \b false otherwise. + //------------------------------------------------------------------ + bool + Save (int fd, bool save_process_group); + + //------------------------------------------------------------------ + /// Restore the TTY state to the cached state. + /// + /// Restore the state of the TTY using the cached values from a + /// previous call to TerminalState::Save(int,bool). + /// + /// @return + /// Returns \b true if the TTY state was successfully restored, + /// \b false otherwise. + //------------------------------------------------------------------ + bool + Restore () const; + + //------------------------------------------------------------------ + /// Test for valid cached TTY state information. + /// + /// @return + /// Returns \b true if this object has valid saved TTY state + /// settings that can be used to restore a previous state, + /// \b false otherwise. + //------------------------------------------------------------------ + bool + IsValid() const; + +protected: + + //------------------------------------------------------------------ + /// Test if tflags is valid. + /// + /// @return + /// Returns \b true if \a m_tflags is valid and can be restored, + /// \b false otherwise. + //------------------------------------------------------------------ + bool + TFlagsIsValid() const; + + //------------------------------------------------------------------ + /// Test if ttystate is valid. + /// + /// @return + /// Returns \b true if \a m_ttystate is valid and can be + /// restored, \b false otherwise. + //------------------------------------------------------------------ + bool + TTYStateIsValid() const; + + //------------------------------------------------------------------ + /// Test if the process group information is valid. + /// + /// @return + /// Returns \b true if \a m_process_group is valid and can be + /// restored, \b false otherwise. + //------------------------------------------------------------------ + bool + ProcessGroupIsValid() const; + + //------------------------------------------------------------------ + // Member variables + //------------------------------------------------------------------ + Terminal m_tty; ///< A terminal + int m_tflags; ///< Cached tflags information. + std::auto_ptr m_termios_ap; ///< Cached terminal state information. + lldb::pid_t m_process_group;///< Cached process group information. + +}; + +//---------------------------------------------------------------------- +/// @class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h" +/// @brief A TTY state switching class. +/// +/// This class can be used to remember 2 TTY states for a given file +/// descriptor and switch between the two states. +//---------------------------------------------------------------------- +class TerminalStateSwitcher +{ +public: + //------------------------------------------------------------------ + /// Constructor + //------------------------------------------------------------------ + TerminalStateSwitcher(); + + //------------------------------------------------------------------ + /// Destructor + //------------------------------------------------------------------ + ~TerminalStateSwitcher(); + + //------------------------------------------------------------------ + /// Get the number of possible states to save. + /// + /// @return + /// The number of states that this TTY switcher object contains. + //------------------------------------------------------------------ + uint32_t + GetNumberOfStates() const; + + //------------------------------------------------------------------ + /// Restore the TTY state for state at index \a idx. + /// + /// @return + /// Returns \b true if the TTY state was successfully restored, + /// \b false otherwise. + //------------------------------------------------------------------ + bool + Restore (uint32_t idx) const; + + //------------------------------------------------------------------ + /// Save the TTY state information for the state at index \a idx. + /// The TTY state is saved for the file descriptor \a fd and + /// the process group information will also be saved if requested + /// by \a save_process_group. + /// + /// @param[in] idx + /// The index into the state array where the state should be + /// saved. + /// + /// @param[in] fd + /// The file descriptor for which to save the settings. + /// + /// @param[in] save_process_group + /// If \b true, save the process group information for the TTY. + /// + /// @return + /// Returns \b true if the save was successful, \b false + /// otherwise. + //------------------------------------------------------------------ + bool + Save (uint32_t idx, int fd, bool save_process_group); + +protected: + //------------------------------------------------------------------ + // Member variables + //------------------------------------------------------------------ + mutable uint32_t m_currentState; ///< The currently active TTY state index. + TerminalState m_ttystates[2]; ///< The array of TTY states that holds saved TTY info. +}; + +} // namespace lldb_private + +#endif // #if defined(__cplusplus) +#endif // #ifndef liblldb_Terminal_h_ Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=125057&r1=125056&r2=125057&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Mon Feb 7 17:24:47 2011 @@ -17,15 +17,10 @@ #include #endif -#include "lldb/Host/Config.h" - -#if LLDB_CONFIG_TERMIOS_SUPPORTED -#include -#endif - #include "lldb/lldb-private.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Core/InputReader.h" +#include "lldb/Host/Terminal.h" namespace lldb_private { @@ -102,6 +97,12 @@ void LeaveSession (); + void + SaveTerminalState (int fd); + + void + RestoreTerminalState (); + private: static size_t @@ -117,10 +118,7 @@ FILE *m_dbg_stdout; PyObject *m_new_sysout; std::string m_dictionary_name; -#if LLDB_CONFIG_TERMIOS_SUPPORTED - struct termios m_termios; - bool m_termios_valid; -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + TerminalState m_terminal_state; bool m_session_is_active; bool m_pty_slave_is_open; bool m_valid_session; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=125057&r1=125056&r2=125057&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Feb 7 17:24:47 2011 @@ -66,6 +66,8 @@ 266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */; }; 266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */; }; 266F5CBC12FC846200DFCE33 /* Config.h in Headers */ = {isa = PBXBuildFile; fileRef = 266F5CBB12FC846200DFCE33 /* Config.h */; }; + 268DA872130095D000C9483A /* Terminal.h in Headers */ = {isa = PBXBuildFile; fileRef = 268DA871130095D000C9483A /* Terminal.h */; }; + 268DA874130095ED00C9483A /* Terminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268DA873130095ED00C9483A /* Terminal.cpp */; }; 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 26B42B1F1187A92B0079C8C8 /* lldb-include.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42B1E1187A92B0079C8C8 /* lldb-include.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -143,7 +145,6 @@ 26D5B0B211B07550009A862E /* StreamString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9310F1B85900F91463 /* StreamString.cpp */; }; 26D5B0B311B07550009A862E /* ConstString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9410F1B85900F91463 /* ConstString.cpp */; }; 26D5B0B411B07550009A862E /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9610F1B85900F91463 /* Timer.cpp */; }; - 26D5B0B511B07550009A862E /* TTYState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9710F1B85900F91463 /* TTYState.cpp */; }; 26D5B0B611B07550009A862E /* UserID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9810F1B85900F91463 /* UserID.cpp */; }; 26D5B0B711B07550009A862E /* Value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9910F1B85900F91463 /* Value.cpp */; }; 26D5B0B811B07550009A862E /* ValueObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */; }; @@ -592,6 +593,8 @@ 2689B0A4113EE3CD00A4AEDB /* Symbols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Symbols.h; path = include/lldb/Host/Symbols.h; sourceTree = ""; }; 2689B0B5113EE47E00A4AEDB /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Symbols.cpp; path = source/Host/macosx/Symbols.cpp; sourceTree = ""; }; 268A813F115B19D000F645B0 /* UniqueCStringMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UniqueCStringMap.h; path = include/lldb/Core/UniqueCStringMap.h; sourceTree = ""; }; + 268DA871130095D000C9483A /* Terminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Terminal.h; path = include/lldb/Host/Terminal.h; sourceTree = ""; }; + 268DA873130095ED00C9483A /* Terminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Terminal.cpp; sourceTree = ""; }; 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSymbolContextList.h; path = include/lldb/API/SBSymbolContextList.h; sourceTree = ""; }; 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = ""; }; 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = ""; }; @@ -709,7 +712,6 @@ 26BC7D7B10F1B77400F91463 /* StreamString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamString.h; path = include/lldb/Core/StreamString.h; sourceTree = ""; }; 26BC7D7C10F1B77400F91463 /* ConstString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConstString.h; path = include/lldb/Core/ConstString.h; sourceTree = ""; }; 26BC7D7E10F1B77400F91463 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timer.h; path = include/lldb/Core/Timer.h; sourceTree = ""; }; - 26BC7D7F10F1B77400F91463 /* TTYState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TTYState.h; path = include/lldb/Core/TTYState.h; sourceTree = ""; }; 26BC7D8010F1B77400F91463 /* UserID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserID.h; path = include/lldb/Core/UserID.h; sourceTree = ""; }; 26BC7D8110F1B77400F91463 /* Value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Value.h; path = include/lldb/Core/Value.h; sourceTree = ""; }; 26BC7D8210F1B77400F91463 /* ValueObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObject.h; path = include/lldb/Core/ValueObject.h; sourceTree = ""; }; @@ -811,7 +813,6 @@ 26BC7E9310F1B85900F91463 /* StreamString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamString.cpp; path = source/Core/StreamString.cpp; sourceTree = ""; }; 26BC7E9410F1B85900F91463 /* ConstString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConstString.cpp; path = source/Core/ConstString.cpp; sourceTree = ""; }; 26BC7E9610F1B85900F91463 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Timer.cpp; path = source/Core/Timer.cpp; sourceTree = ""; }; - 26BC7E9710F1B85900F91463 /* TTYState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TTYState.cpp; path = source/Core/TTYState.cpp; sourceTree = ""; }; 26BC7E9810F1B85900F91463 /* UserID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserID.cpp; path = source/Core/UserID.cpp; sourceTree = ""; }; 26BC7E9910F1B85900F91463 /* Value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Value.cpp; path = source/Core/Value.cpp; sourceTree = ""; }; 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObject.cpp; path = source/Core/ValueObject.cpp; sourceTree = ""; }; @@ -1743,8 +1744,6 @@ 263FEDA5112CC1DA00E4C208 /* ThreadSafeSTLMap.h */, 26BC7D7E10F1B77400F91463 /* Timer.h */, 26BC7E9610F1B85900F91463 /* Timer.cpp */, - 26BC7D7F10F1B77400F91463 /* TTYState.h */, - 26BC7E9710F1B85900F91463 /* TTYState.cpp */, 268A813F115B19D000F645B0 /* UniqueCStringMap.h */, 26BC7D8010F1B77400F91463 /* UserID.h */, 26BC7E9810F1B85900F91463 /* UserID.cpp */, @@ -1978,6 +1977,7 @@ 26BC7DD510F1B7D500F91463 /* Mutex.h */, 26BC7DD610F1B7D500F91463 /* Predicate.h */, 2689B0A4113EE3CD00A4AEDB /* Symbols.h */, + 268DA871130095D000C9483A /* Terminal.h */, 26B4E26E112F35F700AB3F64 /* TimeValue.h */, ); name = Host; @@ -2277,6 +2277,7 @@ 69A01E1C1236C5D400C660B5 /* Host.cpp */, 69A01E1E1236C5D400C660B5 /* Mutex.cpp */, 69A01E1F1236C5D400C660B5 /* Symbols.cpp */, + 268DA873130095ED00C9483A /* Terminal.cpp */, 69A01E201236C5D400C660B5 /* TimeValue.cpp */, ); name = common; @@ -2345,6 +2346,7 @@ 26D9FDC712F784E60003F2EE /* EmulateInstruction.h in Headers */, 26D9FDCF12F7853F0003F2EE /* EmulateInstructionARM.h in Headers */, 266F5CBC12FC846200DFCE33 /* Config.h in Headers */, + 268DA872130095D000C9483A /* Terminal.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2611,7 +2613,6 @@ 26D5B0B211B07550009A862E /* StreamString.cpp in Sources */, 26D5B0B311B07550009A862E /* ConstString.cpp in Sources */, 26D5B0B411B07550009A862E /* Timer.cpp in Sources */, - 26D5B0B511B07550009A862E /* TTYState.cpp in Sources */, 26D5B0B611B07550009A862E /* UserID.cpp in Sources */, 26D5B0B711B07550009A862E /* Value.cpp in Sources */, 26D5B0B811B07550009A862E /* ValueObject.cpp in Sources */, @@ -2850,6 +2851,7 @@ 26D9FDCE12F7853F0003F2EE /* EmulateInstructionARM.cpp in Sources */, 26B8B42512EEC52A00A831B2 /* UniqueDWARFASTType.cpp in Sources */, 4906FD4212F2255300A2A77C /* ASTDumper.cpp in Sources */, + 268DA874130095ED00C9483A /* Terminal.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=125057&r1=125056&r2=125057&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Feb 7 17:24:47 2011 @@ -14,7 +14,7 @@ #include "lldb/Core/State.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" -#include "lldb/Host/Config.h" +#include "lldb/Host/Terminal.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/TargetList.h" #include "lldb/Target/Process.h" @@ -22,9 +22,6 @@ #include "lldb/Target/StopInfo.h" #include "lldb/Target/Thread.h" -#if LLDB_CONFIG_TERMIOS_SUPPORTED -#include -#endif using namespace lldb; using namespace lldb_private; @@ -550,39 +547,31 @@ void Debugger::ActivateInputReader (const InputReaderSP &reader_sp) { -#if LLDB_CONFIG_TERMIOS_SUPPORTED FILE *in_fh = GetInputFileHandle(); if (in_fh) { - struct termios in_fh_termios; int in_fd = fileno (in_fh); - if (::tcgetattr(in_fd, &in_fh_termios) == 0) - { - if (reader_sp->GetEcho()) - in_fh_termios.c_lflag |= ECHO; // Turn on echoing - else - in_fh_termios.c_lflag &= ~ECHO; // Turn off echoing + Terminal tty(in_fd); + + tty.SetEcho(reader_sp->GetEcho()); - switch (reader_sp->GetGranularity()) - { - case eInputReaderGranularityByte: - case eInputReaderGranularityWord: - in_fh_termios.c_lflag &= ~ICANON; // Get one char at a time - break; + switch (reader_sp->GetGranularity()) + { + case eInputReaderGranularityByte: + case eInputReaderGranularityWord: + tty.SetCanonical (false); + break; - case eInputReaderGranularityLine: - case eInputReaderGranularityAll: - in_fh_termios.c_lflag |= ICANON; // Get lines at a time - break; + case eInputReaderGranularityLine: + case eInputReaderGranularityAll: + tty.SetCanonical (true); + break; - default: - break; - } - ::tcsetattr (in_fd, TCSANOW, &in_fh_termios); + default: + break; } } -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED } void Removed: lldb/trunk/source/Core/TTYState.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/TTYState.cpp?rev=125056&view=auto ============================================================================== --- lldb/trunk/source/Core/TTYState.cpp (original) +++ lldb/trunk/source/Core/TTYState.cpp (removed) @@ -1,209 +0,0 @@ -//===-- TTYState.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/Core/TTYState.h" -#include -#include -#include - -using namespace lldb_private; - -//---------------------------------------------------------------------- -// Default constructor -//---------------------------------------------------------------------- -TTYState::TTYState() : - m_fd(-1), - m_tflags(-1), - m_ttystate_err(-1), -#if LLDB_CONFIG_TERMIOS_SUPPORTED - m_ttystate(), -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED - m_process_group(-1) -{ -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -TTYState::~TTYState() -{ -} - -//---------------------------------------------------------------------- -// Save the current state of the TTY for the file descriptor "fd" -// and if "save_process_group" is true, attempt to save the process -// group info for the TTY. -//---------------------------------------------------------------------- -bool -TTYState::Save (int fd, bool save_process_group) -{ - if (fd >= 0 && ::isatty (fd)) - { - m_fd = fd; - m_tflags = ::fcntl (fd, F_GETFL, 0); -#if LLDB_CONFIG_TERMIOS_SUPPORTED - m_ttystate_err = ::tcgetattr (fd, &m_ttystate); -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED - if (save_process_group) - m_process_group = ::tcgetpgrp (0); - else - m_process_group = -1; - } - else - { - m_fd = -1; - m_tflags = -1; - m_ttystate_err = -1; - m_process_group = -1; - } - return m_ttystate_err == 0; -} - -//---------------------------------------------------------------------- -// Restore the state of the TTY using the cached values from a -// previous call to Save(). -//---------------------------------------------------------------------- -bool -TTYState::Restore () const -{ - int result = 0; - if (IsValid()) - { - if (TFlagsIsValid()) - result = fcntl (m_fd, F_SETFL, m_tflags); - -#if LLDB_CONFIG_TERMIOS_SUPPORTED - if (TTYStateIsValid()) - result = tcsetattr (m_fd, TCSANOW, &m_ttystate); -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED - - if (ProcessGroupIsValid()) - { - // Save the original signal handler. - void (*saved_sigttou_callback) (int) = NULL; - saved_sigttou_callback = (void (*)(int)) signal (SIGTTOU, SIG_IGN); - // Set the process group - result = tcsetpgrp (m_fd, m_process_group); - // Restore the original signal handler. - signal (SIGTTOU, saved_sigttou_callback); - } - return true; - } - return false; -} - - - - -//---------------------------------------------------------------------- -// Returns true if this object has valid saved TTY state settings -// that can be used to restore a previous state. -//---------------------------------------------------------------------- -bool -TTYState::IsValid() const -{ - return (m_fd >= 0) && (TFlagsIsValid() || TTYStateIsValid()); -} - -//---------------------------------------------------------------------- -// Returns true if m_tflags is valid -//---------------------------------------------------------------------- -bool -TTYState::TFlagsIsValid() const -{ - return m_tflags != -1; -} - -//---------------------------------------------------------------------- -// Returns true if m_ttystate is valid -//---------------------------------------------------------------------- -bool -TTYState::TTYStateIsValid() const -{ - return m_ttystate_err == 0; -} - -//---------------------------------------------------------------------- -// Returns true if m_process_group is valid -//---------------------------------------------------------------------- -bool -TTYState::ProcessGroupIsValid() const -{ - return m_process_group != -1; -} - -//------------------------------------------------------------------ -// Constructor -//------------------------------------------------------------------ -TTYStateSwitcher::TTYStateSwitcher () : - m_currentState(UINT32_MAX) -{ -} - -//------------------------------------------------------------------ -// Destructor -//------------------------------------------------------------------ -TTYStateSwitcher::~TTYStateSwitcher () -{ -} - -//------------------------------------------------------------------ -// Returns the number of states that this switcher contains -//------------------------------------------------------------------ -uint32_t -TTYStateSwitcher::GetNumberOfStates() const -{ - return sizeof(m_ttystates)/sizeof(TTYState); -} - -//------------------------------------------------------------------ -// Restore the state at index "idx". -// -// Returns true if the restore was successful, false otherwise. -//------------------------------------------------------------------ -bool -TTYStateSwitcher::Restore (uint32_t idx) const -{ - const uint32_t num_states = GetNumberOfStates(); - if (idx >= num_states) - return false; - - // See if we already are in this state? - if (m_currentState < num_states && (idx == m_currentState) && m_ttystates[idx].IsValid()) - return true; - - // Set the state to match the index passed in and only update the - // current state if there are no errors. - if (m_ttystates[idx].Restore()) - { - m_currentState = idx; - return true; - } - - // We failed to set the state. The tty state was invalid or not - // initialized. - return false; -} - -//------------------------------------------------------------------ -// Save the state at index "idx" for file descriptor "fd" and -// save the process group if requested. -// -// Returns true if the restore was successful, false otherwise. -//------------------------------------------------------------------ -bool -TTYStateSwitcher::Save (uint32_t idx, int fd, bool save_process_group) -{ - const uint32_t num_states = GetNumberOfStates(); - if (idx < num_states) - return m_ttystates[idx].Save(fd, save_process_group); - return false; -} - - Added: lldb/trunk/source/Host/common/Terminal.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Terminal.cpp?rev=125057&view=auto ============================================================================== --- lldb/trunk/source/Host/common/Terminal.cpp (added) +++ lldb/trunk/source/Host/common/Terminal.cpp Mon Feb 7 17:24:47 2011 @@ -0,0 +1,299 @@ +//===-- Terminal.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/Host/Terminal.h" +#include "lldb/Host/Config.h" + +#include +#include +#include + +#if LLDB_CONFIG_TERMIOS_SUPPORTED +#include +#endif + + +using namespace lldb_private; + +bool +Terminal::IsATerminal () const +{ + return m_fd >= 0 && ::isatty (m_fd); +} + + +bool +Terminal::SetEcho (bool enabled) +{ + if (FileDescriptorIsValid()) + { +#if LLDB_CONFIG_TERMIOS_SUPPORTED + if (IsATerminal ()) + { + struct termios fd_termios; + if (::tcgetattr(m_fd, &fd_termios) == 0) + { + bool set_corectly = false; + if (enabled) + { + if (fd_termios.c_lflag & ECHO) + set_corectly = true; + else + fd_termios.c_lflag |= ECHO; + } + else + { + if (fd_termios.c_lflag & ECHO) + fd_termios.c_lflag &= ~ECHO; + else + set_corectly = true; + } + + if (set_corectly) + return true; + return ::tcsetattr (m_fd, TCSANOW, &fd_termios) == 0; + } + } +#endif + } + return false; +} + +bool +Terminal::SetCanonical (bool enabled) +{ + if (FileDescriptorIsValid()) + { +#if LLDB_CONFIG_TERMIOS_SUPPORTED + if (IsATerminal ()) + { + struct termios fd_termios; + if (::tcgetattr(m_fd, &fd_termios) == 0) + { + bool set_corectly = false; + if (enabled) + { + if (fd_termios.c_lflag & ICANON) + set_corectly = true; + else + fd_termios.c_lflag |= ICANON; + } + else + { + if (fd_termios.c_lflag & ICANON) + fd_termios.c_lflag &= ~ICANON; + else + set_corectly = true; + } + + if (set_corectly) + return true; + return ::tcsetattr (m_fd, TCSANOW, &fd_termios) == 0; + } + } +#endif + } + return false; +} + +//---------------------------------------------------------------------- +// Default constructor +//---------------------------------------------------------------------- +TerminalState::TerminalState() : + m_tty(), + m_tflags(-1), + m_termios_ap(), + m_process_group(-1) +{ +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +TerminalState::~TerminalState() +{ +} + +//---------------------------------------------------------------------- +// Save the current state of the TTY for the file descriptor "fd" +// and if "save_process_group" is true, attempt to save the process +// group info for the TTY. +//---------------------------------------------------------------------- +bool +TerminalState::Save (int fd, bool save_process_group) +{ + m_tty.SetFileDescriptor(fd); + if (m_tty.IsATerminal()) + { + m_tflags = ::fcntl (fd, F_GETFL, 0); +#if LLDB_CONFIG_TERMIOS_SUPPORTED + if (m_termios_ap.get() == NULL) + m_termios_ap.reset (new struct termios); + int err = ::tcgetattr (fd, m_termios_ap.get()); + if (err != 0) + m_termios_ap.reset(); +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + if (save_process_group) + m_process_group = ::tcgetpgrp (0); + else + m_process_group = -1; + } + else + { + m_tty.Clear(); + m_tflags = -1; + m_termios_ap.reset(); + m_process_group = -1; + } + return IsValid(); +} + +//---------------------------------------------------------------------- +// Restore the state of the TTY using the cached values from a +// previous call to Save(). +//---------------------------------------------------------------------- +bool +TerminalState::Restore () const +{ + int result = 0; + if (IsValid()) + { + const int fd = m_tty.GetFileDescriptor(); + if (TFlagsIsValid()) + result = fcntl (fd, F_SETFL, m_tflags); + +#if LLDB_CONFIG_TERMIOS_SUPPORTED + if (TTYStateIsValid()) + result = tcsetattr (fd, TCSANOW, m_termios_ap.get()); +#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + + if (ProcessGroupIsValid()) + { + // Save the original signal handler. + void (*saved_sigttou_callback) (int) = NULL; + saved_sigttou_callback = (void (*)(int)) signal (SIGTTOU, SIG_IGN); + // Set the process group + result = tcsetpgrp (fd, m_process_group); + // Restore the original signal handler. + signal (SIGTTOU, saved_sigttou_callback); + } + return true; + } + return false; +} + + + + +//---------------------------------------------------------------------- +// Returns true if this object has valid saved TTY state settings +// that can be used to restore a previous state. +//---------------------------------------------------------------------- +bool +TerminalState::IsValid() const +{ + return m_tty.FileDescriptorIsValid () && (TFlagsIsValid() || TTYStateIsValid()); +} + +//---------------------------------------------------------------------- +// Returns true if m_tflags is valid +//---------------------------------------------------------------------- +bool +TerminalState::TFlagsIsValid() const +{ + return m_tflags != -1; +} + +//---------------------------------------------------------------------- +// Returns true if m_ttystate is valid +//---------------------------------------------------------------------- +bool +TerminalState::TTYStateIsValid() const +{ + return m_termios_ap.get() != 0; +} + +//---------------------------------------------------------------------- +// Returns true if m_process_group is valid +//---------------------------------------------------------------------- +bool +TerminalState::ProcessGroupIsValid() const +{ + return m_process_group != -1; +} + +//------------------------------------------------------------------ +// Constructor +//------------------------------------------------------------------ +TerminalStateSwitcher::TerminalStateSwitcher () : + m_currentState(UINT32_MAX) +{ +} + +//------------------------------------------------------------------ +// Destructor +//------------------------------------------------------------------ +TerminalStateSwitcher::~TerminalStateSwitcher () +{ +} + +//------------------------------------------------------------------ +// Returns the number of states that this switcher contains +//------------------------------------------------------------------ +uint32_t +TerminalStateSwitcher::GetNumberOfStates() const +{ + return sizeof(m_ttystates)/sizeof(TerminalState); +} + +//------------------------------------------------------------------ +// Restore the state at index "idx". +// +// Returns true if the restore was successful, false otherwise. +//------------------------------------------------------------------ +bool +TerminalStateSwitcher::Restore (uint32_t idx) const +{ + const uint32_t num_states = GetNumberOfStates(); + if (idx >= num_states) + return false; + + // See if we already are in this state? + if (m_currentState < num_states && (idx == m_currentState) && m_ttystates[idx].IsValid()) + return true; + + // Set the state to match the index passed in and only update the + // current state if there are no errors. + if (m_ttystates[idx].Restore()) + { + m_currentState = idx; + return true; + } + + // We failed to set the state. The tty state was invalid or not + // initialized. + return false; +} + +//------------------------------------------------------------------ +// Save the state at index "idx" for file descriptor "fd" and +// save the process group if requested. +// +// Returns true if the restore was successful, false otherwise. +//------------------------------------------------------------------ +bool +TerminalStateSwitcher::Save (uint32_t idx, int fd, bool save_process_group) +{ + const uint32_t num_states = GetNumberOfStates(); + if (idx < num_states) + return m_ttystates[idx].Save(fd, save_process_group); + return false; +} + + Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=125057&r1=125056&r2=125057&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Feb 7 17:24:47 2011 @@ -201,10 +201,7 @@ m_dbg_stdout (interpreter.GetDebugger().GetOutputFileHandle()), m_new_sysout (NULL), m_dictionary_name (interpreter.GetDebugger().GetInstanceName().AsCString()), -#if LLDB_CONFIG_TERMIOS_SUPPORTED - m_termios (), - m_termios_valid (false), -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + m_terminal_state (), m_session_is_active (false), m_pty_slave_is_open (false), m_valid_session (true) @@ -346,6 +343,28 @@ } void +ScriptInterpreterPython::SaveTerminalState (int fd) +{ + // Python mucks with the terminal state of STDIN. If we can possibly avoid + // this by setting the file handles up correctly prior to entering the + // interpreter we should. For now we save and restore the terminal state + // on the input file handle. + m_terminal_state.Save (fd, false); +} + +void +ScriptInterpreterPython::RestoreTerminalState () +{ + // Python mucks with the terminal state of STDIN. If we can possibly avoid + // this by setting the file handles up correctly prior to entering the + // interpreter we should. For now we save and restore the terminal state + // on the input file handle. + m_terminal_state.Restore(); +} + + + +void ScriptInterpreterPython::LeaveSession () { m_session_is_active = false; @@ -571,9 +590,7 @@ else input_fd = STDIN_FILENO; -#if LLDB_CONFIG_TERMIOS_SUPPORTED - script_interpreter->m_termios_valid = ::tcgetattr (input_fd, &script_interpreter->m_termios) == 0; -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + script_interpreter->SaveTerminalState(input_fd); if (!CurrentThreadHasPythonLock()) { @@ -678,19 +695,9 @@ // Restore terminal settings if they were validly saved if (log) log->Printf ("ScriptInterpreterPython::InputReaderCallback, Done, closing down input reader."); -#if LLDB_CONFIG_TERMIOS_SUPPORTED - if (script_interpreter->m_termios_valid) - { - int input_fd; - FILE *input_fh = reader.GetDebugger().GetInputFileHandle(); - if (input_fh != NULL) - input_fd = ::fileno (input_fh); - else - input_fd = STDIN_FILENO; - ::tcsetattr (input_fd, TCSANOW, &script_interpreter->m_termios); - } -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + script_interpreter->RestoreTerminalState (); + script_interpreter->m_embedded_python_pty.CloseMasterFileDescriptor(); break; } @@ -1436,11 +1443,10 @@ { Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); -#if LLDB_CONFIG_TERMIOS_SUPPORTED - int input_fd = STDIN_FILENO; - struct termios stdin_termios; - bool valid_termios = ::tcgetattr (input_fd, &stdin_termios) == 0; -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + // Python will muck with STDIN terminal state, so save off any current TTY + // settings so we can restore them. + TerminalState stdin_tty_state; + stdin_tty_state.Save(STDIN_FILENO, false); // Find the module that owns this code and use that path we get to // set the PYTHONPATH appropriately. @@ -1518,10 +1524,7 @@ Py_DECREF (pmod); } -#if LLDB_CONFIG_TERMIOS_SUPPORTED - if (valid_termios) - ::tcsetattr (input_fd, TCSANOW, &stdin_termios); -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED + stdin_tty_state.Restore(); } void From johnny.chen at apple.com Mon Feb 7 18:06:35 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 08 Feb 2011 00:06:35 -0000 Subject: [Lldb-commits] [lldb] r125059 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110208000635.DD2AD2A6C12C@llvm.org> Author: johnny Date: Mon Feb 7 18:06:35 2011 New Revision: 125059 URL: http://llvm.org/viewvc/llvm-project?rev=125059&view=rev Log: Add implementation for EmulateInstructionARM::EmulateB() and fixed two typos in g_thumb_opcodes as pointed out By Caroline. Refactored a little bit by adding two new helper methods to the EmulateInstructionARM class: o BranchWritePC() o BXWritePC() Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125059&r1=125058&r2=125059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 7 18:06:35 2011 @@ -779,24 +779,24 @@ uint32_t I2 = !(J2 ^ S); uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10H << 12) + (imm10L << 2); imm32 = llvm::SignExtend32<25>(imm25); - target = (pc & 0xfffffffc) + 4 + imm32; - context.arg1 = eModeARM; // target instruction set - context.arg2 = 4 + imm32; // signed offset + target = ((pc + 4) & 0xfffffffc) + imm32; + context.arg1 = 4 + imm32; // signed offset + context.arg2 = eModeARM; // target instruction set break; } case eEncodingA2: lr = pc + 4; // return address imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2 | Bits32(opcode, 24, 24) << 1); target = pc + 8 + imm32; - context.arg1 = eModeThumb; // target instruction set - context.arg2 = 8 + imm32; // signed offset + context.arg1 = 8 + imm32; // signed offset + context.arg2 = eModeThumb; // target instruction set break; default: return false; } if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, lr)) return false; - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, target)) + if (!BranchWritePC(context, target)) return false; } return true; @@ -858,19 +858,11 @@ default: return false; } - bool toThumb; - if (BitIsSet(target, 0)) - toThumb = true; - else if (BitIsClear(target, 1)) - toThumb = false; - else - return false; // address<1:0> == ???10??? => UNPREDICTABLE context.arg0 = eRegisterKindDWARF; context.arg1 = dwarf_r0 + Rm; - context.arg2 = toThumb ? eModeThumb : eModeARM; if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, lr)) return false; - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, target)) + if (!BXWritePC(context, target)) return false; } return true; @@ -1394,7 +1386,72 @@ if (!success) return false; - return false; + if (ConditionPassed()) + { + EmulateInstruction::Context context = { EmulateInstruction::eContextRelativeBranchImmediate, 0, 0, 0}; + const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); + addr_t target; // target address + if (!success) + return false; + int32_t imm32; // PC-relative offset + switch (encoding) { + case eEncodingT1: + // The 'cond' field is handled in EmulateInstructionARM::CurrentCond(). + imm32 = llvm::SignExtend32<9>(Bits32(opcode, 7, 0) << 1); + target = pc + 4 + imm32; + context.arg1 = 4 + imm32; // signed offset + context.arg2 = eModeThumb; // target instruction set + break; + case eEncodingT2: + imm32 = llvm::SignExtend32<12>(Bits32(opcode, 10, 0)); + target = pc + 4 + imm32; + context.arg1 = 4 + imm32; // signed offset + context.arg2 = eModeThumb; // target instruction set + break; + case eEncodingT3: + // The 'cond' field is handled in EmulateInstructionARM::CurrentCond(). + { + uint32_t S = Bits32(opcode, 26, 26); + uint32_t imm6 = Bits32(opcode, 21, 16); + uint32_t J1 = Bits32(opcode, 13, 13); + uint32_t J2 = Bits32(opcode, 11, 11); + uint32_t imm11 = Bits32(opcode, 10, 0); + uint32_t imm21 = (S << 20) | (J2 << 19) | (J1 << 18) | (imm6 << 12) + (imm11 << 1); + imm32 = llvm::SignExtend32<21>(imm21); + target = pc + 4 + imm32; + context.arg1 = eModeThumb; // target instruction set + context.arg2 = 4 + imm32; // signed offset + break; + } + case eEncodingT4: + { + uint32_t S = Bits32(opcode, 26, 26); + uint32_t imm10 = Bits32(opcode, 25, 16); + uint32_t J1 = Bits32(opcode, 13, 13); + uint32_t J2 = Bits32(opcode, 11, 11); + uint32_t imm11 = Bits32(opcode, 10, 0); + uint32_t I1 = !(J1 ^ S); + uint32_t I2 = !(J2 ^ S); + uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10 << 12) + (imm11 << 1); + imm32 = llvm::SignExtend32<25>(imm25); + target = pc + 4 + imm32; + context.arg1 = eModeThumb; // target instruction set + context.arg2 = 4 + imm32; // signed offset + break; + } + case eEncodingA1: + imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2); + target = pc + 8 + imm32; + context.arg1 = eModeARM; // target instruction set + context.arg2 = 8 + imm32; // signed offset + break; + default: + return false; + } + if (!BranchWritePC(context, target)) + return false; + } + return true; } EmulateInstructionARM::ARMOpcode* @@ -1530,8 +1587,8 @@ // To resolve ambiguity, "b #imm8" should come after "svc #imm8". { 0xfffff000, 0x0000d000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateB, "b #imm8 (outside IT)"}, { 0xffff8000, 0x0000e000, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateB, "b #imm11 (outside or last in IT)"}, - { 0xf800d000, 0x00008000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside IT)"}, - { 0xf800d000, 0x00009000, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside or last in IT)"} + { 0xf800d000, 0xf0008000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside IT)"}, + { 0xf800d000, 0xf0009000, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateB, "b.w #imm8 (outside or last in IT)"} }; @@ -1628,40 +1685,6 @@ return success; } -uint32_t -EmulateInstructionARM::CurrentCond () -{ - switch (m_inst_mode) - { - default: - case eModeInvalid: - break; - - case eModeARM: - return UnsignedBits(m_inst.opcode.inst32, 31, 28); - - case eModeThumb: - // For T1 and T3 encodings of the Branch instruction, it returns the 4-bit - // 'cond' field of the encoding. - if (m_inst.opcode_type == eOpcode16 && - Bits32(m_inst.opcode.inst16, 15, 12) == 0x0d && - Bits32(m_inst.opcode.inst16, 11, 7) != 0x0f) - { - return Bits32(m_inst.opcode.inst16, 11, 7); - } - else if (m_inst.opcode_type == eOpcode32 && - Bits32(m_inst.opcode.inst32, 31, 27) == 0x1e && - Bits32(m_inst.opcode.inst32, 15, 14) == 0x02 && - Bits32(m_inst.opcode.inst32, 12, 12) == 0x00 && - Bits32(m_inst.opcode.inst32, 25, 22) <= 0x0d) - { - return Bits32(m_inst.opcode.inst32, 25, 22); - } - - return m_it_session.GetCond(); - } - return UINT32_MAX; // Return invalid value -} bool EmulateInstructionARM::ConditionPassed () { @@ -1705,6 +1728,88 @@ return result; } +uint32_t +EmulateInstructionARM::CurrentCond () +{ + switch (m_inst_mode) + { + default: + case eModeInvalid: + break; + + case eModeARM: + return UnsignedBits(m_inst.opcode.inst32, 31, 28); + + case eModeThumb: + // For T1 and T3 encodings of the Branch instruction, it returns the 4-bit + // 'cond' field of the encoding. + if (m_inst.opcode_type == eOpcode16 && + Bits32(m_inst.opcode.inst16, 15, 12) == 0x0d && + Bits32(m_inst.opcode.inst16, 11, 7) != 0x0f) + { + return Bits32(m_inst.opcode.inst16, 11, 7); + } + else if (m_inst.opcode_type == eOpcode32 && + Bits32(m_inst.opcode.inst32, 31, 27) == 0x1e && + Bits32(m_inst.opcode.inst32, 15, 14) == 0x02 && + Bits32(m_inst.opcode.inst32, 12, 12) == 0x00 && + Bits32(m_inst.opcode.inst32, 25, 22) <= 0x0d) + { + return Bits32(m_inst.opcode.inst32, 25, 22); + } + + return m_it_session.GetCond(); + } + return UINT32_MAX; // Return invalid value +} + +// API client must pass in a context whose arg2 field contains the target instruction set. +bool +EmulateInstructionARM::BranchWritePC (const Context &context, uint32_t addr) +{ + addr_t target; + + // Chech the target instruction set. + switch (context.arg2) + { + default: + assert(0 && "BranchWritePC expects context.arg1 with either eModeARM or eModeThumb"); + return false; + case eModeARM: + target = addr & 0xfffffffc; + break; + case eModeThumb: + target = addr & 0xfffffffe; + break; + } + if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, target)) + return false; + return false; +} + +// As a side effect, BXWritePC sets context.arg2 to eModeARM or eModeThumb by inspecting addr. +bool +EmulateInstructionARM::BXWritePC (Context &context, uint32_t addr) +{ + addr_t target; + + if (BitIsSet(addr, 0)) + { + target = addr & 0xfffffffe; + context.arg2 = eModeThumb; + } + else if (BitIsClear(addr, 1)) + { + target = addr & 0xfffffffc; + context.arg2 = eModeARM; + } + else + return false; // address<1:0> == '10' => UNPREDICTABLE + + if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, target)) + return false; + return false; +} bool EmulateInstructionARM::EvaluateInstruction () Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125059&r1=125058&r2=125059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon Feb 7 18:06:35 2011 @@ -145,6 +145,12 @@ uint32_t CurrentCond (); + bool + BranchWritePC(const Context &context, uint32_t addr); + + bool + BXWritePC(Context &context, uint32_t addr); + protected: // Typedef for the callback function used during the emulation. From gclayton at apple.com Mon Feb 7 18:35:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 00:35:34 -0000 Subject: [Lldb-commits] [lldb] r125064 - in /lldb/trunk: include/lldb/Core/FileSpec.h include/lldb/Host/Host.h include/lldb/Host/freebsd/Config.h include/lldb/Host/linux/Config.h include/lldb/Host/macosx/Config.h include/lldb/Host/mingw/Config.h source/Commands/CommandCompletions.cpp source/Core/FileSpec.cpp source/Core/PluginManager.cpp source/Core/StreamFile.cpp source/Host/common/Host.cpp source/Host/common/Terminal.cpp Message-ID: <20110208003534.A00682A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 18:35:34 2011 New Revision: 125064 URL: http://llvm.org/viewvc/llvm-project?rev=125064&view=rev Log: Cleaned up the dynamic library open/getsymbol/close code to use abstracted flags such that symbols can be searched for within a shared library if desired. Platforms that support the RTLD_FIRST flag can still take advantage of their quicker lookups, and other platforms can still get the same fucntionality with a little extra work. Also changed LLDB_CONFIG flags over to either being defined, or not being defined to stay in line with current open source practices and to prepare for using autoconf or cmake to configure LLDB builds. Modified: lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Host/freebsd/Config.h lldb/trunk/include/lldb/Host/linux/Config.h lldb/trunk/include/lldb/Host/macosx/Config.h lldb/trunk/include/lldb/Host/mingw/Config.h lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Core/FileSpec.cpp lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/Core/StreamFile.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/common/Terminal.cpp Modified: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h Mon Feb 7 18:35:34 2011 @@ -521,7 +521,7 @@ static size_t Resolve (const char *src_path, char *dst_path, size_t dst_len); -#if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Mon Feb 7 18:35:34 2011 @@ -346,8 +346,15 @@ static size_t GetEnvironment (StringList &env); + enum DynamicLibraryOpenOptions + { + eDynamicLibraryOpenOptionLazy = (1u << 0), // Lazily resolve symbols in this dynamic library + eDynamicLibraryOpenOptionLocal = (1u << 1), // Only open a shared library with local access (hide it from the global symbol namespace) + eDynamicLibraryOpenOptionLimitGetSymbol = (1u << 2) // DynamicLibraryGetSymbol calls on this handle will only return matches from this shared library + }; static void * DynamicLibraryOpen (const FileSpec &file_spec, + uint32_t options, Error &error); static Error Modified: lldb/trunk/include/lldb/Host/freebsd/Config.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/freebsd/Config.h?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/freebsd/Config.h (original) +++ lldb/trunk/include/lldb/Host/freebsd/Config.h Mon Feb 7 18:35:34 2011 @@ -19,4 +19,10 @@ #define LLDB_CONFIG_TERMIOS_SUPPORTED 1 +#define LLDB_CONFIG_TERMIOS_SUPPORTED 1 + +#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1 + +//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 + #endif // #ifndef liblldb_Platform_Config_h_ \ No newline at end of file Modified: lldb/trunk/include/lldb/Host/linux/Config.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/linux/Config.h?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/linux/Config.h (original) +++ lldb/trunk/include/lldb/Host/linux/Config.h Mon Feb 7 18:35:34 2011 @@ -23,4 +23,6 @@ #define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1 +//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 + #endif // #ifndef liblldb_Platform_Config_h_ Modified: lldb/trunk/include/lldb/Host/macosx/Config.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/macosx/Config.h?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/macosx/Config.h (original) +++ lldb/trunk/include/lldb/Host/macosx/Config.h Mon Feb 7 18:35:34 2011 @@ -23,4 +23,6 @@ #define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1 +#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 + #endif // #ifndef liblldb_Platform_Config_h_ Modified: lldb/trunk/include/lldb/Host/mingw/Config.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/mingw/Config.h?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/mingw/Config.h (original) +++ lldb/trunk/include/lldb/Host/mingw/Config.h Mon Feb 7 18:35:34 2011 @@ -19,8 +19,10 @@ #define LLDB_CONFIG_SUPPORTS_SETLINEBUFFERED 1 -#define LLDB_CONFIG_TERMIOS_SUPPORTED 0 +//#define LLDB_CONFIG_TERMIOS_SUPPORTED 1 -#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 0 +//#define LLDB_CONFIG_TILDE_RESOLVES_TO_USER 1 + +//#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 #endif // #ifndef liblldb_Platform_Config_h_ Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Mon Feb 7 18:35:34 2011 @@ -153,7 +153,7 @@ if (end_ptr == NULL) { -#if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER // There's no directory. If the thing begins with a "~" then this is a bare // user name. @@ -207,7 +207,7 @@ return matches.GetSize(); } else -#endif // LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER { // The containing part is the CWD, and the whole string is the remainder. @@ -239,7 +239,7 @@ // Look for a user name in the containing part, and if it's there, resolve it and stick the // result back into the containing_part: -#if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER if (*partial_name_copy == '~') { size_t resolved_username_len = FileSpec::ResolveUsername(containing_part, containing_part, sizeof (containing_part)); @@ -247,7 +247,7 @@ if (resolved_username_len == 0 || resolved_username_len >= sizeof (containing_part)) return matches.GetSize(); } -#endif // #if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER // Okay, containing_part is now the directory we want to open and look for files: Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Mon Feb 7 18:35:34 2011 @@ -16,7 +16,7 @@ #include #include "lldb/Host/Config.h" // Have to include this before we test the define... -#if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER #include #endif @@ -44,7 +44,7 @@ return false; } -#if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER static const char* GetCachedGlobTildeSlash() @@ -134,7 +134,7 @@ else return ::snprintf (dst_path, dst_len, "%s%s", home_dir, remainder); } -#endif // #if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER size_t FileSpec::Resolve (const char *src_path, char *dst_path, size_t dst_len) @@ -144,7 +144,7 @@ // Glob if needed for ~/, otherwise copy in case src_path is same as dst_path... char unglobbed_path[PATH_MAX]; -#if LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER if (src_path[0] == '~') { size_t return_count = ResolveUsername(src_path, unglobbed_path, sizeof(unglobbed_path)); @@ -155,7 +155,7 @@ ::snprintf (unglobbed_path, sizeof(unglobbed_path), "%s", src_path); } else -#endif // LLDB_CONFIG_TILDE_RESOLVES_TO_USER +#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER { ::snprintf(unglobbed_path, sizeof(unglobbed_path), "%s", src_path); } Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Mon Feb 7 18:35:34 2011 @@ -95,7 +95,11 @@ else { PluginInfo plugin_info = { NULL, NULL, NULL }; - plugin_info.plugin_handle = Host::DynamicLibraryOpen (plugin_file_spec, error); + uint32_t flags = Host::eDynamicLibraryOpenOptionLazy | + Host::eDynamicLibraryOpenOptionLocal | + Host::eDynamicLibraryOpenOptionLimitGetSymbol; + + plugin_info.plugin_handle = Host::DynamicLibraryOpen (plugin_file_spec, flags, error); if (plugin_info.plugin_handle) { bool success = false; Modified: lldb/trunk/source/Core/StreamFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StreamFile.cpp?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/source/Core/StreamFile.cpp (original) +++ lldb/trunk/source/Core/StreamFile.cpp Mon Feb 7 18:35:34 2011 @@ -98,10 +98,10 @@ void StreamFile::SetLineBuffered () { -#if LLDB_CONFIG_SUPPORTS_SETLINEBUFFERED +#ifdef LLDB_CONFIG_SUPPORTS_SETLINEBUFFERED if (m_file != NULL) setlinebuf (m_file); -#endif // #if LLDB_CONFIG_SUPPORTS_SETLINEBUFFERED +#endif // #ifdef LLDB_CONFIG_SUPPORTS_SETLINEBUFFERED } void Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Mon Feb 7 18:35:34 2011 @@ -14,6 +14,7 @@ #include "lldb/Core/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" +#include "lldb/Host/Config.h" #include "lldb/Host/Endian.h" #include "lldb/Host/Mutex.h" @@ -21,12 +22,16 @@ #include #if defined (__APPLE__) + #include #include #include #include + #elif defined (__linux__) + #include + #endif using namespace lldb; @@ -643,21 +648,48 @@ } #endif +// Opaque info that tracks a dynamic library that was loaded +struct DynamicLibraryInfo +{ + DynamicLibraryInfo (const FileSpec &fs, int o, void *h) : + file_spec (fs), + open_options (o), + handle (h) + { + } + + const FileSpec file_spec; + uint32_t open_options; + void * handle; +}; + void * -Host::DynamicLibraryOpen (const FileSpec &file_spec, Error &error) +Host::DynamicLibraryOpen (const FileSpec &file_spec, uint32_t options, Error &error) { - void *dynamic_library_handle = NULL; char path[PATH_MAX]; if (file_spec.GetPath(path, sizeof(path))) { -#if defined (__linux__) - dynamic_library_handle = ::dlopen (path, RTLD_LAZY | RTLD_GLOBAL); -#else - dynamic_library_handle = ::dlopen (path, RTLD_LAZY | RTLD_GLOBAL | RTLD_FIRST); + int mode = 0; + + if (options & eDynamicLibraryOpenOptionLazy) + mode |= RTLD_LAZY; + + if (options & eDynamicLibraryOpenOptionLocal) + mode |= RTLD_LOCAL; + else + mode |= RTLD_GLOBAL; + +#ifdef LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED + if (options & eDynamicLibraryOpenOptionLimitGetSymbol) + mode |= RTLD_FIRST; #endif - if (dynamic_library_handle) + + void * opaque = ::dlopen (path, mode); + + if (opaque) { error.Clear(); + return new DynamicLibraryInfo (file_spec, options, opaque); } else { @@ -668,40 +700,73 @@ { error.SetErrorString("failed to extract path"); } - - return dynamic_library_handle; + return NULL; } Error -Host::DynamicLibraryClose (void *dynamic_library_handle) +Host::DynamicLibraryClose (void *opaque) { Error error; - if (dynamic_library_handle == NULL) + if (opaque == NULL) { error.SetErrorString ("invalid dynamic library handle"); } - else if (::dlclose(dynamic_library_handle) != 0) + else { - error.SetErrorString(::dlerror()); + DynamicLibraryInfo *dylib_info = (DynamicLibraryInfo *) opaque; + if (::dlclose (dylib_info->handle) != 0) + { + error.SetErrorString(::dlerror()); + } + + dylib_info->open_options = 0; + dylib_info->handle = 0; + delete dylib_info; } return error; } void * -Host::DynamicLibraryGetSymbol (void *dynamic_library_handle, const char *symbol_name, Error &error) +Host::DynamicLibraryGetSymbol (void *opaque, const char *symbol_name, Error &error) { - if (dynamic_library_handle == NULL) + if (opaque == NULL) { error.SetErrorString ("invalid dynamic library handle"); - return NULL; } - - void *symbol_addr = ::dlsym (dynamic_library_handle, symbol_name); - if (symbol_addr == NULL) - error.SetErrorString(::dlerror()); else - error.Clear(); - return symbol_addr; + { + DynamicLibraryInfo *dylib_info = (DynamicLibraryInfo *) opaque; + + void *symbol_addr = ::dlsym (dylib_info->handle, symbol_name); + if (symbol_addr) + { +#ifndef LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED + // This host doesn't support limiting searches to this shared library + // so we need to verify that the match came from this shared library + // if it was requested in the Host::DynamicLibraryOpen() function. + if (dylib_info->options & eDynamicLibraryOpenOptionLimitGetSymbol) + { + FileSpec match_dylib_spec (Host::GetModuleFileSpecForHostAddress (symbol_addr)); + if (match_dylib_spec != dylib_info->file_spec) + { + char dylib_path[PATH_MAX]; + if (dylib_info->file_spec.GetPath (dylib_path, sizeof(dylib_path))) + error.SetErrorStringWithFormat ("symbol not found in \"%s\"", dylib_path); + else + error.SetErrorString ("symbol not found"); + return NULL; + } + } +#endif + error.Clear(); + return symbol_addr; + } + else + { + error.SetErrorString(::dlerror()); + } + } + return NULL; } bool Modified: lldb/trunk/source/Host/common/Terminal.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Terminal.cpp?rev=125064&r1=125063&r2=125064&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Terminal.cpp (original) +++ lldb/trunk/source/Host/common/Terminal.cpp Mon Feb 7 18:35:34 2011 @@ -14,7 +14,7 @@ #include #include -#if LLDB_CONFIG_TERMIOS_SUPPORTED +#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED #include #endif @@ -33,7 +33,7 @@ { if (FileDescriptorIsValid()) { -#if LLDB_CONFIG_TERMIOS_SUPPORTED +#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED if (IsATerminal ()) { struct termios fd_termios; @@ -60,7 +60,7 @@ return ::tcsetattr (m_fd, TCSANOW, &fd_termios) == 0; } } -#endif +#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED } return false; } @@ -70,7 +70,7 @@ { if (FileDescriptorIsValid()) { -#if LLDB_CONFIG_TERMIOS_SUPPORTED +#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED if (IsATerminal ()) { struct termios fd_termios; @@ -97,7 +97,7 @@ return ::tcsetattr (m_fd, TCSANOW, &fd_termios) == 0; } } -#endif +#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED } return false; } @@ -132,13 +132,13 @@ if (m_tty.IsATerminal()) { m_tflags = ::fcntl (fd, F_GETFL, 0); -#if LLDB_CONFIG_TERMIOS_SUPPORTED +#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED if (m_termios_ap.get() == NULL) m_termios_ap.reset (new struct termios); int err = ::tcgetattr (fd, m_termios_ap.get()); if (err != 0) m_termios_ap.reset(); -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED +#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED if (save_process_group) m_process_group = ::tcgetpgrp (0); else @@ -168,10 +168,10 @@ if (TFlagsIsValid()) result = fcntl (fd, F_SETFL, m_tflags); -#if LLDB_CONFIG_TERMIOS_SUPPORTED +#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED if (TTYStateIsValid()) result = tcsetattr (fd, TCSANOW, m_termios_ap.get()); -#endif // #if LLDB_CONFIG_TERMIOS_SUPPORTED +#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED if (ProcessGroupIsValid()) { From gclayton at apple.com Mon Feb 7 19:03:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 01:03:32 -0000 Subject: [Lldb-commits] [lldb] r125066 - in /lldb/branches/apple/calcite/lldb: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110208010332.6587C2A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 19:03:32 2011 New Revision: 125066 URL: http://llvm.org/viewvc/llvm-project?rev=125066&view=rev Log: Bumping Xcode project versions to lldb-47, debugserver-132. Modified: lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj?rev=125066&r1=125065&r2=125066&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj (original) +++ lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj Mon Feb 7 19:03:32 2011 @@ -2968,9 +2968,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 47; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3025,11 +3025,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 47; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3112,7 +3112,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3148,11 +3148,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 47; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3206,7 +3206,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3245,7 +3245,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 47; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist?rev=125066&r1=125065&r2=125066&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist (original) +++ lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist Mon Feb 7 19:03:32 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 46 + 47 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=125066&r1=125065&r2=125066&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Feb 7 19:03:32 2011 @@ -460,7 +460,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -478,7 +478,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -498,7 +498,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -556,7 +556,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -597,7 +597,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 132; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Mon Feb 7 19:34:25 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 01:34:25 -0000 Subject: [Lldb-commits] [lldb] r125067 - in /lldb/trunk: include/lldb/lldb-types.h source/Core/Communication.cpp source/Host/common/Host.cpp source/Interpreter/ScriptInterpreterPython.cpp source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Process.cpp tools/driver/IOChannel.cpp Message-ID: <20110208013425.C1F8C2A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 19:34:25 2011 New Revision: 125067 URL: http://llvm.org/viewvc/llvm-project?rev=125067&view=rev Log: Patch that allows for thread_t to be something more complex than an integer. Modified patch from Kirk Beitz. Modified: lldb/trunk/include/lldb/lldb-types.h lldb/trunk/source/Core/Communication.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/tools/driver/IOChannel.cpp Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Mon Feb 7 19:34:25 2011 @@ -39,6 +39,7 @@ // #define LLDB_INVALID_PROCESS_ID ... // #define LLDB_INVALID_THREAD_ID ... // #define LLDB_INVALID_HOST_THREAD ... +// #define IS_VALID_LLDB_HOST_THREAD ... //---------------------------------------------------------------------- // TODO: Add a bunch of ifdefs to determine the host system and what @@ -72,7 +73,19 @@ } // namespace lldb +#if defined(__MINGW32__) + +const lldb::thread_t lldb_invalid_host_thread_const = { NULL, 0 } ; +#define LLDB_INVALID_HOST_THREAD (lldb_invalid_host_thread_const) +#define IS_VALID_LLDB_HOST_THREAD(t) (!(NULL == (t).p && 0 == (t).x)) + +#else + #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) +#define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD) + +#endif + #define LLDB_INVALID_HOST_TIME { 0, 0 } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Mon Feb 7 19:34:25 2011 @@ -228,7 +228,7 @@ bool Communication::StartReadThread (Error *error_ptr) { - if (m_read_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_read_thread)) return true; lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, @@ -240,7 +240,7 @@ m_read_thread_enabled = true; m_read_thread = Host::ThreadCreate (thread_name, Communication::ReadThread, this, error_ptr); - if (m_read_thread == LLDB_INVALID_HOST_THREAD) + if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread)) m_read_thread_enabled = false; return m_read_thread_enabled; } @@ -248,7 +248,7 @@ bool Communication::StopReadThread (Error *error_ptr) { - if (m_read_thread == LLDB_INVALID_HOST_THREAD) + if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread)) return true; lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Mon Feb 7 19:34:25 2011 @@ -74,7 +74,7 @@ info_ap.get(), NULL); - if (thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(thread)) info_ap.release(); } return thread; Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Feb 7 19:34:25 2011 @@ -614,7 +614,7 @@ embedded_interpreter_thread = Host::ThreadCreate ("", ScriptInterpreterPython::RunEmbeddedPythonInterpreter, script_interpreter, NULL); - if (embedded_interpreter_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(embedded_interpreter_thread)) { if (log) log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, succeeded in creating thread (thread = %d)", embedded_interpreter_thread); Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Mon Feb 7 19:34:25 2011 @@ -1167,7 +1167,7 @@ m_exception_messages.clear(); } - if (m_monitor_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_monitor_thread)) { Host::ThreadCancel (m_monitor_thread, NULL); thread_result_t thread_result; @@ -1180,6 +1180,9 @@ bool ProcessMacOSX::StartSTDIOThread() { + if (IS_VALID_LLDB_HOST_THREAD(m_stdio_thread)) + return true; + // If we created and own the child STDIO file handles, then we track the // STDIO ourselves, else we let whomever owns these file handles track // the IO themselves. @@ -1188,7 +1191,7 @@ ProcessMacOSXLog::LogIf (PD_LOG_PROCESS, "ProcessMacOSX::%s ( )", __FUNCTION__); // Create the thread that watches for the child STDIO m_stdio_thread = Host::ThreadCreate ("", ProcessMacOSX::STDIOThread, this, NULL); - return m_stdio_thread != LLDB_INVALID_HOST_THREAD; + return IS_VALID_LLDB_HOST_THREAD(m_stdio_thread); } return false; } @@ -1199,7 +1202,7 @@ { ProcessMacOSXLog::LogIf (PD_LOG_PROCESS, "ProcessMacOSX::%s ( )", __FUNCTION__); // Stop the stdio thread - if (m_stdio_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_stdio_thread)) { Host::ThreadCancel (m_stdio_thread, NULL); thread_result_t result = NULL; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Feb 7 19:34:25 2011 @@ -131,7 +131,7 @@ { m_dynamic_loader_ap.reset(); - if (m_debugserver_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_debugserver_thread)) { Host::ThreadCancel (m_debugserver_thread, NULL); thread_result_t thread_result; @@ -2174,7 +2174,7 @@ // Create a thread that watches our internal state and controls which // events make it to clients (into the DCProcess event queue). m_async_thread = Host::ThreadCreate ("", ProcessGDBRemote::AsyncThread, this, NULL); - return m_async_thread != LLDB_INVALID_HOST_THREAD; + return IS_VALID_LLDB_HOST_THREAD(m_async_thread); } void @@ -2188,7 +2188,7 @@ m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit); // Stop the stdio thread - if (m_async_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_async_thread)) { Host::ThreadJoin (m_async_thread, NULL, NULL); } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Feb 7 19:34:25 2011 @@ -2122,7 +2122,7 @@ char thread_name[1024]; snprintf(thread_name, sizeof(thread_name), "", GetID()); m_private_state_thread = Host::ThreadCreate (thread_name, Process::PrivateStateThread, this, NULL); - return m_private_state_thread != LLDB_INVALID_HOST_THREAD; + return IS_VALID_LLDB_HOST_THREAD(m_private_state_thread); } void @@ -2159,7 +2159,7 @@ // thread starts exiting since the private state thread will NULL this out // when it exits const lldb::thread_t private_state_thread = m_private_state_thread; - if (private_state_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(private_state_thread)) { TimeValue timeout_time; bool timed_out; Modified: lldb/trunk/tools/driver/IOChannel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=125067&r1=125066&r2=125067&view=diff ============================================================================== --- lldb/trunk/tools/driver/IOChannel.cpp (original) +++ lldb/trunk/tools/driver/IOChannel.cpp Mon Feb 7 19:34:25 2011 @@ -412,19 +412,19 @@ bool IOChannel::Start () { - if (m_read_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_read_thread)) return true; m_read_thread = SBHostOS::ThreadCreate ("", IOChannel::IOReadThread, this, NULL); - return (m_read_thread != LLDB_INVALID_HOST_THREAD); + return (IS_VALID_LLDB_HOST_THREAD(m_read_thread)); } bool IOChannel::Stop () { - if (m_read_thread == LLDB_INVALID_HOST_THREAD) + if (!IS_VALID_LLDB_HOST_THREAD(m_read_thread)) return true; BroadcastEventByType (eBroadcastBitThreadShouldExit); From gclayton at apple.com Mon Feb 7 20:38:36 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 02:38:36 -0000 Subject: [Lldb-commits] [lldb] r125071 - /lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Message-ID: <20110208023836.0D6252A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 20:38:35 2011 New Revision: 125071 URL: http://llvm.org/viewvc/llvm-project?rev=125071&view=rev Log: Fixed an issue that could cause a crash if a symbol we thought was related to a N_GSYM symbol didn't have an address value for itself. Modified: lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Modified: lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=125071&r1=125070&r2=125071&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Mon Feb 7 20:38:35 2011 @@ -363,7 +363,7 @@ #endif // Next we find the non-stab entry that corresponds to the N_GSYM in the .o file Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny); - if (exe_gsym_symbol && oso_gsym_symbol) + if (exe_gsym_symbol && oso_gsym_symbol && exe_gsym_symbol->GetAddressRangePtr() && oso_gsym_symbol->GetAddressRangePtr()) { // If we found the symbol, then we Section* exe_gsym_section = const_cast
(exe_gsym_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection()); From gclayton at apple.com Mon Feb 7 20:40:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 02:40:32 -0000 Subject: [Lldb-commits] [lldb] r125072 - in /lldb/trunk: include/lldb/Symbol/Block.h source/Commands/CommandObjectImage.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Symbol/Block.cpp source/Symbol/SymbolContext.cpp Message-ID: <20110208024032.ED1FE2A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 20:40:32 2011 New Revision: 125072 URL: http://llvm.org/viewvc/llvm-project?rev=125072&view=rev Log: Fixed a crasher that could happen when trying to look at N_GSYM entries in the DWARF + debug map symbol file parser. Also cleaned up the "image lookup --address ADDR" output when we it results in something that is in an inlined function. Now we correctly dump out the full inlined call stack. Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=125072&r1=125071&r2=125072&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Mon Feb 7 20:40:32 2011 @@ -323,7 +323,7 @@ /// Get const accessor for any inlined function information. /// /// @return - /// A cpmst pointer to any inlined function information, or NULL + /// A comst pointer to any inlined function information, or NULL /// if this is a regular block. //------------------------------------------------------------------ const InlineFunctionInfo* Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=125072&r1=125071&r2=125072&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Mon Feb 7 20:40:32 2011 @@ -248,7 +248,10 @@ so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset); strm.EOL(); strm.Indent (" Summary: "); + const uint32_t save_indent = strm.GetIndentLevel (); + strm.SetIndentLevel (save_indent + 11); so_addr.Dump (&strm, exe_scope, Address::DumpStyleResolvedDescription); + strm.SetIndentLevel (save_indent); strm.EOL(); // Print out detailed address information when verbose is enabled if (verbose) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=125072&r1=125071&r2=125072&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Mon Feb 7 20:40:32 2011 @@ -363,7 +363,7 @@ #endif // Next we find the non-stab entry that corresponds to the N_GSYM in the .o file Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny); - if (exe_gsym_symbol && oso_gsym_symbol) + if (exe_gsym_symbol && oso_gsym_symbol && exe_gsym_symbol->GetAddressRangePtr() && oso_gsym_symbol->GetAddressRangePtr()) { // If we found the symbol, then we Section* exe_gsym_section = const_cast
(exe_gsym_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection()); Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=125072&r1=125071&r2=125072&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Mon Feb 7 20:40:32 2011 @@ -172,7 +172,7 @@ // First frame in a frame with inlined functions s->PutCString (" [inlined]"); } - if (show_inline_blocks) + if (show_inline_blocks && child_inline_call_site) s->EOL(); else s->PutChar(' '); Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=125072&r1=125071&r2=125072&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Mon Feb 7 20:40:32 2011 @@ -133,29 +133,6 @@ if (function->GetMangled().GetName()) function->GetMangled().GetName().Dump(s); - if (show_inlined_frames && block) - { - const InlineFunctionInfo *inline_info = block->GetInlinedFunctionInfo(); - if (inline_info == NULL) - { - const Block *parent_inline_block = block->GetInlinedParent(); - if (parent_inline_block) - inline_info = parent_inline_block->GetInlinedFunctionInfo(); - } - - if (inline_info) - { - s->PutCString(" [inlined] "); - inline_info->GetName().Dump(s); - - if (line_entry.IsValid()) - { - s->PutCString(" at "); - line_entry.DumpStopContext(s, show_fullpaths); - } - return; - } - } if (addr.IsValid()) { const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset(); From johnny.chen at apple.com Mon Feb 7 22:21:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 08 Feb 2011 04:21:13 -0000 Subject: [Lldb-commits] [lldb] r125075 - /lldb/trunk/include/lldb/Core/EmulateInstruction.h Message-ID: <20110208042113.433572A6C12C@llvm.org> Author: johnny Date: Mon Feb 7 22:21:13 2011 New Revision: 125075 URL: http://llvm.org/viewvc/llvm-project?rev=125075&view=rev Log: Forgot to check in this file with r125059. Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=125075&r1=125074&r2=125075&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Mon Feb 7 22:21:13 2011 @@ -123,8 +123,8 @@ // Used when performing a PC-relative branch where the // arg0 = don't care - // arg1 = target instruction set or don't care - // arg2 = imm32 (signed offset) + // arg1 = imm32 (signed offset) + // arg2 = target instruction set or don't care eContextRelativeBranchImmediate, // Used when performing an absolute branch where the From jingham at apple.com Mon Feb 7 22:27:50 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 08 Feb 2011 04:27:50 -0000 Subject: [Lldb-commits] [lldb] r125076 - /lldb/trunk/source/Target/ThreadPlanStepRange.cpp Message-ID: <20110208042751.011352A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 22:27:50 2011 New Revision: 125076 URL: http://llvm.org/viewvc/llvm-project?rev=125076&view=rev Log: Formatting. Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=125076&r1=125075&r2=125076&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Mon Feb 7 22:27:50 2011 @@ -33,7 +33,12 @@ // based on the value of \a type. //---------------------------------------------------------------------- -ThreadPlanStepRange::ThreadPlanStepRange (ThreadPlanKind kind, const char *name, Thread &thread, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_others) : +ThreadPlanStepRange::ThreadPlanStepRange (ThreadPlanKind kind, + const char *name, + Thread &thread, + const AddressRange &range, + const SymbolContext &addr_context, + lldb::RunMode stop_others) : ThreadPlan (kind, name, thread, eVoteNoOpinion, eVoteNoOpinion), m_addr_context (addr_context), m_address_range (range), From gclayton at apple.com Mon Feb 7 22:46:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 04:46:38 -0000 Subject: [Lldb-commits] [lldb] r125077 - in /lldb/branches/apple/calcite/lldb: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110208044638.B34002A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 22:46:38 2011 New Revision: 125077 URL: http://llvm.org/viewvc/llvm-project?rev=125077&view=rev Log: Bumped Xcode project versions for lldb-48. Modified: lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist Modified: lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj?rev=125077&r1=125076&r2=125077&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj (original) +++ lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj Mon Feb 7 22:46:38 2011 @@ -2968,9 +2968,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 47; + DYLIB_CURRENT_VERSION = 48; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3025,11 +3025,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 47; + DYLIB_CURRENT_VERSION = 48; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3112,7 +3112,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3148,11 +3148,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 47; + DYLIB_CURRENT_VERSION = 48; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3206,7 +3206,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3245,7 +3245,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 48; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist?rev=125077&r1=125076&r2=125077&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist (original) +++ lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist Mon Feb 7 22:46:38 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 47 + 48 CFBundleName ${EXECUTABLE_NAME} From wilsons at start.ca Mon Feb 7 22:59:28 2011 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 07 Feb 2011 23:59:28 -0500 Subject: [Lldb-commits] [PATCH] linux: use IS_VALID_LLDB_HOST_THREAD. Message-ID: Update the linux plugin code to use the new check for a valid host thread introduced in r125067. diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp index 2c93638..490ca6f 100644 --- a/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -555,7 +555,7 @@ WAIT_AGAIN: // Finally, start monitoring the child process for change in state. m_monitor_thread = Host::StartMonitoringChildProcess( ProcessMonitor::MonitorCallback, this, GetPID(), true); - if (m_monitor_thread == LLDB_INVALID_HOST_THREAD) + if (!IS_VALID_LLDB_HOST_THREAD(m_monitor_thread)) { error.SetErrorToGenericError(); error.SetErrorString("Process launch failed."); @@ -580,7 +580,7 @@ ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) { static const char *g_thread_name = "lldb.process.linux.operation"; - if (m_operation_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_operation_thread)) return; m_operation_thread = @@ -592,7 +592,7 @@ ProcessMonitor::StopOperationThread() { lldb::thread_result_t result; - if (m_operation_thread == LLDB_INVALID_HOST_THREAD) + if (!IS_VALID_LLDB_HOST_THREAD(m_operation_thread)) return; Host::ThreadCancel(m_operation_thread, NULL); @@ -1009,7 +1009,7 @@ ProcessMonitor::StopMonitoringChildProcess() { lldb::thread_result_t thread_result; - if (m_monitor_thread != LLDB_INVALID_HOST_THREAD) + if (IS_VALID_LLDB_HOST_THREAD(m_monitor_thread)) { Host::ThreadCancel(m_monitor_thread, NULL); Host::ThreadJoin(m_monitor_thread, &thread_result, NULL); From gclayton at apple.com Mon Feb 7 23:05:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 05:05:52 -0000 Subject: [Lldb-commits] [lldb] r125078 - in /lldb/trunk: include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Host/ include/lldb/Symbol/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Host/common/ source/Host/macosx/ source/Interpreter/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/ObjectContainer/BSD-Archive/ source/Plugins/ObjectContainer/Universal-Mach-O/ source/Plugins/ObjectFile/ELF/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/Proce... Message-ID: <20110208050553.0B2A32A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 23:05:52 2011 New Revision: 125078 URL: http://llvm.org/viewvc/llvm-project?rev=125078&view=rev Log: Moved FileSpec into the Host layer since it will vary from host to host. We have a common unix implementation in lldb/source/Host/common/FileSpec.cpp. Added: lldb/trunk/include/lldb/Host/FileSpec.h - copied, changed from r125077, lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/source/Host/common/FileSpec.cpp - copied, changed from r125077, lldb/trunk/source/Core/FileSpec.cpp Removed: lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/source/Core/FileSpec.cpp Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h lldb/trunk/include/lldb/Core/AddressResolver.h lldb/trunk/include/lldb/Core/FileSpecList.h lldb/trunk/include/lldb/Core/PluginManager.h lldb/trunk/include/lldb/Core/SearchFilter.h lldb/trunk/include/lldb/Core/SourceManager.h lldb/trunk/include/lldb/Host/Symbols.h lldb/trunk/include/lldb/Symbol/Declaration.h lldb/trunk/include/lldb/Symbol/LineEntry.h lldb/trunk/include/lldb/Symbol/ObjectContainer.h lldb/trunk/include/lldb/Symbol/ObjectFile.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBFileSpec.cpp lldb/trunk/source/API/SBHostOS.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Core/DataBufferMemoryMap.cpp lldb/trunk/source/Core/PluginManager.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h Mon Feb 7 23:05:52 2011 @@ -18,7 +18,7 @@ #include "lldb/Core/Address.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointResolver.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Core/ConstString.h" Modified: lldb/trunk/include/lldb/Core/AddressResolver.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressResolver.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/AddressResolver.h (original) +++ lldb/trunk/include/lldb/Core/AddressResolver.h Mon Feb 7 23:05:52 2011 @@ -19,7 +19,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Core/ConstString.h" Removed: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=125077&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h (removed) @@ -1,591 +0,0 @@ -//===-- FileSpec.h ----------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_FileSpec_h_ -#define liblldb_FileSpec_h_ -#if defined(__cplusplus) - -#include "lldb/lldb-private.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/STLUtils.h" -#include "lldb/Host/TimeValue.h" -#include "lldb/Host/Config.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class FileSpec FileSpec.h "lldb/Core/FileSpec.h" -/// @brief A file utility class. -/// -/// A file specification class that divides paths up into a directory -/// and basename. These string values of the paths are put into uniqued -/// string pools for fast comparisons and efficient memory usage. -/// -/// Another reason the paths are split into the directory and basename -/// is to allow efficient debugger searching. Often in a debugger the -/// user types in the basename of the file, for example setting a -/// breakpoint by file and line, or specifying a module (shared library) -/// to limit the scope in which to execute a command. The user rarely -/// types in a full path. When the paths are already split up, it makes -/// it easy for us to compare only the basenames of a lot of file -/// specifications without having to split up the file path each time -/// to get to the basename. -//---------------------------------------------------------------------- -class FileSpec -{ -public: - typedef enum FileType - { - eFileTypeInvalid = -1, - eFileTypeUnknown = 0, - eFileTypeDirectory, - eFileTypePipe, - eFileTypeRegular, - eFileTypeSocket, - eFileTypeSymbolicLink, - eFileTypeOther - } FileType; - - FileSpec(); - - //------------------------------------------------------------------ - /// Constructor with path. - /// - /// Takes a path to a file which can be just a filename, or a full - /// path. If \a path is not NULL or empty, this function will call - /// FileSpec::SetFile (const char *path, bool resolve). - /// - /// @param[in] path - /// The full or partial path to a file. - /// - /// @param[in] resolve_path - /// If \b true, then we resolve the path with realpath, - /// if \b false we trust the path is in canonical form already. - /// - /// @see FileSpec::SetFile (const char *path, bool resolve) - //------------------------------------------------------------------ - explicit FileSpec (const char *path, bool resolve_path); - - //------------------------------------------------------------------ - /// Copy constructor - /// - /// Makes a copy of the uniqued directory and filename strings from - /// \a rhs. - /// - /// @param[in] rhs - /// A const FileSpec object reference to copy. - //------------------------------------------------------------------ - FileSpec (const FileSpec& rhs); - - //------------------------------------------------------------------ - /// Copy constructor - /// - /// Makes a copy of the uniqued directory and filename strings from - /// \a rhs if it is not NULL. - /// - /// @param[in] rhs - /// A const FileSpec object pointer to copy if non-NULL. - //------------------------------------------------------------------ - FileSpec (const FileSpec* rhs); - - //------------------------------------------------------------------ - /// Destructor. - /// - /// The destructor is virtual in case this class is subclassed. - //------------------------------------------------------------------ - virtual - ~FileSpec (); - - //------------------------------------------------------------------ - /// Assignment operator. - /// - /// Makes a copy of the uniqued directory and filename strings from - /// \a rhs. - /// - /// @param[in] rhs - /// A const FileSpec object reference to assign to this object. - /// - /// @return - /// A const reference to this object. - //------------------------------------------------------------------ - const FileSpec& - operator= (const FileSpec& rhs); - - //------------------------------------------------------------------ - /// Equal to operator - /// - /// Tests if this object is equal to \a rhs. - /// - /// @param[in] rhs - /// A const FileSpec object reference to compare this object - /// to. - /// - /// @return - /// \b true if this object is equal to \a rhs, \b false - /// otherwise. - //------------------------------------------------------------------ - bool - operator== (const FileSpec& rhs) const; - - //------------------------------------------------------------------ - /// Not equal to operator - /// - /// Tests if this object is not equal to \a rhs. - /// - /// @param[in] rhs - /// A const FileSpec object reference to compare this object - /// to. - /// - /// @return - /// \b true if this object is equal to \a rhs, \b false - /// otherwise. - //------------------------------------------------------------------ - bool - operator!= (const FileSpec& rhs) const; - - //------------------------------------------------------------------ - /// Less than to operator - /// - /// Tests if this object is less than \a rhs. - /// - /// @param[in] rhs - /// A const FileSpec object reference to compare this object - /// to. - /// - /// @return - /// \b true if this object is less than \a rhs, \b false - /// otherwise. - //------------------------------------------------------------------ - bool - operator< (const FileSpec& rhs) const; - - //------------------------------------------------------------------ - /// Convert to pointer operator. - /// - /// This allows code to check a FileSpec object to see if it - /// contains anything valid using code such as: - /// - /// @code - /// FileSpec file_spec(...); - /// if (file_spec) - /// { ... - /// @endcode - /// - /// @return - /// A pointer to this object if either the directory or filename - /// is valid, NULL otherwise. - //------------------------------------------------------------------ - operator - void* () const; - - //------------------------------------------------------------------ - /// Logical NOT operator. - /// - /// This allows code to check a FileSpec object to see if it is - /// invalid using code such as: - /// - /// @code - /// FileSpec file_spec(...); - /// if (!file_spec) - /// { ... - /// @endcode - /// - /// @return - /// Returns \b true if the object has an empty directory and - /// filename, \b false otherwise. - //------------------------------------------------------------------ - bool - operator! () const; - - //------------------------------------------------------------------ - /// Clears the object state. - /// - /// Clear this object by releasing both the directory and filename - /// string values and reverting them to empty strings. - //------------------------------------------------------------------ - void - Clear (); - - //------------------------------------------------------------------ - /// Compare two FileSpec objects. - /// - /// If \a full is true, then both the directory and the filename - /// must match. If \a full is false, then the directory names for - /// \a lhs and \a rhs are only compared if they are both not empty. - /// This allows a FileSpec object to only contain a filename - /// and it can match FileSpec objects that have matching - /// filenames with different paths. - /// - /// @param[in] lhs - /// A const reference to the Left Hand Side object to compare. - /// - /// @param[in] rhs - /// A const reference to the Right Hand Side object to compare. - /// - /// @param[in] full - /// If true, then both the directory and filenames will have to - /// match for a compare to return zero (equal to). If false - /// and either directory from \a lhs or \a rhs is empty, then - /// only the filename will be compared, else a full comparison - /// is done. - /// - /// @return - /// @li -1 if \a lhs is less than \a rhs - /// @li 0 if \a lhs is equal to \a rhs - /// @li 1 if \a lhs is greater than \a rhs - //------------------------------------------------------------------ - static int - Compare (const FileSpec& lhs, const FileSpec& rhs, bool full); - - static bool - Equal (const FileSpec& a, const FileSpec& b, bool full); - - //------------------------------------------------------------------ - /// Dump this object to a Stream. - /// - /// Dump the object to the supplied stream \a s. If the object - /// contains a valid directory name, it will be displayed followed - /// by a directory delimiter, and the filename. - /// - /// @param[in] s - /// The stream to which to dump the object descripton. - //------------------------------------------------------------------ - void - Dump (Stream *s) const; - - //------------------------------------------------------------------ - /// Existence test. - /// - /// @return - /// \b true if the file exists on disk, \b false otherwise. - //------------------------------------------------------------------ - bool - Exists () const; - - - //------------------------------------------------------------------ - /// Expanded existence test. - /// - /// Call into the Host to see if it can help find the file (e.g. by - /// searching paths set in the environment, etc.). - /// - /// If found, sets the value of m_directory to the directory where - /// the file was found. - /// - /// @return - /// \b true if was able to find the file using expanded search - /// methods, \b false otherwise. - //------------------------------------------------------------------ - bool - ResolveExecutableLocation (); - - //------------------------------------------------------------------ - /// Canonicalize this file path (basically running the static - /// FileSpec::Resolve method on it). Useful if you asked us not to - /// resolve the file path when you set the file. - //------------------------------------------------------------------ - bool - ResolvePath (); - - uint64_t - GetByteSize() const; - - //------------------------------------------------------------------ - /// Directory string get accessor. - /// - /// @return - /// A reference to the directory string object. - //------------------------------------------------------------------ - ConstString & - GetDirectory (); - - //------------------------------------------------------------------ - /// Directory string const get accessor. - /// - /// @return - /// A const reference to the directory string object. - //------------------------------------------------------------------ - const ConstString & - GetDirectory () const; - - //------------------------------------------------------------------ - /// Filename string get accessor. - /// - /// @return - /// A reference to the filename string object. - //------------------------------------------------------------------ - ConstString & - GetFilename (); - - //------------------------------------------------------------------ - /// Filename string const get accessor. - /// - /// @return - /// A const reference to the filename string object. - //------------------------------------------------------------------ - const ConstString & - GetFilename () const; - - TimeValue - GetModificationTime () const; - - //------------------------------------------------------------------ - /// Extract the full path to the file. - /// - /// Extract the directory and path into a fixed buffer. This is - /// needed as the directory and path are stored in separate string - /// values. - /// - /// @param[out] path - /// The buffer in which to place the extracted full path. - /// - /// @param[in] max_path_length - /// The maximum length or \a path. - /// - /// @return - /// Returns the number of characters that would be needed to - /// properly copy the full path into \a path. If the returned - /// number is less than \a max_path_length, then the path is - /// properly copied and terminated. If the return value is - /// >= \a max_path_length, then the path was truncated (but is - /// still NULL terminated). - //------------------------------------------------------------------ - size_t - GetPath (char *path, size_t max_path_length) const; - - FileType - GetFileType () const; - - //------------------------------------------------------------------ - /// Get the memory cost of this object. - /// - /// Return the size in bytes that this object takes in memory. This - /// returns the size in bytes of this object, not any shared string - /// values it may refer to. - /// - /// @return - /// The number of bytes that this object occupies in memory. - /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ - size_t - MemorySize () const; - - //------------------------------------------------------------------ - /// Memory map part of, or the entire contents of, a file. - /// - /// Returns a shared pointer to a data buffer that contains all or - /// part of the contents of a file. The data is memory mapped and - /// will lazily page in data from the file as memory is accessed. - /// The data that is mappped will start \a offset bytes into the - /// file, and \a length bytes will be mapped. If \a length is - /// greater than the number of bytes available in the file starting - /// at \a offset, the number of bytes will be appropriately - /// truncated. The final number of bytes that get mapped can be - /// verified using the DataBuffer::GetByteSize() function on the return - /// shared data pointer object contents. - /// - /// @param[in] offset - /// The offset in bytes from the beginning of the file where - /// memory mapping should begin. - /// - /// @param[in] length - /// The size in bytes that should be mapped starting \a offset - /// bytes into the file. If \a length is \c SIZE_MAX, map - /// as many bytes as possible. - /// - /// @return - /// A shared pointer to the memeory mapped data. This shared - /// pointer can contain a NULL DataBuffer pointer, so the contained - /// pointer must be checked prior to using it. - //------------------------------------------------------------------ - lldb::DataBufferSP - MemoryMapFileContents (off_t offset = 0, size_t length = SIZE_MAX) const; - - //------------------------------------------------------------------ - /// Read part of, or the entire contents of, a file into a heap based data buffer. - /// - /// Returns a shared pointer to a data buffer that contains all or - /// part of the contents of a file. The data copies into a heap based - /// buffer that lives in the DataBuffer shared pointer object returned. - /// The data that is cached will start \a offset bytes into the - /// file, and \a length bytes will be mapped. If \a length is - /// greater than the number of bytes available in the file starting - /// at \a offset, the number of bytes will be appropriately - /// truncated. The final number of bytes that get mapped can be - /// verified using the DataBuffer::GetByteSize() function. - /// - /// @param[in] offset - /// The offset in bytes from the beginning of the file where - /// memory mapping should begin. - /// - /// @param[in] length - /// The size in bytes that should be mapped starting \a offset - /// bytes into the file. If \a length is \c SIZE_MAX, map - /// as many bytes as possible. - /// - /// @return - /// A shared pointer to the memeory mapped data. This shared - /// pointer can contain a NULL DataBuffer pointer, so the contained - /// pointer must be checked prior to using it. - //------------------------------------------------------------------ - lldb::DataBufferSP - ReadFileContents (off_t offset = 0, size_t length = SIZE_MAX) const; - - size_t - ReadFileContents (off_t file_offset, void *dst, size_t dst_len) const; - - //------------------------------------------------------------------ - /// Change the file specificed with a new path. - /// - /// Update the contents of this object with a new path. The path will - /// be split up into a directory and filename and stored as uniqued - /// string values for quick comparison and efficient memory usage. - /// - /// @param[in] path - /// A full, partial, or relative path to a file. - /// - /// @param[in] resolve_path - /// If \b true, then we will try to resolve links the path using - /// the static FileSpec::Resolve. - //------------------------------------------------------------------ - void - SetFile (const char *path, bool resolve_path); - - bool - IsResolved () const - { - return m_is_resolved; - } - - //------------------------------------------------------------------ - /// Set if the file path has been resolved or not. - /// - /// If you know a file path is already resolved and avoided passing - /// a \b true parameter for any functions that take a "bool - /// resolve_path" parameter, you can set the value manually using - /// this call to make sure we don't try and resolve it later, or try - /// and resolve a path that has already been resolved. - /// - /// @param[in] is_resolved - /// A boolean value that will replace the current value that - /// indicates if the paths in this object have been resolved. - //------------------------------------------------------------------ - void - SetIsResolved (bool is_resolved) - { - m_is_resolved = is_resolved; - } - //------------------------------------------------------------------ - /// Read the file into an array of strings, one per line. - /// - /// Opens and reads the file in this object into an array of strings, - /// one string per line of the file. Returns a boolean indicating - /// success or failure. - /// - /// @param[out] lines - /// The string array into which to read the file. - /// - /// @result - /// Returns the number of lines that were read from the file. - //------------------------------------------------------------------ - size_t - ReadFileLines (STLStringArray &lines); - - //------------------------------------------------------------------ - /// Resolves user name and links in \a src_path, and writes the output - /// to \a dst_path. Note if the path pointed to by \a src_path does not - /// exist, the contents of \a src_path will be copied to \a dst_path - /// unchanged. - /// - /// @param[in] src_path - /// Input path to be resolved. - /// - /// @param[in] dst_path - /// Buffer to store the resolved path. - /// - /// @param[in] dst_len - /// Size of the buffer pointed to by dst_path. - /// - /// @result - /// The number of characters required to write the resolved path. If the - /// resolved path doesn't fit in dst_len, dst_len-1 characters will - /// be written to \a dst_path, but the actual required length will still be returned. - //------------------------------------------------------------------ - static size_t - Resolve (const char *src_path, char *dst_path, size_t dst_len); - -#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER - - - //------------------------------------------------------------------ - /// Resolves the user name at the beginning of \a src_path, and writes the output - /// to \a dst_path. Note, \a src_path can contain other path components after the - /// user name, they will be copied over, and if the path doesn't start with "~" it - /// will also be copied over to \a dst_path. - /// - /// @param[in] src_path - /// Input path to be resolved. - /// - /// @param[in] dst_path - /// Buffer to store the resolved path. - /// - /// @param[in] dst_len - /// Size of the buffer pointed to by dst_path. - /// - /// @result - /// The number of characters required to write the resolved path, or 0 if - /// the user name could not be found. If the - /// resolved path doesn't fit in dst_len, dst_len-1 characters will - /// be written to \a dst_path, but the actual required length will still be returned. - //------------------------------------------------------------------ - static size_t - ResolveUsername (const char *src_path, char *dst_path, size_t dst_len); - -#endif - - enum EnumerateDirectoryResult - { - eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory - eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not - eEnumerateDirectoryResultExit, // Exit from the current directory at the current level. - eEnumerateDirectoryResultQuit // Stop directory enumerations at any level - }; - - typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton, - FileType file_type, - const FileSpec &spec -); - - static EnumerateDirectoryResult - EnumerateDirectory (const char *dir_path, - bool find_directories, - bool find_files, - bool find_other, - EnumerateDirectoryCallbackType callback, - void *callback_baton); - -protected: - //------------------------------------------------------------------ - // Member variables - //------------------------------------------------------------------ - ConstString m_directory; ///< The uniqued directory path - ConstString m_filename; ///< The uniqued filename path - mutable bool m_is_resolved; ///< True if this path has been resolved. -}; - -//---------------------------------------------------------------------- -/// Dump a FileSpec object to a stream -//---------------------------------------------------------------------- -Stream& operator << (Stream& s, const FileSpec& f); - -} // namespace lldb_private - -#endif // #if defined(__cplusplus) -#endif // liblldb_FileSpec_h_ Modified: lldb/trunk/include/lldb/Core/FileSpecList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpecList.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpecList.h (original) +++ lldb/trunk/include/lldb/Core/FileSpecList.h Mon Feb 7 23:05:52 2011 @@ -12,7 +12,7 @@ #if defined(__cplusplus) #include "lldb/lldb-private.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include namespace lldb_private { Modified: lldb/trunk/include/lldb/Core/PluginManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/PluginManager.h (original) +++ lldb/trunk/include/lldb/Core/PluginManager.h Mon Feb 7 23:05:52 2011 @@ -12,7 +12,7 @@ #define liblldb_PluginManager_h_ #include "lldb/lldb-private.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Core/SearchFilter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SearchFilter.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/SearchFilter.h (original) +++ lldb/trunk/include/lldb/Core/SearchFilter.h Mon Feb 7 23:05:52 2011 @@ -16,7 +16,7 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Stream.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Address.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Core/Module.h" Modified: lldb/trunk/include/lldb/Core/SourceManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/SourceManager.h (original) +++ lldb/trunk/include/lldb/Core/SourceManager.h Mon Feb 7 23:05:52 2011 @@ -18,7 +18,7 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" namespace lldb_private { Copied: lldb/trunk/include/lldb/Host/FileSpec.h (from r125077, lldb/trunk/include/lldb/Core/FileSpec.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?p2=lldb/trunk/include/lldb/Host/FileSpec.h&p1=lldb/trunk/include/lldb/Core/FileSpec.h&r1=125077&r2=125078&rev=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Host/FileSpec.h Mon Feb 7 23:05:52 2011 @@ -20,7 +20,7 @@ namespace lldb_private { //---------------------------------------------------------------------- -/// @class FileSpec FileSpec.h "lldb/Core/FileSpec.h" +/// @class FileSpec FileSpec.h "lldb/Host/FileSpec.h" /// @brief A file utility class. /// /// A file specification class that divides paths up into a directory Modified: lldb/trunk/include/lldb/Host/Symbols.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Symbols.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Symbols.h (original) +++ lldb/trunk/include/lldb/Host/Symbols.h Mon Feb 7 23:05:52 2011 @@ -17,7 +17,7 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Symbol/Declaration.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Declaration.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Declaration.h (original) +++ lldb/trunk/include/lldb/Symbol/Declaration.h Mon Feb 7 23:05:52 2011 @@ -11,7 +11,7 @@ #define liblldb_Declaration_h_ #include "lldb/lldb-private.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Symbol/LineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineEntry.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/LineEntry.h (original) +++ lldb/trunk/include/lldb/Symbol/LineEntry.h Mon Feb 7 23:05:52 2011 @@ -12,7 +12,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/AddressRange.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Symbol/ObjectContainer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectContainer.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectContainer.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectContainer.h Mon Feb 7 23:05:52 2011 @@ -17,7 +17,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/DataExtractor.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Host/Endian.h" Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Mon Feb 7 23:05:52 2011 @@ -12,7 +12,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/DataExtractor.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Host/Endian.h" Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Feb 7 23:05:52 2011 @@ -124,7 +124,6 @@ 26D5B09C11B07550009A862E /* DynamicLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7710F1B85900F91463 /* DynamicLoader.cpp */; }; 26D5B09D11B07550009A862E /* Error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7810F1B85900F91463 /* Error.cpp */; }; 26D5B09E11B07550009A862E /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7910F1B85900F91463 /* Event.cpp */; }; - 26D5B09F11B07550009A862E /* FileSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7A10F1B85900F91463 /* FileSpec.cpp */; }; 26D5B0A011B07550009A862E /* FileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */; }; 26D5B0A211B07550009A862E /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7D10F1B85900F91463 /* Language.cpp */; }; 26D5B0A311B07550009A862E /* Listener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E7E10F1B85900F91463 /* Listener.cpp */; }; @@ -321,6 +320,8 @@ 26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; }; 26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; + 26FA4316130103F400E71120 /* FileSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 26FA4315130103F400E71120 /* FileSpec.h */; }; + 26FA43181301048600E71120 /* FileSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26FA43171301048600E71120 /* FileSpec.cpp */; }; 4906FD4212F2255300A2A77C /* ASTDumper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4906FD4012F2255300A2A77C /* ASTDumper.cpp */; }; 491193521226386000578B7F /* ASTStructExtractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 491193501226386000578B7F /* ASTStructExtractor.cpp */; }; 49307AAE11DEA4D90081F992 /* IRForTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49307AAD11DEA4D90081F992 /* IRForTarget.cpp */; }; @@ -687,7 +688,6 @@ 26BC7D5F10F1B77400F91463 /* dwarf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dwarf.h; path = include/lldb/Core/dwarf.h; sourceTree = ""; }; 26BC7D6010F1B77400F91463 /* Error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Error.h; path = include/lldb/Core/Error.h; sourceTree = ""; }; 26BC7D6110F1B77400F91463 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Event.h; path = include/lldb/Core/Event.h; sourceTree = ""; }; - 26BC7D6210F1B77400F91463 /* FileSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSpec.h; path = include/lldb/Core/FileSpec.h; sourceTree = ""; }; 26BC7D6310F1B77400F91463 /* FileSpecList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSpecList.h; path = include/lldb/Core/FileSpecList.h; sourceTree = ""; }; 26BC7D6410F1B77400F91463 /* Flags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Flags.h; path = include/lldb/Core/Flags.h; sourceTree = ""; }; 26BC7D6510F1B77400F91463 /* IOStreamMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IOStreamMacros.h; path = include/lldb/Core/IOStreamMacros.h; sourceTree = ""; }; @@ -792,7 +792,6 @@ 26BC7E7710F1B85900F91463 /* DynamicLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DynamicLoader.cpp; path = source/Core/DynamicLoader.cpp; sourceTree = ""; }; 26BC7E7810F1B85900F91463 /* Error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Error.cpp; path = source/Core/Error.cpp; sourceTree = ""; }; 26BC7E7910F1B85900F91463 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Event.cpp; path = source/Core/Event.cpp; sourceTree = ""; }; - 26BC7E7A10F1B85900F91463 /* FileSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSpec.cpp; path = source/Core/FileSpec.cpp; sourceTree = ""; }; 26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileSpecList.cpp; path = source/Core/FileSpecList.cpp; sourceTree = ""; }; 26BC7E7D10F1B85900F91463 /* Language.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Language.cpp; path = source/Core/Language.cpp; sourceTree = ""; }; 26BC7E7E10F1B85900F91463 /* Listener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Listener.cpp; path = source/Core/Listener.cpp; sourceTree = ""; }; @@ -930,6 +929,8 @@ 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = ""; }; 26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARM_DWARF_Registers.h; path = source/Utility/ARM_DWARF_Registers.h; sourceTree = ""; }; 26F996A8119B79C300412154 /* ARM_GCC_Registers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARM_GCC_Registers.h; path = source/Utility/ARM_GCC_Registers.h; sourceTree = ""; }; + 26FA4315130103F400E71120 /* FileSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSpec.h; path = include/lldb/Host/FileSpec.h; sourceTree = ""; }; + 26FA43171301048600E71120 /* FileSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSpec.cpp; sourceTree = ""; }; 26FE25221146CADE00F4085A /* GDBRemoteCommunication.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GDBRemoteCommunication.cpp; path = "source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp"; sourceTree = ""; }; 26FE25231146CADE00F4085A /* GDBRemoteCommunication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GDBRemoteCommunication.h; path = "source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h"; sourceTree = ""; }; 4906FD4012F2255300A2A77C /* ASTDumper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTDumper.cpp; path = source/Expression/ASTDumper.cpp; sourceTree = ""; }; @@ -1694,8 +1695,6 @@ 26BC7E7810F1B85900F91463 /* Error.cpp */, 26BC7D6110F1B77400F91463 /* Event.h */, 26BC7E7910F1B85900F91463 /* Event.cpp */, - 26BC7D6210F1B77400F91463 /* FileSpec.h */, - 26BC7E7A10F1B85900F91463 /* FileSpec.cpp */, 26BC7D6310F1B77400F91463 /* FileSpecList.h */, 26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */, 26BC7D6410F1B77400F91463 /* Flags.h */, @@ -1973,6 +1972,7 @@ 26BC7DD210F1B7D500F91463 /* Condition.h */, 266F5CBB12FC846200DFCE33 /* Config.h */, 26BC7DD310F1B7D500F91463 /* Endian.h */, + 26FA4315130103F400E71120 /* FileSpec.h */, 26BC7DD410F1B7D500F91463 /* Host.h */, 26BC7DD510F1B7D500F91463 /* Mutex.h */, 26BC7DD610F1B7D500F91463 /* Predicate.h */, @@ -2273,6 +2273,7 @@ 69A01E1A1236C5D400C660B5 /* common */ = { isa = PBXGroup; children = ( + 26FA43171301048600E71120 /* FileSpec.cpp */, 69A01E1B1236C5D400C660B5 /* Condition.cpp */, 69A01E1C1236C5D400C660B5 /* Host.cpp */, 69A01E1E1236C5D400C660B5 /* Mutex.cpp */, @@ -2347,6 +2348,7 @@ 26D9FDCF12F7853F0003F2EE /* EmulateInstructionARM.h in Headers */, 266F5CBC12FC846200DFCE33 /* Config.h in Headers */, 268DA872130095D000C9483A /* Terminal.h in Headers */, + 26FA4316130103F400E71120 /* FileSpec.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2592,7 +2594,6 @@ 26D5B09C11B07550009A862E /* DynamicLoader.cpp in Sources */, 26D5B09D11B07550009A862E /* Error.cpp in Sources */, 26D5B09E11B07550009A862E /* Event.cpp in Sources */, - 26D5B09F11B07550009A862E /* FileSpec.cpp in Sources */, 26D5B0A011B07550009A862E /* FileSpecList.cpp in Sources */, 26D5B0A211B07550009A862E /* Language.cpp in Sources */, 26D5B0A311B07550009A862E /* Listener.cpp in Sources */, @@ -2852,6 +2853,7 @@ 26B8B42512EEC52A00A831B2 /* UniqueDWARFASTType.cpp in Sources */, 4906FD4212F2255300A2A77C /* ASTDumper.cpp in Sources */, 268DA874130095ED00C9483A /* Terminal.cpp in Sources */, + 26FA43181301048600E71120 /* FileSpec.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/API/SBFileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpec.cpp (original) +++ lldb/trunk/source/API/SBFileSpec.cpp Mon Feb 7 23:05:52 2011 @@ -9,7 +9,7 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" using namespace lldb; Modified: lldb/trunk/source/API/SBHostOS.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBHostOS.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/API/SBHostOS.cpp (original) +++ lldb/trunk/source/API/SBHostOS.cpp Mon Feb 7 23:05:52 2011 @@ -9,7 +9,7 @@ #include "lldb/API/SBHostOS.h" #include "lldb/API/SBError.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Host/Host.h" Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Mon Feb 7 23:05:52 2011 @@ -25,7 +25,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/SearchFilter.h" Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Mon Feb 7 23:05:52 2011 @@ -18,7 +18,7 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandCompletions.h" Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Mon Feb 7 23:05:52 2011 @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Debugger.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Module.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/Stream.h" Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Mon Feb 7 23:05:52 2011 @@ -17,7 +17,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Interpreter/Options.h" Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Mon Feb 7 23:05:52 2011 @@ -17,7 +17,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Target/Process.h" #include "lldb/Core/SourceManager.h" #include "lldb/Target/TargetList.h" Modified: lldb/trunk/source/Core/DataBufferMemoryMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataBufferMemoryMap.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Core/DataBufferMemoryMap.cpp (original) +++ lldb/trunk/source/Core/DataBufferMemoryMap.cpp Mon Feb 7 23:05:52 2011 @@ -15,7 +15,7 @@ #include "lldb/Core/DataBufferMemoryMap.h" #include "lldb/Core/Error.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" using namespace lldb_private; Removed: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=125077&view=auto ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp (removed) @@ -1,918 +0,0 @@ -//===-- FileSpec.cpp --------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - - -#include -#include -#include -#include -#include -#include - -#include "lldb/Host/Config.h" // Have to include this before we test the define... -#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER -#include -#endif - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/Program.h" - -#include "lldb/Core/FileSpec.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/DataBufferMemoryMap.h" -#include "lldb/Core/Stream.h" -#include "lldb/Host/Host.h" -#include "lldb/Utility/CleanUp.h" - -using namespace lldb; -using namespace lldb_private; -using namespace std; - -static bool -GetFileStats (const FileSpec *file_spec, struct stat *stats_ptr) -{ - char resolved_path[PATH_MAX]; - if (file_spec->GetPath(&resolved_path[0], sizeof(resolved_path))) - return ::stat (resolved_path, stats_ptr) == 0; - return false; -} - -#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER - -static const char* -GetCachedGlobTildeSlash() -{ - static std::string g_tilde; - if (g_tilde.empty()) - { - struct passwd *user_entry; - user_entry = getpwuid(geteuid()); - if (user_entry != NULL) - g_tilde = user_entry->pw_dir; - - if (g_tilde.empty()) - return NULL; - } - return g_tilde.c_str(); -} - -// Resolves the username part of a path of the form ~user/other/directories, and -// writes the result into dst_path. -// Returns 0 if there WAS a ~ in the path but the username couldn't be resolved. -// Otherwise returns the number of characters copied into dst_path. If the return -// is >= dst_len, then the resolved path is too long... -size_t -FileSpec::ResolveUsername (const char *src_path, char *dst_path, size_t dst_len) -{ - char user_home[PATH_MAX]; - const char *user_name; - - if (src_path == NULL || src_path[0] == '\0') - return 0; - - // If there's no ~, then just copy src_path straight to dst_path (they may be the same string...) - if (src_path[0] != '~') - { - size_t len = strlen (src_path); - if (len >= dst_len) - { - ::bcopy (src_path, dst_path, dst_len - 1); - dst_path[dst_len] = '\0'; - } - else - ::bcopy (src_path, dst_path, len + 1); - - return len; - } - - const char *first_slash = ::strchr (src_path, '/'); - char remainder[PATH_MAX]; - - if (first_slash == NULL) - { - // The whole name is the username (minus the ~): - user_name = src_path + 1; - remainder[0] = '\0'; - } - else - { - int user_name_len = first_slash - src_path - 1; - ::memcpy (user_home, src_path + 1, user_name_len); - user_home[user_name_len] = '\0'; - user_name = user_home; - - ::strcpy (remainder, first_slash); - } - - if (user_name == NULL) - return 0; - // User name of "" means the current user... - - struct passwd *user_entry; - const char *home_dir = NULL; - - if (user_name[0] == '\0') - { - home_dir = GetCachedGlobTildeSlash(); - } - else - { - user_entry = ::getpwnam (user_name); - if (user_entry != NULL) - home_dir = user_entry->pw_dir; - } - - if (home_dir == NULL) - return 0; - else - return ::snprintf (dst_path, dst_len, "%s%s", home_dir, remainder); -} -#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER - -size_t -FileSpec::Resolve (const char *src_path, char *dst_path, size_t dst_len) -{ - if (src_path == NULL || src_path[0] == '\0') - return 0; - - // Glob if needed for ~/, otherwise copy in case src_path is same as dst_path... - char unglobbed_path[PATH_MAX]; -#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER - if (src_path[0] == '~') - { - size_t return_count = ResolveUsername(src_path, unglobbed_path, sizeof(unglobbed_path)); - - // If we couldn't find the user referred to, or the resultant path was too long, - // then just copy over the src_path. - if (return_count == 0 || return_count >= sizeof(unglobbed_path)) - ::snprintf (unglobbed_path, sizeof(unglobbed_path), "%s", src_path); - } - else -#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER - { - ::snprintf(unglobbed_path, sizeof(unglobbed_path), "%s", src_path); - } - - // Now resolve the path if needed - char resolved_path[PATH_MAX]; - if (::realpath (unglobbed_path, resolved_path)) - { - // Success, copy the resolved path - return ::snprintf(dst_path, dst_len, "%s", resolved_path); - } - else - { - // Failed, just copy the unglobbed path - return ::snprintf(dst_path, dst_len, "%s", unglobbed_path); - } -} - -FileSpec::FileSpec() : - m_directory(), - m_filename() -{ -} - -//------------------------------------------------------------------ -// Default constructor that can take an optional full path to a -// file on disk. -//------------------------------------------------------------------ -FileSpec::FileSpec(const char *pathname, bool resolve_path) : - m_directory(), - m_filename(), - m_is_resolved(false) -{ - if (pathname && pathname[0]) - SetFile(pathname, resolve_path); -} - -//------------------------------------------------------------------ -// Copy constructor -//------------------------------------------------------------------ -FileSpec::FileSpec(const FileSpec& rhs) : - m_directory (rhs.m_directory), - m_filename (rhs.m_filename), - m_is_resolved (rhs.m_is_resolved) -{ -} - -//------------------------------------------------------------------ -// Copy constructor -//------------------------------------------------------------------ -FileSpec::FileSpec(const FileSpec* rhs) : - m_directory(), - m_filename() -{ - if (rhs) - *this = *rhs; -} - -//------------------------------------------------------------------ -// Virtual destrcuctor in case anyone inherits from this class. -//------------------------------------------------------------------ -FileSpec::~FileSpec() -{ -} - -//------------------------------------------------------------------ -// Assignment operator. -//------------------------------------------------------------------ -const FileSpec& -FileSpec::operator= (const FileSpec& rhs) -{ - if (this != &rhs) - { - m_directory = rhs.m_directory; - m_filename = rhs.m_filename; - m_is_resolved = rhs.m_is_resolved; - } - return *this; -} - -//------------------------------------------------------------------ -// Update the contents of this object with a new path. The path will -// be split up into a directory and filename and stored as uniqued -// string values for quick comparison and efficient memory usage. -//------------------------------------------------------------------ -void -FileSpec::SetFile (const char *pathname, bool resolve) -{ - m_filename.Clear(); - m_directory.Clear(); - m_is_resolved = false; - if (pathname == NULL || pathname[0] == '\0') - return; - - char resolved_path[PATH_MAX]; - bool path_fit = true; - - if (resolve) - { - path_fit = (FileSpec::Resolve (pathname, resolved_path, sizeof(resolved_path)) < sizeof(resolved_path) - 1); - m_is_resolved = path_fit; - } - else - { - // Copy the path because "basename" and "dirname" want to muck with the - // path buffer - if (::strlen (pathname) > sizeof(resolved_path) - 1) - path_fit = false; - else - ::strcpy (resolved_path, pathname); - } - - - if (path_fit) - { - char *filename = ::basename (resolved_path); - if (filename) - { - m_filename.SetCString (filename); - // Truncate the basename off the end of the resolved path - - // Only attempt to get the dirname if it looks like we have a path - if (strchr(resolved_path, '/')) - { - char *directory = ::dirname (resolved_path); - - // Make sure we didn't get our directory resolved to "." without having - // specified - if (directory) - m_directory.SetCString(directory); - else - { - char *last_resolved_path_slash = strrchr(resolved_path, '/'); - if (last_resolved_path_slash) - { - *last_resolved_path_slash = '\0'; - m_directory.SetCString(resolved_path); - } - } - } - } - else - m_directory.SetCString(resolved_path); - } -} - -//---------------------------------------------------------------------- -// Convert to pointer operator. This allows code to check any FileSpec -// objects to see if they contain anything valid using code such as: -// -// if (file_spec) -// {} -//---------------------------------------------------------------------- -FileSpec::operator -void*() const -{ - return (m_directory || m_filename) ? const_cast(this) : NULL; -} - -//---------------------------------------------------------------------- -// Logical NOT operator. This allows code to check any FileSpec -// objects to see if they are invalid using code such as: -// -// if (!file_spec) -// {} -//---------------------------------------------------------------------- -bool -FileSpec::operator!() const -{ - return !m_directory && !m_filename; -} - -//------------------------------------------------------------------ -// Equal to operator -//------------------------------------------------------------------ -bool -FileSpec::operator== (const FileSpec& rhs) const -{ - if (m_filename == rhs.m_filename) - { - if (m_directory == rhs.m_directory) - return true; - - // TODO: determine if we want to keep this code in here. - // The code below was added to handle a case where we were - // trying to set a file and line breakpoint and one path - // was resolved, and the other not and the directory was - // in a mount point that resolved to a more complete path: - // "/tmp/a.c" == "/private/tmp/a.c". I might end up pulling - // this out... - if (IsResolved() && rhs.IsResolved()) - { - // Both paths are resolved, no need to look further... - return false; - } - - FileSpec resolved_lhs(*this); - - // If "this" isn't resolved, resolve it - if (!IsResolved()) - { - if (resolved_lhs.ResolvePath()) - { - // This path wasn't resolved but now it is. Check if the resolved - // directory is the same as our unresolved directory, and if so, - // we can mark this object as resolved to avoid more future resolves - m_is_resolved = (m_directory == resolved_lhs.m_directory); - } - else - return false; - } - - FileSpec resolved_rhs(rhs); - if (!rhs.IsResolved()) - { - if (resolved_rhs.ResolvePath()) - { - // rhs's path wasn't resolved but now it is. Check if the resolved - // directory is the same as rhs's unresolved directory, and if so, - // we can mark this object as resolved to avoid more future resolves - rhs.m_is_resolved = (m_directory == resolved_rhs.m_directory); - } - else - return false; - } - - // If we reach this point in the code we were able to resolve both paths - // and since we only resolve the paths if the basenames are equal, then - // we can just check if both directories are equal... - return resolved_lhs.GetDirectory() == resolved_rhs.GetDirectory(); - } - return false; -} - -//------------------------------------------------------------------ -// Not equal to operator -//------------------------------------------------------------------ -bool -FileSpec::operator!= (const FileSpec& rhs) const -{ - return !(*this == rhs); -} - -//------------------------------------------------------------------ -// Less than operator -//------------------------------------------------------------------ -bool -FileSpec::operator< (const FileSpec& rhs) const -{ - return FileSpec::Compare(*this, rhs, true) < 0; -} - -//------------------------------------------------------------------ -// Dump a FileSpec object to a stream -//------------------------------------------------------------------ -Stream& -lldb_private::operator << (Stream &s, const FileSpec& f) -{ - f.Dump(&s); - return s; -} - -//------------------------------------------------------------------ -// Clear this object by releasing both the directory and filename -// string values and making them both the empty string. -//------------------------------------------------------------------ -void -FileSpec::Clear() -{ - m_directory.Clear(); - m_filename.Clear(); -} - -//------------------------------------------------------------------ -// Compare two FileSpec objects. If "full" is true, then both -// the directory and the filename must match. If "full" is false, -// then the directory names for "a" and "b" are only compared if -// they are both non-empty. This allows a FileSpec object to only -// contain a filename and it can match FileSpec objects that have -// matching filenames with different paths. -// -// Return -1 if the "a" is less than "b", 0 if "a" is equal to "b" -// and "1" if "a" is greater than "b". -//------------------------------------------------------------------ -int -FileSpec::Compare(const FileSpec& a, const FileSpec& b, bool full) -{ - int result = 0; - - // If full is true, then we must compare both the directory and filename. - - // If full is false, then if either directory is empty, then we match on - // the basename only, and if both directories have valid values, we still - // do a full compare. This allows for matching when we just have a filename - // in one of the FileSpec objects. - - if (full || (a.m_directory && b.m_directory)) - { - result = ConstString::Compare(a.m_directory, b.m_directory); - if (result) - return result; - } - return ConstString::Compare (a.m_filename, b.m_filename); -} - -bool -FileSpec::Equal (const FileSpec& a, const FileSpec& b, bool full) -{ - if (full) - return a == b; - else - return a.m_filename == b.m_filename; -} - - - -//------------------------------------------------------------------ -// Dump the object to the supplied stream. If the object contains -// a valid directory name, it will be displayed followed by a -// directory delimiter, and the filename. -//------------------------------------------------------------------ -void -FileSpec::Dump(Stream *s) const -{ - if (m_filename) - m_directory.Dump(s, ""); // Provide a default for m_directory when we dump it in case it is invalid - - if (m_directory) - { - // If dirname was valid, then we need to print a slash between - // the directory and the filename - s->PutChar('/'); - } - m_filename.Dump(s); -} - -//------------------------------------------------------------------ -// Returns true if the file exists. -//------------------------------------------------------------------ -bool -FileSpec::Exists () const -{ - struct stat file_stats; - return GetFileStats (this, &file_stats); -} - -bool -FileSpec::ResolveExecutableLocation () -{ - if (!m_directory) - { - const char *file_cstr = m_filename.GetCString(); - if (file_cstr) - { - const std::string file_str (file_cstr); - llvm::sys::Path path = llvm::sys::Program::FindProgramByName (file_str); - const std::string &path_str = path.str(); - llvm::StringRef dir_ref = llvm::sys::path::parent_path(path_str); - //llvm::StringRef dir_ref = path.getDirname(); - if (! dir_ref.empty()) - { - // FindProgramByName returns "." if it can't find the file. - if (strcmp (".", dir_ref.data()) == 0) - return false; - - m_directory.SetCString (dir_ref.data()); - if (Exists()) - return true; - else - { - // If FindProgramByName found the file, it returns the directory + filename in its return results. - // We need to separate them. - FileSpec tmp_file (dir_ref.data(), false); - if (tmp_file.Exists()) - { - m_directory = tmp_file.m_directory; - return true; - } - } - } - } - } - - return false; -} - -bool -FileSpec::ResolvePath () -{ - if (m_is_resolved) - return true; // We have already resolved this path - - char path_buf[PATH_MAX]; - if (!GetPath (path_buf, PATH_MAX)) - return false; - // SetFile(...) will set m_is_resolved correctly if it can resolve the path - SetFile (path_buf, true); - return m_is_resolved; -} - -uint64_t -FileSpec::GetByteSize() const -{ - struct stat file_stats; - if (GetFileStats (this, &file_stats)) - return file_stats.st_size; - return 0; -} - -FileSpec::FileType -FileSpec::GetFileType () const -{ - struct stat file_stats; - if (GetFileStats (this, &file_stats)) - { - mode_t file_type = file_stats.st_mode & S_IFMT; - switch (file_type) - { - case S_IFDIR: return eFileTypeDirectory; - case S_IFIFO: return eFileTypePipe; - case S_IFREG: return eFileTypeRegular; - case S_IFSOCK: return eFileTypeSocket; - case S_IFLNK: return eFileTypeSymbolicLink; - default: - break; - } - return eFileTypeUnknown; - } - return eFileTypeInvalid; -} - -TimeValue -FileSpec::GetModificationTime () const -{ - TimeValue mod_time; - struct stat file_stats; - if (GetFileStats (this, &file_stats)) - mod_time.OffsetWithSeconds(file_stats.st_mtime); - return mod_time; -} - -//------------------------------------------------------------------ -// Directory string get accessor. -//------------------------------------------------------------------ -ConstString & -FileSpec::GetDirectory() -{ - return m_directory; -} - -//------------------------------------------------------------------ -// Directory string const get accessor. -//------------------------------------------------------------------ -const ConstString & -FileSpec::GetDirectory() const -{ - return m_directory; -} - -//------------------------------------------------------------------ -// Filename string get accessor. -//------------------------------------------------------------------ -ConstString & -FileSpec::GetFilename() -{ - return m_filename; -} - -//------------------------------------------------------------------ -// Filename string const get accessor. -//------------------------------------------------------------------ -const ConstString & -FileSpec::GetFilename() const -{ - return m_filename; -} - -//------------------------------------------------------------------ -// Extract the directory and path into a fixed buffer. This is -// needed as the directory and path are stored in separate string -// values. -//------------------------------------------------------------------ -size_t -FileSpec::GetPath(char *path, size_t path_max_len) const -{ - if (path_max_len) - { - const char *dirname = m_directory.GetCString(); - const char *filename = m_filename.GetCString(); - if (dirname) - { - if (filename) - return ::snprintf (path, path_max_len, "%s/%s", dirname, filename); - else - return ::snprintf (path, path_max_len, "%s", dirname); - } - else if (filename) - { - return ::snprintf (path, path_max_len, "%s", filename); - } - } - path[0] = '\0'; - return 0; -} - -//------------------------------------------------------------------ -// Returns a shared pointer to a data buffer that contains all or -// part of the contents of a file. The data is memory mapped and -// will lazily page in data from the file as memory is accessed. -// The data that is mappped will start "file_offset" bytes into the -// file, and "file_size" bytes will be mapped. If "file_size" is -// greater than the number of bytes available in the file starting -// at "file_offset", the number of bytes will be appropriately -// truncated. The final number of bytes that get mapped can be -// verified using the DataBuffer::GetByteSize() function. -//------------------------------------------------------------------ -DataBufferSP -FileSpec::MemoryMapFileContents(off_t file_offset, size_t file_size) const -{ - DataBufferSP data_sp; - auto_ptr mmap_data(new DataBufferMemoryMap()); - if (mmap_data.get()) - { - if (mmap_data->MemoryMapFromFileSpec (this, file_offset, file_size) >= file_size) - data_sp.reset(mmap_data.release()); - } - return data_sp; -} - - -//------------------------------------------------------------------ -// Return the size in bytes that this object takes in memory. This -// returns the size in bytes of this object, not any shared string -// values it may refer to. -//------------------------------------------------------------------ -size_t -FileSpec::MemorySize() const -{ - return m_filename.MemorySize() + m_directory.MemorySize(); -} - - -size_t -FileSpec::ReadFileContents (off_t file_offset, void *dst, size_t dst_len) const -{ - size_t bytes_read = 0; - char resolved_path[PATH_MAX]; - if (GetPath(resolved_path, sizeof(resolved_path))) - { - int fd = ::open (resolved_path, O_RDONLY, 0); - if (fd != -1) - { - struct stat file_stats; - if (::fstat (fd, &file_stats) == 0) - { - // Read bytes directly into our basic_string buffer - if (file_stats.st_size > 0) - { - off_t lseek_result = 0; - if (file_offset > 0) - lseek_result = ::lseek (fd, file_offset, SEEK_SET); - - if (lseek_result == file_offset) - { - ssize_t n = ::read (fd, dst, dst_len); - if (n >= 0) - bytes_read = n; - } - } - } - } - close(fd); - } - return bytes_read; -} - -//------------------------------------------------------------------ -// Returns a shared pointer to a data buffer that contains all or -// part of the contents of a file. The data copies into a heap based -// buffer that lives in the DataBuffer shared pointer object returned. -// The data that is cached will start "file_offset" bytes into the -// file, and "file_size" bytes will be mapped. If "file_size" is -// greater than the number of bytes available in the file starting -// at "file_offset", the number of bytes will be appropriately -// truncated. The final number of bytes that get mapped can be -// verified using the DataBuffer::GetByteSize() function. -//------------------------------------------------------------------ -DataBufferSP -FileSpec::ReadFileContents (off_t file_offset, size_t file_size) const -{ - DataBufferSP data_sp; - char resolved_path[PATH_MAX]; - if (GetPath(resolved_path, sizeof(resolved_path))) - { - int fd = ::open (resolved_path, O_RDONLY, 0); - if (fd != -1) - { - struct stat file_stats; - if (::fstat (fd, &file_stats) == 0) - { - if (file_stats.st_size > 0) - { - off_t lseek_result = 0; - if (file_offset > 0) - lseek_result = ::lseek (fd, file_offset, SEEK_SET); - - if (lseek_result < 0) - { - // Get error from errno - } - else if (lseek_result == file_offset) - { - const size_t bytes_left = file_stats.st_size - file_offset; - size_t num_bytes_to_read = file_size; - if (num_bytes_to_read > bytes_left) - num_bytes_to_read = bytes_left; - - std::auto_ptr data_heap_ap; - data_heap_ap.reset(new DataBufferHeap(num_bytes_to_read, '\0')); - - if (data_heap_ap.get()) - { - ssize_t bytesRead = ::read (fd, (void *)data_heap_ap->GetBytes(), data_heap_ap->GetByteSize()); - if (bytesRead >= 0) - { - // Make sure we read exactly what we asked for and if we got - // less, adjust the array - if ((size_t)bytesRead < data_heap_ap->GetByteSize()) - data_heap_ap->SetByteSize(bytesRead); - data_sp.reset(data_heap_ap.release()); - } - } - } - } - } - } - close(fd); - } - return data_sp; -} - -size_t -FileSpec::ReadFileLines (STLStringArray &lines) -{ - lines.clear(); - char path[PATH_MAX]; - if (GetPath(path, sizeof(path))) - { - ifstream file_stream (path); - - if (file_stream) - { - std::string line; - while (getline (file_stream, line)) - lines.push_back (line); - } - } - return lines.size(); -} - -FileSpec::EnumerateDirectoryResult -FileSpec::EnumerateDirectory -( - const char *dir_path, - bool find_directories, - bool find_files, - bool find_other, - EnumerateDirectoryCallbackType callback, - void *callback_baton -) -{ - if (dir_path && dir_path[0]) - { - lldb_utility::CleanUp dir_path_dir (opendir(dir_path), NULL, closedir); - if (dir_path_dir.is_valid()) - { - struct dirent* dp; - while ((dp = readdir(dir_path_dir.get())) != NULL) - { - // Only search directories - if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) - { - size_t len = strlen(dp->d_name); - - if (len == 1 && dp->d_name[0] == '.') - continue; - - if (len == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.') - continue; - } - - bool call_callback = false; - FileSpec::FileType file_type = eFileTypeUnknown; - - switch (dp->d_type) - { - default: - case DT_UNKNOWN: file_type = eFileTypeUnknown; call_callback = true; break; - case DT_FIFO: file_type = eFileTypePipe; call_callback = find_other; break; - case DT_CHR: file_type = eFileTypeOther; call_callback = find_other; break; - case DT_DIR: file_type = eFileTypeDirectory; call_callback = find_directories; break; - case DT_BLK: file_type = eFileTypeOther; call_callback = find_other; break; - case DT_REG: file_type = eFileTypeRegular; call_callback = find_files; break; - case DT_LNK: file_type = eFileTypeSymbolicLink; call_callback = find_other; break; - case DT_SOCK: file_type = eFileTypeSocket; call_callback = find_other; break; - case DT_WHT: file_type = eFileTypeOther; call_callback = find_other; break; - } - - if (call_callback) - { - char child_path[PATH_MAX]; - const int child_path_len = ::snprintf (child_path, sizeof(child_path), "%s/%s", dir_path, dp->d_name); - if (child_path_len < sizeof(child_path) - 1) - { - // Don't resolve the file type or path - FileSpec child_path_spec (child_path, false); - - EnumerateDirectoryResult result = callback (callback_baton, file_type, child_path_spec); - - switch (result) - { - default: - case eEnumerateDirectoryResultNext: - // Enumerate next entry in the current directory. We just - // exit this switch and will continue enumerating the - // current directory as we currently are... - break; - - case eEnumerateDirectoryResultEnter: // Recurse into the current entry if it is a directory or symlink, or next if not - if (FileSpec::EnumerateDirectory (child_path, - find_directories, - find_files, - find_other, - callback, - callback_baton) == eEnumerateDirectoryResultQuit) - { - // The subdirectory returned Quit, which means to - // stop all directory enumerations at all levels. - return eEnumerateDirectoryResultQuit; - } - break; - - case eEnumerateDirectoryResultExit: // Exit from the current directory at the current level. - // Exit from this directory level and tell parent to - // keep enumerating. - return eEnumerateDirectoryResultNext; - - case eEnumerateDirectoryResultQuit: // Stop directory enumerations at any level - return eEnumerateDirectoryResultQuit; - } - } - } - } - } - } - // By default when exiting a directory, we tell the parent enumeration - // to continue enumerating. - return eEnumerateDirectoryResultNext; -} - Modified: lldb/trunk/source/Core/PluginManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Core/PluginManager.cpp (original) +++ lldb/trunk/source/Core/PluginManager.cpp Mon Feb 7 23:05:52 2011 @@ -13,7 +13,7 @@ #include #include "lldb/Core/Error.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/Mutex.h" Copied: lldb/trunk/source/Host/common/FileSpec.cpp (from r125077, lldb/trunk/source/Core/FileSpec.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?p2=lldb/trunk/source/Host/common/FileSpec.cpp&p1=lldb/trunk/source/Core/FileSpec.cpp&r1=125077&r2=125078&rev=125078&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Host/common/FileSpec.cpp Mon Feb 7 23:05:52 2011 @@ -24,7 +24,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataBufferMemoryMap.h" #include "lldb/Core/Stream.h" Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Mon Feb 7 23:05:52 2011 @@ -11,7 +11,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Error.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/Config.h" Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Mon Feb 7 23:05:52 2011 @@ -21,7 +21,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Communication.h" #include "lldb/Core/ConnectionFileDescriptor.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Mon Feb 7 23:05:52 2011 @@ -21,7 +21,7 @@ // These are for the Sourcename completers. // FIXME: Make a separate file for the completers. -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Mon Feb 7 23:05:52 2011 @@ -20,7 +20,7 @@ #include "llvm/Support/MachO.h" #include "lldb/Target/DynamicLoader.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/UUID.h" #include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Mon Feb 7 23:05:52 2011 @@ -18,7 +18,7 @@ #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h (original) +++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h Mon Feb 7 23:05:52 2011 @@ -14,7 +14,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/ConstString.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Host/TimeValue.h" Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h (original) +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h Mon Feb 7 23:05:52 2011 @@ -11,7 +11,7 @@ #define liblldb_ObjectContainerUniversalMachO_h_ #include "lldb/Symbol/ObjectContainer.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/MachO.h" Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Mon Feb 7 23:05:52 2011 @@ -14,7 +14,7 @@ #include #include "lldb/lldb-private.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ObjectFile.h" #include "ELFHeader.h" Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Feb 7 23:05:52 2011 @@ -11,7 +11,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataBuffer.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Mon Feb 7 23:05:52 2011 @@ -12,7 +12,7 @@ #include "llvm/Support/MachO.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Mon Feb 7 23:05:52 2011 @@ -27,7 +27,7 @@ #include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/ArchSpec.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125078&r1=125077&r2=125078&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Feb 7 23:05:52 2011 @@ -24,7 +24,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/ConnectionFileDescriptor.h" -#include "lldb/Core/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Core/InputReader.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" From jingham at apple.com Mon Feb 7 23:15:05 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 08 Feb 2011 05:15:05 -0000 Subject: [Lldb-commits] [lldb] r125079 - /lldb/trunk/include/lldb/Core/Listener.h Message-ID: <20110208051505.5A37D2A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 23:15:05 2011 New Revision: 125079 URL: http://llvm.org/viewvc/llvm-project?rev=125079&view=rev Log: Add a GetName interface to the Listener for logging purposes. Modified: lldb/trunk/include/lldb/Core/Listener.h Modified: lldb/trunk/include/lldb/Core/Listener.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Listener.h?rev=125079&r1=125078&r2=125079&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Listener.h (original) +++ lldb/trunk/include/lldb/Core/Listener.h Mon Feb 7 23:15:05 2011 @@ -46,6 +46,12 @@ void Clear (); + const char * + GetName () + { + return m_name.c_str(); + } + uint32_t StartListeningForEvents (Broadcaster* broadcaster, uint32_t event_mask); From jingham at apple.com Mon Feb 7 23:16:50 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 08 Feb 2011 05:16:50 -0000 Subject: [Lldb-commits] [lldb] r125080 - in /lldb/trunk: include/lldb/Core/Broadcaster.h source/Core/Broadcaster.cpp Message-ID: <20110208051650.335ED2A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 23:16:50 2011 New Revision: 125080 URL: http://llvm.org/viewvc/llvm-project?rev=125080&view=rev Log: Change the Hijacking interposer to a stack of interposers. Modified: lldb/trunk/include/lldb/Core/Broadcaster.h lldb/trunk/source/Core/Broadcaster.cpp Modified: lldb/trunk/include/lldb/Core/Broadcaster.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Broadcaster.h?rev=125080&r1=125079&r2=125080&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Broadcaster.h (original) +++ lldb/trunk/include/lldb/Core/Broadcaster.h Mon Feb 7 23:16:50 2011 @@ -195,9 +195,6 @@ bool RemoveListener (Listener* listener, uint32_t event_mask = UINT32_MAX); -protected: - - //------------------------------------------------------------------ /// Provides a simple mechanism to temporarily redirect events from /// broadcaster. When you call this function passing in a listener and @@ -225,8 +222,8 @@ bool IsHijackedForEvent (uint32_t event_mask) { - if (m_hijacking_listener) - return (event_mask & m_hijacking_mask) != 0; + if (m_hijacking_listeners.size() > 0) + return (event_mask & m_hijacking_masks.back()) != 0; return false; } @@ -237,6 +234,9 @@ void RestoreBroadcaster (); +protected: + + void PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique); @@ -251,8 +251,9 @@ event_names_map m_event_names; ///< Optionally define event names for readability and logging for each event bit collection m_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster. Mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners. - Listener *m_hijacking_listener; // A simple mechanism to intercept events in lieu of a real Listener collection stack. - uint32_t m_hijacking_mask; + std::vector m_hijacking_listeners; // A simple mechanism to intercept events from a broadcaster + std::vector m_hijacking_masks; // At some point we may want to have a stack or Listener + // collections, but for now this is just for private hijacking. private: //------------------------------------------------------------------ Modified: lldb/trunk/source/Core/Broadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Broadcaster.cpp?rev=125080&r1=125079&r2=125080&view=diff ============================================================================== --- lldb/trunk/source/Core/Broadcaster.cpp (original) +++ lldb/trunk/source/Core/Broadcaster.cpp Mon Feb 7 23:16:50 2011 @@ -25,8 +25,8 @@ m_broadcaster_name (name), m_listeners (), m_listeners_mutex (Mutex::eMutexTypeRecursive), - m_hijacking_listener(NULL), - m_hijacking_mask(UINT32_MAX) + m_hijacking_listeners(), + m_hijacking_masks() { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) @@ -153,7 +153,7 @@ { Mutex::Locker locker (m_listeners_mutex); - if (m_hijacking_listener != NULL && event_type & m_hijacking_mask) + if (m_hijacking_listeners.size() > 0 && event_type & m_hijacking_masks.back()) return true; if (m_listeners.empty()) @@ -224,19 +224,22 @@ m_broadcaster_name.AsCString(""), event_description.GetData(), unique, - m_hijacking_listener); + m_hijacking_listeners.back()); } - if (m_hijacking_listener != NULL && m_hijacking_mask & event_type) + if (m_hijacking_listeners.size() > 0 && m_hijacking_masks.back() & event_type) { + Listener *hijacking_listener = m_hijacking_listeners.back(); // FIXME: REMOVE THIS EXTRA LOGGING LogSP log_process(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log_process) - log_process->Printf ("Hijacking event delivery for Broadcaster(\"%s\").", m_broadcaster_name.AsCString("")); + log_process->Printf ("Hijacking event delivery for Broadcaster(\"%s\") to Listener(\"%s\").", + m_broadcaster_name.AsCString(""), + hijacking_listener->GetName()); - if (unique && m_hijacking_listener->PeekAtNextEventForBroadcasterWithType (this, event_type)) + if (unique && hijacking_listener->PeekAtNextEventForBroadcasterWithType (this, event_type)) return; - m_hijacking_listener->AddEvent (event_sp); + hijacking_listener->AddEvent (event_sp); } else { @@ -276,13 +279,9 @@ Broadcaster::HijackBroadcaster (Listener *listener, uint32_t event_mask) { Mutex::Locker event_types_locker(m_listeners_mutex); - assert (m_hijacking_listener == NULL); - if (m_hijacking_listener != NULL) - return false; - - m_hijacking_listener = listener; - m_hijacking_mask = event_mask; + m_hijacking_listeners.push_back(listener); + m_hijacking_masks.push_back(event_mask); return true; } @@ -290,7 +289,7 @@ Broadcaster::RestoreBroadcaster () { Mutex::Locker event_types_locker(m_listeners_mutex); - m_hijacking_listener = NULL; - m_hijacking_mask = 0; + m_hijacking_listeners.pop_back(); + m_hijacking_masks.pop_back(); } From jingham at apple.com Mon Feb 7 23:19:01 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 08 Feb 2011 05:19:01 -0000 Subject: [Lldb-commits] [lldb] r125081 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110208051901.E621B2A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 23:19:01 2011 New Revision: 125081 URL: http://llvm.org/viewvc/llvm-project?rev=125081&view=rev Log: Add _pthread_wqthread to the list of thread stop points, and change the logging a bit. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125081&r1=125080&r2=125081&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Feb 7 23:19:01 2011 @@ -2405,6 +2405,7 @@ static const char *bp_names[] = { "start_wqthread", + "_pthread_wqthread", "_pthread_start", NULL }; @@ -2451,18 +2452,18 @@ bool ProcessGDBRemote::StopNoticingNewThreads() { + LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + if (log) + log->Printf ("Disabling new thread notification breakpoint."); size_t num_bps = m_thread_observation_bps.size(); if (num_bps != 0) { for (int i = 0; i < num_bps; i++) { - LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); lldb::BreakpointSP break_sp = m_target.GetBreakpointByID(m_thread_observation_bps[i]); if (break_sp) { - if (log) - log->Printf ("Disabling new thread notification breakpoint."); break_sp->SetEnabled(false); } } From gclayton at apple.com Mon Feb 7 23:19:07 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 05:19:07 -0000 Subject: [Lldb-commits] [lldb] r125082 - in /lldb/trunk: include/lldb/Host/FileSpec.h source/Core/StreamFile.cpp source/Host/common/FileSpec.cpp Message-ID: <20110208051907.1FE032A6C12D@llvm.org> Author: gclayton Date: Mon Feb 7 23:19:06 2011 New Revision: 125082 URL: http://llvm.org/viewvc/llvm-project?rev=125082&view=rev Log: A bit more cleanup with respect to using LLDB_CONFIG_XXX defines outside of the lldb/source/Host/*.cpp and lldb/source/Host/*/*.cpp directories. The only offenders are the command completion and the StreamFile.cpp. I will soon modify StreamFile.cpp to use a lldb/source/Host/File.cpp so that all file open, close, read, write, seek, are abstracted into the host layer as well, then this will be gone. Modified: lldb/trunk/include/lldb/Host/FileSpec.h lldb/trunk/source/Core/StreamFile.cpp lldb/trunk/source/Host/common/FileSpec.cpp Modified: lldb/trunk/include/lldb/Host/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=125082&r1=125081&r2=125082&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/FileSpec.h (original) +++ lldb/trunk/include/lldb/Host/FileSpec.h Mon Feb 7 23:19:06 2011 @@ -15,7 +15,6 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/STLUtils.h" #include "lldb/Host/TimeValue.h" -#include "lldb/Host/Config.h" namespace lldb_private { @@ -521,9 +520,6 @@ static size_t Resolve (const char *src_path, char *dst_path, size_t dst_len); -#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER - - //------------------------------------------------------------------ /// Resolves the user name at the beginning of \a src_path, and writes the output /// to \a dst_path. Note, \a src_path can contain other path components after the @@ -548,8 +544,6 @@ static size_t ResolveUsername (const char *src_path, char *dst_path, size_t dst_len); -#endif - enum EnumerateDirectoryResult { eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory Modified: lldb/trunk/source/Core/StreamFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StreamFile.cpp?rev=125082&r1=125081&r2=125082&view=diff ============================================================================== --- lldb/trunk/source/Core/StreamFile.cpp (original) +++ lldb/trunk/source/Core/StreamFile.cpp Mon Feb 7 23:19:06 2011 @@ -98,6 +98,8 @@ void StreamFile::SetLineBuffered () { + // TODO: check if we can get rid of this LLDB_CONFIG if we do a: + // setvbuf(m_file, (char *)NULL, _IOLBF, 0); #ifdef LLDB_CONFIG_SUPPORTS_SETLINEBUFFERED if (m_file != NULL) setlinebuf (m_file); Modified: lldb/trunk/source/Host/common/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=125082&r1=125081&r2=125082&view=diff ============================================================================== --- lldb/trunk/source/Host/common/FileSpec.cpp (original) +++ lldb/trunk/source/Host/common/FileSpec.cpp Mon Feb 7 23:19:06 2011 @@ -63,6 +63,8 @@ return g_tilde.c_str(); } +#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER + // Resolves the username part of a path of the form ~user/other/directories, and // writes the result into dst_path. // Returns 0 if there WAS a ~ in the path but the username couldn't be resolved. @@ -71,11 +73,14 @@ size_t FileSpec::ResolveUsername (const char *src_path, char *dst_path, size_t dst_len) { + if (src_path == NULL || src_path[0] == '\0') + return 0; + +#ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER + char user_home[PATH_MAX]; const char *user_name; - if (src_path == NULL || src_path[0] == '\0') - return 0; // If there's no ~, then just copy src_path straight to dst_path (they may be the same string...) if (src_path[0] != '~') @@ -133,8 +138,11 @@ return 0; else return ::snprintf (dst_path, dst_len, "%s%s", home_dir, remainder); +#else + // Resolving home directories is not supported, just copy the path... + return ::snprintf (dst_path, dst_len, "%s", src_path); +#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER } -#endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER size_t FileSpec::Resolve (const char *src_path, char *dst_path, size_t dst_len) From jingham at apple.com Mon Feb 7 23:21:00 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 08 Feb 2011 05:21:00 -0000 Subject: [Lldb-commits] [lldb] r125083 - in /lldb/trunk: include/lldb/Target/Process.h include/lldb/Target/Thread.h source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp source/Target/Process.cpp source/Target/StopInfo.cpp source/Target/Thread.cpp source/Target/ThreadPlanBase.cpp tools/debugserver/source/MacOSX/MachThreadList.cpp Message-ID: <20110208052100.1C54E2A6C12C@llvm.org> Author: jingham Date: Mon Feb 7 23:20:59 2011 New Revision: 125083 URL: http://llvm.org/viewvc/llvm-project?rev=125083&view=rev Log: Rework the RunThreadPlan event handling to use Event Hijacking not stopping the event thread. Also clarify the logic of the function. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanBase.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Feb 7 23:20:59 2011 @@ -1676,6 +1676,26 @@ PeekAtStateChangedEvents (); + class + ProcessEventHijacker + { + public: + ProcessEventHijacker (Process &process, Listener *listener) : + m_process (process), + m_listener (listener) + { + m_process.HijackProcessEvents (listener); + } + ~ProcessEventHijacker () + { + m_process.RestoreProcessEvents(); + } + + private: + Process &m_process; + Listener *m_listener; + }; + friend class ProcessEventHijacker; //------------------------------------------------------------------ /// If you need to ensure that you and only you will hear about some public /// event, then make a new listener, set to listen to process events, and @@ -1892,6 +1912,11 @@ DISALLOW_COPY_AND_ASSIGN (MemoryCache); }; + bool + HijackPrivateProcessEvents (Listener *listener); + + void + RestorePrivateProcessEvents (); //------------------------------------------------------------------ // Member variables Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Mon Feb 7 23:20:59 2011 @@ -553,6 +553,16 @@ ThreadPlan * GetCurrentPlan (); +private: + bool + PlanIsBasePlan (ThreadPlan *plan_ptr) + { + if (m_plan_stack.size() == 0) + return false; + return m_plan_stack[0].get() == plan_ptr; + } +public: + //------------------------------------------------------------------ /// Gets the inner-most plan that was popped off the plan stack in the /// most recent stop. Useful for printing the stop reason accurately. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Mon Feb 7 23:20:59 2011 @@ -13,6 +13,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/State.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" @@ -88,6 +89,9 @@ Thread::WillResume(resume_state); int signo = GetResumeSignal(); + lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP)); + if (log) + log->Printf ("Resuming thread: %4.4x with state: %s.", GetID(), StateAsCString(resume_state)); switch (resume_state) { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Feb 7 23:20:59 2011 @@ -393,6 +393,23 @@ RestoreBroadcaster(); } +bool +Process::HijackPrivateProcessEvents (Listener *listener) +{ + if (listener != NULL) + { + return m_private_state_broadcaster.HijackBroadcaster(listener, eBroadcastBitStateChanged); + } + else + return false; +} + +void +Process::RestorePrivateProcessEvents () +{ + m_private_state_broadcaster.RestoreBroadcaster(); +} + StateType Process::WaitForStateChangedEvents (const TimeValue *timeout, EventSP &event_sp) { @@ -1827,7 +1844,8 @@ { // Pause our private state thread so we can ensure no one else eats // the stop event out from under us. - PausePrivateStateThread(); + Listener halt_listener ("lldb.process.halt_listener"); + HijackPrivateProcessEvents(&halt_listener); EventSP event_sp; Error error (WillHalt()); @@ -1856,16 +1874,17 @@ // a halt command. if (caused_stop) { - // Wait for 2 seconds for the process to stop. + // Wait for 1 second for the process to stop. TimeValue timeout_time; timeout_time = TimeValue::Now(); timeout_time.OffsetWithSeconds(1); - StateType state = WaitForStateChangedEventsPrivate (&timeout_time, event_sp); + bool got_event = halt_listener.WaitForEvent (&timeout_time, event_sp); + StateType state = ProcessEventData::GetStateFromEvent(event_sp.get()); - if (state == eStateInvalid) + if (!got_event || state == eStateInvalid) { // We timeout out and didn't get a stop event... - error.SetErrorString ("Halt timed out."); + error.SetErrorStringWithFormat ("Halt timed out. State = %s", StateAsCString(GetState())); } else { @@ -1890,7 +1909,7 @@ } } // Resume our private state thread before we post the event (if any) - ResumePrivateStateThread(); + RestorePrivateProcessEvents(); // Post any event we might have consumed. If all goes well, we will have // stopped the process, intercepted the event and set the interrupted @@ -2728,8 +2747,7 @@ if (m_private_state.GetValue() != eStateStopped) { errors.Printf ("RunThreadPlan called while the private state was not stopped."); - // REMOVE BEAR TRAP... - // abort(); + return lldb::eExecutionSetupError; } // Save this value for restoration of the execution context after we run @@ -2755,73 +2773,190 @@ exe_ctx.thread->QueueThreadPlan(thread_plan_sp, true); Listener listener("lldb.process.listener.run-thread-plan"); - exe_ctx.process->HijackProcessEvents(&listener); + + // This process event hijacker Hijacks the Public events and its destructor makes sure that the process events get + // restored on exit to the function. + + ProcessEventHijacker run_thread_plan_hijacker (*this, &listener); lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS)); if (log) { StreamString s; thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); - log->Printf ("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4x to run thread plan \"%s\".", exe_ctx.thread->GetIndexID(), exe_ctx.thread->GetID(), s.GetData()); - } - - Error resume_error = exe_ctx.process->Resume (); - if (!resume_error.Success()) - { - errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString()); - exe_ctx.process->RestoreProcessEvents(); - return lldb::eExecutionSetupError; + log->Printf ("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4x to run thread plan \"%s\".", + exe_ctx.thread->GetIndexID(), + exe_ctx.thread->GetID(), + s.GetData()); } - // We need to call the function synchronously, so spin waiting for it to return. - // If we get interrupted while executing, we're going to lose our context, and - // won't be able to gather the result at this point. - // We set the timeout AFTER the resume, since the resume takes some time and we - // don't want to charge that to the timeout. + bool got_event; + lldb::EventSP event_sp; + lldb::StateType stop_state = lldb::eStateInvalid; TimeValue* timeout_ptr = NULL; TimeValue real_timeout; - if (single_thread_timeout_usec != 0) - { - real_timeout = TimeValue::Now(); - real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec); - timeout_ptr = &real_timeout; - } + bool first_timeout = true; + bool do_resume = true; while (1) { - lldb::EventSP event_sp; - lldb::StateType stop_state = lldb::eStateInvalid; + // We usually want to resume the process if we get to the top of the loop. + // The only exception is if we get two running events with no intervening + // stop, which can happen, we will just wait for then next stop event. + + if (do_resume) + { + // Do the initial resume and wait for the running event before going further. + + Error resume_error = exe_ctx.process->Resume (); + if (!resume_error.Success()) + { + errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString()); + return_value = lldb::eExecutionSetupError; + break; + } + + real_timeout = TimeValue::Now(); + real_timeout.OffsetWithMicroSeconds(500000); + timeout_ptr = &real_timeout; + + got_event = listener.WaitForEvent(NULL, event_sp); + if (!got_event) + { + if (log) + log->Printf("Didn't get any event after initial resume, exiting."); + + errors.Printf("Didn't get any event after initial resume, exiting."); + return_value = lldb::eExecutionSetupError; + break; + } + + stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); + if (stop_state != eStateRunning) + { + if (log) + log->Printf("Didn't get running event after initial resume, got %s instead.", StateAsCString(stop_state)); + + errors.Printf("Didn't get running event after initial resume, got %s instead.", StateAsCString(stop_state)); + return_value = lldb::eExecutionSetupError; + break; + } + + if (log) + log->Printf ("Resuming succeeded."); + // We need to call the function synchronously, so spin waiting for it to return. + // If we get interrupted while executing, we're going to lose our context, and + // won't be able to gather the result at this point. + // We set the timeout AFTER the resume, since the resume takes some time and we + // don't want to charge that to the timeout. + + if (single_thread_timeout_usec != 0) + { + real_timeout = TimeValue::Now(); + if (first_timeout) + real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec); + else + real_timeout.OffsetWithSeconds(10); + + timeout_ptr = &real_timeout; + } + } + else + { + if (log) + log->Printf ("Handled an extra running event."); + do_resume = true; + } + // Now wait for the process to stop again: - bool got_event = listener.WaitForEvent (timeout_ptr, event_sp); + stop_state = lldb::eStateInvalid; + event_sp.reset(); + got_event = listener.WaitForEvent (timeout_ptr, event_sp); - if (!got_event) + if (got_event) { - // Right now this is the only way to tell we've timed out... - // We should interrupt the process here... + if (event_sp.get()) + { + bool keep_going = false; + stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); + if (log) + log->Printf("In while loop, got event: %s.", StateAsCString(stop_state)); + + switch (stop_state) + { + case lldb::eStateStopped: + // Yay, we're done. + if (log) + log->Printf ("Execution completed successfully."); + return_value = lldb::eExecutionCompleted; + break; + case lldb::eStateCrashed: + if (log) + log->Printf ("Execution crashed."); + return_value = lldb::eExecutionInterrupted; + break; + case lldb::eStateRunning: + do_resume = false; + keep_going = true; + break; + default: + if (log) + log->Printf("Execution stopped with unexpected state: %s.", StateAsCString(stop_state)); + return_value = lldb::eExecutionInterrupted; + break; + } + if (keep_going) + continue; + else + break; + } + else + { + if (log) + log->Printf ("got_event was true, but the event pointer was null. How odd..."); + return_value = lldb::eExecutionInterrupted; + break; + } + } + else + { + // If we didn't get an event that means we've timed out... + // We will interrupt the process here. Depending on what we were asked to do we will + // either exit, or try with all threads running for the same timeout. // Not really sure what to do if Halt fails here... + if (log) { if (try_all_threads) - log->Printf ("Process::RunThreadPlan(): Running function with timeout: %d timed out, trying with all threads enabled.", - single_thread_timeout_usec); + { + if (first_timeout) + log->Printf ("Process::RunThreadPlan(): Running function with timeout: %d timed out, " + "trying with all threads enabled.", + single_thread_timeout_usec); + else + log->Printf ("Process::RunThreadPlan(): Restarting function with all threads enabled " + "and timeout: %d timed out.", + single_thread_timeout_usec); + } else - log->Printf ("Process::RunThreadPlan(): Running function with timeout: %d timed out, abandoning execution.", + log->Printf ("Process::RunThreadPlan(): Running function with timeout: %d timed out, " + "halt and abandoning execution.", single_thread_timeout_usec); } Error halt_error = exe_ctx.process->Halt(); - if (halt_error.Success()) { - timeout_ptr = NULL; if (log) log->Printf ("Process::RunThreadPlan(): Halt succeeded."); - // Between the time that we got the timeout and the time we halted, but target - // might have actually completed the plan. If so, we're done. Note, I call WFE here with a short - // timeout to - got_event = listener.WaitForEvent(NULL, event_sp); + // If halt succeeds, it always produces a stopped event. Wait for that: + + real_timeout = TimeValue::Now(); + real_timeout.OffsetWithMicroSeconds(500000); + + got_event = listener.WaitForEvent(&real_timeout, event_sp); if (got_event) { @@ -2829,184 +2964,253 @@ if (log) { log->Printf ("Process::RunThreadPlan(): Stopped with event: %s", StateAsCString(stop_state)); - if (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent(event_sp.get())) + if (stop_state == lldb::eStateStopped + && Process::ProcessEventData::GetInterruptedFromEvent(event_sp.get())) log->Printf (" Event was the Halt interruption event."); } - if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + if (stop_state == lldb::eStateStopped) { - if (log) - log->Printf ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. Exiting wait loop."); - return_value = lldb::eExecutionCompleted; - break; - } + // Between the time we initiated the Halt and the time we delivered it, the process could have + // already finished its job. Check that here: + + if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + { + if (log) + log->Printf ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " + "Exiting wait loop."); + return_value = lldb::eExecutionCompleted; + break; + } - if (try_all_threads - && (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent (event_sp.get()))) - { + if (!try_all_threads) + { + if (log) + log->Printf ("try_all_threads was false, we stopped so now we're quitting."); + return_value = lldb::eExecutionInterrupted; + break; + } - thread_plan_sp->SetStopOthers (false); - if (log) - log->Printf ("Process::RunThreadPlan(): About to resume."); + if (first_timeout) + { + // Set all the other threads to run, and return to the top of the loop, which will continue; + first_timeout = false; + thread_plan_sp->SetStopOthers (false); + if (log) + log->Printf ("Process::RunThreadPlan(): About to resume."); - exe_ctx.process->Resume(); - continue; - } - else - { - exe_ctx.process->RestoreProcessEvents (); - return lldb::eExecutionInterrupted; + continue; + } + else + { + // Running all threads failed, so return Interrupted. + if (log) + log->Printf("Process::RunThreadPlan(): running all threads timed out."); + return_value = lldb::eExecutionInterrupted; + break; + } } } + else + { if (log) + log->Printf("Process::RunThreadPlan(): halt said it succeeded, but I got no event. " + "I'm getting out of here passing Interrupted."); + return_value = lldb::eExecutionInterrupted; + break; + } } else { - + // This branch is to work around some problems with gdb-remote's Halt. It is a little racy, and can return + // an error from halt, but if you wait a bit you'll get a stopped event anyway. if (log) - log->Printf ("Process::RunThreadPlan(): halt failed: error = \"%s\", I'm just going to wait a little longer and see if the world gets nicer to me.", - halt_error.AsCString()); -// abort(); - - if (single_thread_timeout_usec != 0) + log->Printf ("Process::RunThreadPlan(): halt failed: error = \"%s\", I'm just going to wait a little longer and see if I get a stopped event.", + halt_error.AsCString()); + real_timeout = TimeValue::Now(); + real_timeout.OffsetWithMicroSeconds(500000); + timeout_ptr = &real_timeout; + got_event = listener.WaitForEvent(&real_timeout, event_sp); + if (!got_event || event_sp.get() == NULL) { - real_timeout = TimeValue::Now(); - real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec); - timeout_ptr = &real_timeout; + // This is not going anywhere, bag out. + if (log) + log->Printf ("Process::RunThreadPlan(): halt failed: and waiting for the stopped event failed."); + return_value = lldb::eExecutionInterrupted; + break; + } + else + { + stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); + if (log) + log->Printf ("Process::RunThreadPlan(): halt failed: but then I got a stopped event. Whatever..."); + if (stop_state == lldb::eStateStopped) + { + // Between the time we initiated the Halt and the time we delivered it, the process could have + // already finished its job. Check that here: + + if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + { + if (log) + log->Printf ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " + "Exiting wait loop."); + return_value = lldb::eExecutionCompleted; + break; + } + + if (first_timeout) + { + // Set all the other threads to run, and return to the top of the loop, which will continue; + first_timeout = false; + thread_plan_sp->SetStopOthers (false); + if (log) + log->Printf ("Process::RunThreadPlan(): About to resume."); + + continue; + } + else + { + // Running all threads failed, so return Interrupted. + if (log) + log->Printf("Process::RunThreadPlan(): running all threads timed out."); + return_value = lldb::eExecutionInterrupted; + break; + } + } + else + { + log->Printf ("Process::RunThreadPlan(): halt failed, I waited and didn't get" + " a stopped event, instead got %s.", StateAsCString(stop_state)); + return_value = lldb::eExecutionInterrupted; + break; + } } - continue; } } - stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); + } // END WAIT LOOP + + // Now do some processing on the results of the run: + if (return_value == eExecutionInterrupted) + { if (log) - log->Printf("Process::RunThreadPlan(): got event: %s.", StateAsCString(stop_state)); - - if (stop_state == lldb::eStateRunning || stop_state == lldb::eStateStepping) - continue; - - if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) - { - if (log) - log->Printf("Process::RunThreadPlan(): thread plan is done"); - return_value = lldb::eExecutionCompleted; - break; - } - else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get())) - { - if (log) - log->Printf("Process::RunThreadPlan(): thread plan was discarded"); - return_value = lldb::eExecutionDiscarded; - break; - } - else { - if (log) + StreamString s; + if (event_sp) + event_sp->Dump (&s); + else { - StreamString s; - if (event_sp) - event_sp->Dump (&s); - else + log->Printf ("Process::RunThreadPlan(): Stop event that interrupted us is NULL."); + } + + StreamString ts; + + const char *event_explanation; + + do + { + const Process::ProcessEventData *event_data = Process::ProcessEventData::GetEventDataFromEvent (event_sp.get()); + + if (!event_data) { - log->Printf ("Process::RunThreadPlan(): Stop event that interrupted us is NULL."); + event_explanation = ""; + break; } + + Process *process = event_data->GetProcessSP().get(); - StreamString ts; - - const char *event_explanation; + if (!process) + { + event_explanation = ""; + break; + } + + ThreadList &thread_list = process->GetThreadList(); + + uint32_t num_threads = thread_list.GetSize(); + uint32_t thread_index; + + ts.Printf("<%u threads> ", num_threads); - do + for (thread_index = 0; + thread_index < num_threads; + ++thread_index) { - const Process::ProcessEventData *event_data = Process::ProcessEventData::GetEventDataFromEvent (event_sp.get()); - - if (!event_data) - { - event_explanation = ""; - break; - } + Thread *thread = thread_list.GetThreadAtIndex(thread_index).get(); - Process *process = event_data->GetProcessSP().get(); - - if (!process) + if (!thread) { - event_explanation = ""; - break; + ts.Printf(" "); + continue; } - ThreadList &thread_list = process->GetThreadList(); - - uint32_t num_threads = thread_list.GetSize(); - uint32_t thread_index; - - ts.Printf("<%u threads> ", num_threads); + ts.Printf("<0x%4.4x ", thread->GetID()); + RegisterContext *register_context = thread->GetRegisterContext().get(); - for (thread_index = 0; - thread_index < num_threads; - ++thread_index) - { - Thread *thread = thread_list.GetThreadAtIndex(thread_index).get(); - - if (!thread) - { - ts.Printf(" "); - continue; - } - - ts.Printf("<0x%4.4x ", thread->GetID()); - RegisterContext *register_context = thread->GetRegisterContext().get(); - - if (register_context) - ts.Printf("[ip 0x%llx] ", register_context->GetPC()); - else - ts.Printf("[ip unknown] "); - - lldb::StopInfoSP stop_info_sp = thread->GetStopInfo(); - if (stop_info_sp) - { - const char *stop_desc = stop_info_sp->GetDescription(); - if (stop_desc) - ts.PutCString (stop_desc); - } - ts.Printf(">"); - } + if (register_context) + ts.Printf("[ip 0x%llx] ", register_context->GetPC()); + else + ts.Printf("[ip unknown] "); - event_explanation = ts.GetData(); - } while (0); - - // See if any of the threads that stopped think we ought to stop. Otherwise continue on. - if (!GetThreadList().ShouldStop(event_sp.get())) - { - if (log) - log->Printf("Process::RunThreadPlan(): execution interrupted, but nobody wanted to stop, so we continued: %s %s", - s.GetData(), event_explanation); - if (single_thread_timeout_usec != 0) + lldb::StopInfoSP stop_info_sp = thread->GetStopInfo(); + if (stop_info_sp) { - real_timeout = TimeValue::Now(); - real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec); - timeout_ptr = &real_timeout; + const char *stop_desc = stop_info_sp->GetDescription(); + if (stop_desc) + ts.PutCString (stop_desc); } - - continue; + ts.Printf(">"); } - else - { - if (log) - log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s", s.GetData(), event_explanation); - } - } + + event_explanation = ts.GetData(); + } while (0); + if (log) + log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s", s.GetData(), event_explanation); + if (discard_on_error && thread_plan_sp) { exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); } - return_value = lldb::eExecutionInterrupted; - break; } } - - if (exe_ctx.process) - exe_ctx.process->RestoreProcessEvents (); + else if (return_value == eExecutionSetupError) + { + if (log) + log->Printf("Process::RunThreadPlan(): execution set up error."); + if (discard_on_error && thread_plan_sp) + { + exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + } + } + else + { + if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + { + if (log) + log->Printf("Process::RunThreadPlan(): thread plan is done"); + return_value = lldb::eExecutionCompleted; + } + else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get())) + { + if (log) + log->Printf("Process::RunThreadPlan(): thread plan was discarded"); + return_value = lldb::eExecutionDiscarded; + } + else + { + if (log) + log->Printf("Process::RunThreadPlan(): thread plan stopped in mid course"); + if (discard_on_error && thread_plan_sp) + { + if (log) + log->Printf("Process::RunThreadPlan(): discarding thread plan 'cause discard_on_error is set."); + exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + } + } + } + // Thread we ran the function in may have gone away because we ran the target // Check that it's still there. exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get(); Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Mon Feb 7 23:20:59 2011 @@ -59,7 +59,8 @@ StopInfo (thread, break_id), m_description(), m_should_stop (false), - m_should_stop_is_valid (false) + m_should_stop_is_valid (false), + m_should_perform_action (true) { } @@ -67,7 +68,8 @@ StopInfo (thread, break_id), m_description(), m_should_stop (should_stop), - m_should_stop_is_valid (true) + m_should_stop_is_valid (true), + m_should_perform_action (true) { } @@ -115,6 +117,10 @@ virtual void PerformAction (Event *event_ptr) { + if (!m_should_perform_action) + return; + m_should_perform_action = false; + BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value)); if (bp_site_sp) { @@ -189,6 +195,8 @@ std::string m_description; bool m_should_stop; bool m_should_stop_is_valid; + bool m_should_perform_action; // Since we are trying to preserve the "state" of the system even if we run functions + // etc. behind the users backs, we need to make sure we only REALLY perform the action once. }; Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Mon Feb 7 23:20:59 2011 @@ -259,38 +259,56 @@ if (current_plan->PlanExplainsStop()) { bool over_ride_stop = current_plan->ShouldAutoContinue(event_ptr); - while (1) + + // We're starting from the base plan, so just let it decide; + if (PlanIsBasePlan(current_plan)) + { + should_stop = current_plan->ShouldStop (event_ptr); + if (log) + log->Printf("Base plan says should stop: %d.", current_plan->GetName(), should_stop); + } + else { - should_stop = current_plan->ShouldStop(event_ptr); - if (current_plan->MischiefManaged()) + // Otherwise, don't let the base plan override what the other plans say to do, since + // presumably if there were other plans they would know what to do... + while (1) { - if (should_stop) - current_plan->WillStop(); - - // If a Master Plan wants to stop, and wants to stick on the stack, we let it. - // Otherwise, see if the plan's parent wants to stop. - - if (should_stop && current_plan->IsMasterPlan() && !current_plan->OkayToDiscard()) - { - PopPlan(); + if (PlanIsBasePlan(current_plan)) break; - } - else + + should_stop = current_plan->ShouldStop(event_ptr); + if (log) + log->Printf("Plan %s should stop: %d.", current_plan->GetName(), should_stop); + if (current_plan->MischiefManaged()) { + if (should_stop) + current_plan->WillStop(); - PopPlan(); + // If a Master Plan wants to stop, and wants to stick on the stack, we let it. + // Otherwise, see if the plan's parent wants to stop. - current_plan = GetCurrentPlan(); - if (current_plan == NULL) + if (should_stop && current_plan->IsMasterPlan() && !current_plan->OkayToDiscard()) { + PopPlan(); break; } - } + else + { - } - else - { - break; + PopPlan(); + + current_plan = GetCurrentPlan(); + if (current_plan == NULL) + { + break; + } + } + + } + else + { + break; + } } } if (over_ride_stop) @@ -476,7 +494,6 @@ bool Thread::IsThreadPlanDone (ThreadPlan *plan) { - ThreadPlanSP empty_plan_sp; if (!m_completed_plan_stack.empty()) { for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) @@ -491,7 +508,6 @@ bool Thread::WasThreadPlanDiscarded (ThreadPlan *plan) { - ThreadPlanSP empty_plan_sp; if (!m_discarded_plan_stack.empty()) { for (int i = m_discarded_plan_stack.size() - 1; i >= 0; i--) Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanBase.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanBase.cpp Mon Feb 7 23:20:59 2011 @@ -18,6 +18,7 @@ #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/Breakpoint.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -82,6 +83,8 @@ m_stop_vote = eVoteYes; m_run_vote = eVoteYes; + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + StopInfoSP stop_info_sp = GetPrivateStopReason(); if (stop_info_sp) { @@ -101,6 +104,8 @@ // If we are going to stop for a breakpoint, then unship the other plans // at this point. Don't force the discard, however, so Master plans can stay // in place if they want to. + if (log) + log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (breakpoint hit.)", m_thread.GetID()); m_thread.DiscardThreadPlans(false); return true; } @@ -127,12 +132,16 @@ case eStopReasonException: // If we crashed, discard thread plans and stop. Don't force the discard, however, // since on rerun the target may clean up this exception and continue normally from there. + if (log) + log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (exception.)", m_thread.GetID()); m_thread.DiscardThreadPlans(false); return true; case eStopReasonSignal: if (stop_info_sp->ShouldStop(event_ptr)) { + if (log) + log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (signal.)", m_thread.GetID()); m_thread.DiscardThreadPlans(false); return true; } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=125083&r1=125082&r2=125083&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Mon Feb 7 23:20:59 2011 @@ -252,13 +252,15 @@ thread_sp.reset(new MachThread(process, tid)); // Add the new thread regardless of its is user ready state... - if (new_threads) - new_threads->push_back(thread_sp); - // Make sure the thread is ready to be displayed and shown to users // before we add this thread to our list... if (thread_sp->IsUserReady()) + { + if (new_threads) + new_threads->push_back(thread_sp); + currThreads.push_back(thread_sp); + } } } From gclayton at apple.com Mon Feb 7 23:24:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 05:24:57 -0000 Subject: [Lldb-commits] [lldb] r125084 - /lldb/trunk/source/Host/common/Host.cpp Message-ID: <20110208052457.5AB712A6C12C@llvm.org> Author: gclayton Date: Mon Feb 7 23:24:57 2011 New Revision: 125084 URL: http://llvm.org/viewvc/llvm-project?rev=125084&view=rev Log: A patch from Stephen Wilson that fixes some issues with my previous dynamic loader changes. Modified: lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125084&r1=125083&r2=125084&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Mon Feb 7 23:24:57 2011 @@ -673,6 +673,9 @@ if (options & eDynamicLibraryOpenOptionLazy) mode |= RTLD_LAZY; + else + mode |= RTLD_NOW; + if (options & eDynamicLibraryOpenOptionLocal) mode |= RTLD_LOCAL; @@ -744,7 +747,7 @@ // This host doesn't support limiting searches to this shared library // so we need to verify that the match came from this shared library // if it was requested in the Host::DynamicLibraryOpen() function. - if (dylib_info->options & eDynamicLibraryOpenOptionLimitGetSymbol) + if (dylib_info->open_options & eDynamicLibraryOpenOptionLimitGetSymbol) { FileSpec match_dylib_spec (Host::GetModuleFileSpecForHostAddress (symbol_addr)); if (match_dylib_spec != dylib_info->file_spec) From gclayton at apple.com Tue Feb 8 11:49:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 17:49:03 -0000 Subject: [Lldb-commits] [lldb] r125093 - in /lldb/trunk: include/lldb/Core/Error.h include/lldb/Host/File.h lldb.xcodeproj/project.pbxproj source/Core/Error.cpp source/Host/common/File.cpp Message-ID: <20110208174903.3B5C32A6C12C@llvm.org> Author: gclayton Date: Tue Feb 8 11:49:02 2011 New Revision: 125093 URL: http://llvm.org/viewvc/llvm-project?rev=125093&view=rev Log: Added a file abtraction layer into the Host section of LLDB. Added: lldb/trunk/include/lldb/Host/File.h lldb/trunk/source/Host/common/File.cpp Modified: lldb/trunk/include/lldb/Core/Error.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Error.cpp Modified: lldb/trunk/include/lldb/Core/Error.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Error.h?rev=125093&r1=125092&r2=125093&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Error.h (original) +++ lldb/trunk/include/lldb/Core/Error.h Tue Feb 8 11:49:02 2011 @@ -205,7 +205,7 @@ /// A mach error code. //------------------------------------------------------------------ void - SetError (uint32_t err); + SetMachError (uint32_t err); //------------------------------------------------------------------ /// Set accesssor with an error value and type. Added: lldb/trunk/include/lldb/Host/File.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=125093&view=auto ============================================================================== --- lldb/trunk/include/lldb/Host/File.h (added) +++ lldb/trunk/include/lldb/Host/File.h Tue Feb 8 11:49:02 2011 @@ -0,0 +1,179 @@ +//===-- File.h --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_File_h_ +#define liblldb_File_h_ +#if defined(__cplusplus) + +#include "lldb/lldb-private.h" +#include "lldb/Host/FileSpec.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// @class File File.h "lldb/Host/File.h" +/// @brief A file class. +/// +/// A file class that divides abstracts the LLDB core from host file +/// functionality. +//---------------------------------------------------------------------- +class File +{ +public: + + enum OpenOptions + { + eOpenOptionRead = (1u << 0), // Open file for reading + eOpenOptionWrite = (1u << 1), // Open file for writing + eOpenOptionAppend = (1u << 2), // Don't truncate file when opening, append to end of file + eOpenOptionNonBlocking = (1u << 3), // File reads + eOpenOptionCanCreate = (1u << 4), // Create file if doesn't already exist + eOpenOptionCanCreateNewOnly = (1u << 5), // Can create file only if it doesn't already exist + eOpenOptionTruncate = (1u << 6), // Truncate file when opening existing + eOpenOptionSharedLock = (1u << 7), // Open file and get shared lock + eOpenOptionExclusiveLock = (1u << 8) // Open file and get exclusive lock + }; + + enum Permissions + { + ePermissionsUserRead = (1u << 0), + ePermissionsUserWrite = (1u << 1), + ePermissionsUserExecute = (1u << 2), + ePermissionsGroupRead = (1u << 3), + ePermissionsGroupWrite = (1u << 4), + ePermissionsGroupExecute = (1u << 5), + ePermissionsWorldRead = (1u << 6), + ePermissionsWorldWrite = (1u << 7), + ePermissionsWorldExecute = (1u << 8) + }; + + File() : + m_file_spec (), + m_file_desc (-1) + { + } + + //------------------------------------------------------------------ + /// Constructor with path. + /// + /// Takes a path to a file which can be just a filename, or a full + /// path. If \a path is not NULL or empty, this function will call + /// FileSpec::SetFile (const char *path, bool resolve). + /// + /// @param[in] path + /// The full or partial path to a file. + /// + /// @param[in] options + /// Options to use when opening (see OpenOptions) + /// + /// @param[in] permissions + /// Options to use when opening (see OpenOptions) + /// + /// @see FileSpec::SetFile (const char *path, bool resolve) + //------------------------------------------------------------------ + File (const char *path, + uint32_t options, + uint32_t permissions); + + //------------------------------------------------------------------ + /// Destructor. + /// + /// The destructor is virtual in case this class is subclassed. + //------------------------------------------------------------------ + virtual + ~File (); + + bool + IsValid () const + { + return m_file_desc >= 0; + } + + //------------------------------------------------------------------ + /// Convert to pointer operator. + /// + /// This allows code to check a File object to see if it + /// contains anything valid using code such as: + /// + /// @code + /// File file(...); + /// if (file) + /// { ... + /// @endcode + /// + /// @return + /// A pointer to this object if either the directory or filename + /// is valid, NULL otherwise. + //------------------------------------------------------------------ + operator + bool () const + { + return m_file_desc >= 0; + } + + //------------------------------------------------------------------ + /// Logical NOT operator. + /// + /// This allows code to check a File object to see if it is + /// invalid using code such as: + /// + /// @code + /// File file(...); + /// if (!file) + /// { ... + /// @endcode + /// + /// @return + /// Returns \b true if the object has an empty directory and + /// filename, \b false otherwise. + //------------------------------------------------------------------ + bool + operator! () const + { + return m_file_desc < 0; + } + + //------------------------------------------------------------------ + /// Get the file spec for this file. + /// + /// @return + /// A reference to the file specification object. + //------------------------------------------------------------------ + const FileSpec & + GetFileSpec () const + { + return m_file_spec; + } + + Error + Open (const char *path, + uint32_t options, + uint32_t permissions); + + Error + Close (); + + Error + Read (void *dst, size_t &num_bytes); + + Error + Write (const void *src, size_t &num_bytes); + +protected: + //------------------------------------------------------------------ + // Member variables + //------------------------------------------------------------------ + FileSpec m_file_spec; ///< The file specific for the current file (if any) + int m_file_desc; ///< The open file handle or NULL if the file isn't opened +}; + +} // namespace lldb_private + +#endif // #if defined(__cplusplus) +#endif // liblldb_FileSpec_h_ Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=125093&r1=125092&r2=125093&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Feb 8 11:49:02 2011 @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 260C6EA113011578005E16B0 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = 260C6EA013011578005E16B0 /* File.h */; }; + 260C6EA313011581005E16B0 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C6EA213011581005E16B0 /* File.cpp */; }; 260C876A10F538E700BB2B04 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 260C876910F538E700BB2B04 /* Foundation.framework */; }; 2615DB871208A9E40021781D /* StopInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2615DB861208A9E40021781D /* StopInfo.cpp */; }; 2615DBCA1208B5FC0021781D /* StopInfoMachException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2615DBC81208B5FC0021781D /* StopInfoMachException.cpp */; }; @@ -437,6 +439,8 @@ 260223E8115F06E500A601A2 /* SBCommunication.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBCommunication.cpp; path = source/API/SBCommunication.cpp; sourceTree = ""; }; 26022531115F27FA00A601A2 /* SBFileSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFileSpec.h; path = include/lldb/API/SBFileSpec.h; sourceTree = ""; }; 26022532115F281400A601A2 /* SBFileSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFileSpec.cpp; path = source/API/SBFileSpec.cpp; sourceTree = ""; }; + 260C6EA013011578005E16B0 /* File.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = File.h; path = include/lldb/Host/File.h; sourceTree = ""; }; + 260C6EA213011581005E16B0 /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = File.cpp; sourceTree = ""; }; 260C847110F50EFC00BB2B04 /* ThreadPlanBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanBase.cpp; path = source/Target/ThreadPlanBase.cpp; sourceTree = ""; }; 260C847210F50EFC00BB2B04 /* ThreadPlanStepInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepInstruction.cpp; path = source/Target/ThreadPlanStepInstruction.cpp; sourceTree = ""; }; 260C847310F50EFC00BB2B04 /* ThreadPlanStepOut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepOut.cpp; path = source/Target/ThreadPlanStepOut.cpp; sourceTree = ""; }; @@ -1972,6 +1976,7 @@ 26BC7DD210F1B7D500F91463 /* Condition.h */, 266F5CBB12FC846200DFCE33 /* Config.h */, 26BC7DD310F1B7D500F91463 /* Endian.h */, + 260C6EA013011578005E16B0 /* File.h */, 26FA4315130103F400E71120 /* FileSpec.h */, 26BC7DD410F1B7D500F91463 /* Host.h */, 26BC7DD510F1B7D500F91463 /* Mutex.h */, @@ -2273,6 +2278,7 @@ 69A01E1A1236C5D400C660B5 /* common */ = { isa = PBXGroup; children = ( + 260C6EA213011581005E16B0 /* File.cpp */, 26FA43171301048600E71120 /* FileSpec.cpp */, 69A01E1B1236C5D400C660B5 /* Condition.cpp */, 69A01E1C1236C5D400C660B5 /* Host.cpp */, @@ -2349,6 +2355,7 @@ 266F5CBC12FC846200DFCE33 /* Config.h in Headers */, 268DA872130095D000C9483A /* Terminal.h in Headers */, 26FA4316130103F400E71120 /* FileSpec.h in Headers */, + 260C6EA113011578005E16B0 /* File.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2854,6 +2861,7 @@ 4906FD4212F2255300A2A77C /* ASTDumper.cpp in Sources */, 268DA874130095ED00C9483A /* Terminal.cpp in Sources */, 26FA43181301048600E71120 /* FileSpec.cpp in Sources */, + 260C6EA313011581005E16B0 /* File.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/Error.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Error.cpp?rev=125093&r1=125092&r2=125093&view=diff ============================================================================== --- lldb/trunk/source/Core/Error.cpp (original) +++ lldb/trunk/source/Core/Error.cpp Tue Feb 8 11:49:02 2011 @@ -244,7 +244,7 @@ // "eErrorTypeMachKernel" //---------------------------------------------------------------------- void -Error::SetError (uint32_t err) +Error::SetMachError (uint32_t err) { m_code = err; m_type = eErrorTypeMachKernel; Added: lldb/trunk/source/Host/common/File.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=125093&view=auto ============================================================================== --- lldb/trunk/source/Host/common/File.cpp (added) +++ lldb/trunk/source/Host/common/File.cpp Tue Feb 8 11:49:02 2011 @@ -0,0 +1,146 @@ +//===-- FileSpec.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/Host/File.h" + +#include + +#include "lldb/Core/Error.h" + +using namespace lldb; +using namespace lldb_private; + +File::File(const char *path, uint32_t options, uint32_t permissions) : + m_file_spec (path, false), + m_file_desc (-1) +{ + Open (path, options, permissions); +} + +File::~File() +{ + Close (); +} + +Error +File::Open (const char *path, uint32_t options, uint32_t permissions) +{ + Error error; + if (IsValid()) + Close (); + + int oflag = 0; + if (options & eOpenOptionRead && + options & eOpenOptionWrite ) + oflag |= O_RDWR; + else if (options & eOpenOptionRead) + oflag |= O_RDONLY; + else if (options & eOpenOptionWrite) + oflag |= O_WRONLY; + + if (options & eOpenOptionNonBlocking) + oflag |= O_NONBLOCK; + + if (options & eOpenOptionAppend) + oflag |= O_APPEND; + + if (options & eOpenOptionCanCreate) + oflag |= O_CREAT; + + if (options & eOpenOptionCanCreateNewOnly) + oflag |= O_CREAT | O_EXCL; + + if (options & eOpenOptionTruncate) + oflag |= O_TRUNC; + + if (options & eOpenOptionSharedLock) + oflag |= O_SHLOCK; + + if (options & eOpenOptionExclusiveLock) + oflag |= O_EXLOCK; + + mode_t mode = 0; + if (permissions & ePermissionsUserRead) mode |= S_IRUSR; + if (permissions & ePermissionsUserWrite) mode |= S_IWUSR; + if (permissions & ePermissionsUserExecute) mode |= S_IXUSR; + if (permissions & ePermissionsGroupRead) mode |= S_IRGRP; + if (permissions & ePermissionsGroupWrite) mode |= S_IWGRP; + if (permissions & ePermissionsGroupExecute) mode |= S_IXGRP; + if (permissions & ePermissionsWorldRead) mode |= S_IROTH; + if (permissions & ePermissionsWorldWrite) mode |= S_IWOTH; + if (permissions & ePermissionsWorldExecute) mode |= S_IXOTH; + + m_file_desc = ::open(path, oflag, mode); + if (m_file_desc == -1) + error.SetErrorToErrno(); + else + m_file_spec.SetFile (path, false); + + return error; +} + +Error +File::Close () +{ + Error error; + if (IsValid ()) + { + if (::close (m_file_desc) != 0) + error.SetErrorToErrno(); + } + return error; +} + +Error +File::Read (void *buf, size_t &num_bytes) +{ + Error error; + if (IsValid ()) + { + ssize_t bytes_read = ::read (m_file_desc, buf, num_bytes); + if (bytes_read == -1) + { + error.SetErrorToErrno(); + num_bytes = 0; + } + else + num_bytes = bytes_read; + } + else + { + num_bytes = 0; + error.SetErrorString("invalid file handle"); + } + return error; +} + +Error +File::Write (const void *buf, size_t &num_bytes) +{ + Error error; + if (IsValid()) + { + ssize_t bytes_written = ::write (m_file_desc, buf, num_bytes); + if (bytes_written == -1) + { + error.SetErrorToErrno(); + num_bytes = 0; + } + else + num_bytes = bytes_written; + } + else + { + num_bytes = 0; + error.SetErrorString("invalid file handle"); + } + return error; +} + From johnny.chen at apple.com Tue Feb 8 12:31:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 08 Feb 2011 18:31:06 -0000 Subject: [Lldb-commits] [lldb] r125099 - /lldb/trunk/test/macosx/universal/TestUniversal.py Message-ID: <20110208183106.36B802A6C12C@llvm.org> Author: johnny Date: Tue Feb 8 12:31:06 2011 New Revision: 125099 URL: http://llvm.org/viewvc/llvm-project?rev=125099&view=rev Log: Make the assertion message about 32-bit process address byte size more clear. Modified: lldb/trunk/test/macosx/universal/TestUniversal.py Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=125099&r1=125098&r2=125099&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Tue Feb 8 12:31:06 2011 @@ -67,10 +67,13 @@ # Check whether we have a 32-bit process launched. target = self.dbg.GetSelectedTarget() process = target.GetProcess() - self.assertTrue(target.IsValid() and process.IsValid() and - self.invoke(process, 'GetAddressByteSize') == 4, + self.assertTrue(target.IsValid() and process.IsValid(), "32-bit process launched") + pointerSize = self.invoke(process, 'GetAddressByteSize') + self.assertTrue(pointerSize == 4, + "AddressByteSize of 32-bit process should be 4, got %d instead." % pointerSize) + self.runCmd("continue") From johnny.chen at apple.com Tue Feb 8 12:37:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 08 Feb 2011 18:37:49 -0000 Subject: [Lldb-commits] [lldb] r125100 - /lldb/trunk/test/macosx/universal/TestUniversal.py Message-ID: <20110208183749.9AF102A6C12C@llvm.org> Author: johnny Date: Tue Feb 8 12:37:49 2011 New Revision: 125100 URL: http://llvm.org/viewvc/llvm-project?rev=125100&view=rev Log: Add new radar info for failed test. Modified: lldb/trunk/test/macosx/universal/TestUniversal.py Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=125100&r1=125099&r2=125100&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Tue Feb 8 12:37:49 2011 @@ -15,7 +15,7 @@ # Find the line number to break inside main(). self.line = line_number('main.c', '// Set break point at this line.') - # rdar://problem/8689814 test failure: test/macosx/universal (the i386 slice does not break?) + # rdar://problem/8972204 AddressByteSize of 32-bit process should be 4, got 8 instead. @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4]=='i386', "requires Darwin & i386") def test_process_launch_for_universal(self): From johnny.chen at apple.com Tue Feb 8 12:58:32 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 08 Feb 2011 18:58:32 -0000 Subject: [Lldb-commits] [lldb] r125103 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110208185832.1B5FD2A6C12C@llvm.org> Author: johnny Date: Tue Feb 8 12:58:31 2011 New Revision: 125103 URL: http://llvm.org/viewvc/llvm-project?rev=125103&view=rev Log: Add missing implementation for "BL, BLX (immediate)" Encoding A1. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125103&r1=125102&r2=125103&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 8 12:58:31 2011 @@ -784,6 +784,13 @@ context.arg2 = eModeARM; // target instruction set break; } + case eEncodingA1: + lr = pc + 4; // return address + imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2); + target = pc + 8 + imm32; + context.arg1 = 8 + imm32; // signed offset + context.arg2 = eModeARM; // target instruction set + break; case eEncodingA2: lr = pc + 4; // return address imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2 | Bits32(opcode, 24, 24) << 1); From gclayton at apple.com Tue Feb 8 13:10:54 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 19:10:54 -0000 Subject: [Lldb-commits] [lldb] r125106 - in /lldb/trunk: include/lldb/Host/File.h source/Host/common/File.cpp Message-ID: <20110208191054.234512A6C12C@llvm.org> Author: gclayton Date: Tue Feb 8 13:10:53 2011 New Revision: 125106 URL: http://llvm.org/viewvc/llvm-project?rev=125106&view=rev Log: Added a few more calls to the File abtract class for seeking, syncing and getting the file spec from the file descriptor. Modified: lldb/trunk/include/lldb/Host/File.h lldb/trunk/source/Host/common/File.cpp Modified: lldb/trunk/include/lldb/Host/File.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=125106&r1=125105&r2=125106&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/File.h (original) +++ lldb/trunk/include/lldb/Host/File.h Tue Feb 8 13:10:53 2011 @@ -53,9 +53,7 @@ ePermissionsWorldExecute = (1u << 8) }; - File() : - m_file_spec (), - m_file_desc (-1) + File() : m_file_desc (-1) { } @@ -145,11 +143,8 @@ /// @return /// A reference to the file specification object. //------------------------------------------------------------------ - const FileSpec & - GetFileSpec () const - { - return m_file_spec; - } + Error + GetFileSpec (FileSpec &file_spec) const; Error Open (const char *path, @@ -165,12 +160,23 @@ Error Write (const void *src, size_t &num_bytes); + Error + SeekFromStart (off_t& offset); + + Error + SeekFromCurrent (off_t& offset); + + Error + SeekFromEnd (off_t& offset); + + Error + Sync (); + protected: //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ - FileSpec m_file_spec; ///< The file specific for the current file (if any) - int m_file_desc; ///< The open file handle or NULL if the file isn't opened + int m_file_desc; ///< The open file handle or NULL if the file isn't opened }; } // namespace lldb_private Modified: lldb/trunk/source/Host/common/File.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=125106&r1=125105&r2=125106&view=diff ============================================================================== --- lldb/trunk/source/Host/common/File.cpp (original) +++ lldb/trunk/source/Host/common/File.cpp Tue Feb 8 13:10:53 2011 @@ -18,7 +18,6 @@ using namespace lldb_private; File::File(const char *path, uint32_t options, uint32_t permissions) : - m_file_spec (path, false), m_file_desc (-1) { Open (path, options, permissions); @@ -80,8 +79,6 @@ m_file_desc = ::open(path, oflag, mode); if (m_file_desc == -1) error.SetErrorToErrno(); - else - m_file_spec.SetFile (path, false); return error; } @@ -94,10 +91,101 @@ { if (::close (m_file_desc) != 0) error.SetErrorToErrno(); + m_file_desc = -1; + } + return error; +} + + +Error +File::GetFileSpec (FileSpec &file_spec) const +{ + Error error; + if (IsValid ()) + { + char path[PATH_MAX]; + if (::fcntl(m_file_desc, F_GETPATH, path) == -1) + error.SetErrorToErrno(); + else + file_spec.SetFile (path, false); + } + else + error.SetErrorString("invalid file handle"); + + if (error.Fail()) + file_spec.Clear(); + return error; +} + +Error +File::SeekFromStart (off_t& offset) +{ + Error error; + if (IsValid ()) + { + offset = ::lseek (m_file_desc, offset, SEEK_SET); + + if (offset == -1) + error.SetErrorToErrno(); + } + else + { + error.SetErrorString("invalid file handle"); + } + return error; +} + +Error +File::SeekFromCurrent (off_t& offset) +{ + Error error; + if (IsValid ()) + { + offset = ::lseek (m_file_desc, offset, SEEK_CUR); + + if (offset == -1) + error.SetErrorToErrno(); + } + else + { + error.SetErrorString("invalid file handle"); + } + return error; +} + +Error +File::SeekFromEnd (off_t& offset) +{ + Error error; + if (IsValid ()) + { + offset = ::lseek (m_file_desc, offset, SEEK_CUR); + + if (offset == -1) + error.SetErrorToErrno(); + } + else + { + error.SetErrorString("invalid file handle"); + } + return error; +} + +Error +File::Sync () +{ + Error error; + if (IsValid ()) + { + if (::fsync (m_file_desc) == -1) + error.SetErrorToErrno(); + } + else + { + error.SetErrorString("invalid file handle"); } return error; } - Error File::Read (void *buf, size_t &num_bytes) { From gclayton at apple.com Tue Feb 8 13:54:44 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 08 Feb 2011 19:54:44 -0000 Subject: [Lldb-commits] [lldb] r125110 - in /lldb/trunk: include/lldb/Host/File.h source/Host/common/File.cpp Message-ID: <20110208195444.972EC2A6C12C@llvm.org> Author: gclayton Date: Tue Feb 8 13:54:44 2011 New Revision: 125110 URL: http://llvm.org/viewvc/llvm-project?rev=125110&view=rev Log: Updated a few more Host::File functions and added documentation. Modified: lldb/trunk/include/lldb/Host/File.h lldb/trunk/source/Host/common/File.cpp Modified: lldb/trunk/include/lldb/Host/File.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=125110&r1=125109&r2=125110&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/File.h (original) +++ lldb/trunk/include/lldb/Host/File.h Tue Feb 8 13:54:44 2011 @@ -12,7 +12,6 @@ #if defined(__cplusplus) #include "lldb/lldb-private.h" -#include "lldb/Host/FileSpec.h" namespace lldb_private { @@ -62,18 +61,18 @@ /// /// Takes a path to a file which can be just a filename, or a full /// path. If \a path is not NULL or empty, this function will call - /// FileSpec::SetFile (const char *path, bool resolve). + /// File::Open (const char *path, uint32_t options, uint32_t permissions). /// /// @param[in] path /// The full or partial path to a file. /// /// @param[in] options - /// Options to use when opening (see OpenOptions) + /// Options to use when opening (see File::OpenOptions) /// /// @param[in] permissions - /// Options to use when opening (see OpenOptions) + /// Options to use when opening (see File::Permissions) /// - /// @see FileSpec::SetFile (const char *path, bool resolve) + /// @see File::Open (const char *path, uint32_t options, uint32_t permissions) //------------------------------------------------------------------ File (const char *path, uint32_t options, @@ -146,6 +145,21 @@ Error GetFileSpec (FileSpec &file_spec) const; + //------------------------------------------------------------------ + /// Open a file for read/writing with the specified options. + /// + /// Takes a path to a file which can be just a filename, or a full + /// path. + /// + /// @param[in] path + /// The full or partial path to a file. + /// + /// @param[in] options + /// Options to use when opening (see File::OpenOptions) + /// + /// @param[in] permissions + /// Options to use when opening (see File::Permissions) + //------------------------------------------------------------------ Error Open (const char *path, uint32_t options, @@ -154,21 +168,174 @@ Error Close (); + //------------------------------------------------------------------ + /// Read bytes from a file from the current file position. + /// + /// NOTE: This function is NOT thread safe. Use the read function + /// that takes an "off_t &offset" to ensure correct operation in + /// multi-threaded environments. + /// + /// @param[in] buf + /// A buffer where to put the bytes that are read. + /// + /// @param[in/out] num_bytes + /// The number of bytes to read form the current file position + /// which gets modified with the number of bytes that were read. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ Error - Read (void *dst, size_t &num_bytes); + Read (void *buf, size_t &num_bytes); + //------------------------------------------------------------------ + /// Write bytes to a file at the current file position. + /// + /// NOTE: This function is NOT thread safe. Use the write function + /// that takes an "off_t &offset" to ensure correct operation in + /// multi-threaded environments. + /// + /// @param[in] buf + /// A buffer where to put the bytes that are read. + /// + /// @param[in/out] num_bytes + /// The number of bytes to write to the current file position + /// which gets modified with the number of bytes that were + /// written. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ Error - Write (const void *src, size_t &num_bytes); + Write (const void *buf, size_t &num_bytes); + //------------------------------------------------------------------ + /// Seek to an offset relative to the beginning of the file. + /// + /// NOTE: This function is NOT thread safe, other threads that + /// access this object might also change the current file position. + /// For thread safe reads and writes see the following functions: + /// @see File::Read (void *, size_t, off_t &) + /// @see File::Write (const void *, size_t, off_t &) + /// + /// @param[in/out] offset + /// The offset to seek to within the file relative to the + /// beginning of the file which gets filled in the the resulting + /// absolute file offset. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ Error SeekFromStart (off_t& offset); + //------------------------------------------------------------------ + /// Seek to an offset relative to the current file position. + /// + /// NOTE: This function is NOT thread safe, other threads that + /// access this object might also change the current file position. + /// For thread safe reads and writes see the following functions: + /// @see File::Read (void *, size_t, off_t &) + /// @see File::Write (const void *, size_t, off_t &) + /// + /// @param[in/out] offset + /// The offset to seek to within the file relative to the + /// current file position. On return this parameter gets filled + /// in the the resulting absolute file offset. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ Error SeekFromCurrent (off_t& offset); + //------------------------------------------------------------------ + /// Seek to an offset relative to the end of the file. + /// + /// NOTE: This function is NOT thread safe, other threads that + /// access this object might also change the current file position. + /// For thread safe reads and writes see the following functions: + /// @see File::Read (void *, size_t, off_t &) + /// @see File::Write (const void *, size_t, off_t &) + /// + /// @param[in/out] offset + /// The offset to seek to within the file relative to the + /// end of the file which gets filled in the the resulting + /// absolute file offset. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ Error SeekFromEnd (off_t& offset); + //------------------------------------------------------------------ + /// Read bytes from a file from the specified file offset. + /// + /// NOTE: This function is thread safe in that clients manager their + /// own file position markers and reads on other threads won't mess + /// up the current read. + /// + /// @param[in] buf + /// A buffer where to put the bytes that are read. + /// + /// @param[in/out] num_bytes + /// The number of bytes to read form the current file position + /// which gets modified with the number of bytes that were read. + /// + /// @param[in/out] offset + /// The offset within the file from which to read \a num_bytes + /// bytes. This offset gets incremented by the number of bytes + /// that were read. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ + Error + Read (void *dst, size_t &num_bytes, off_t &offset); + + //------------------------------------------------------------------ + /// Write bytes to a file at the specified file offset. + /// + /// NOTE: This function is thread safe in that clients manager their + /// own file position markers, though clients will need to implement + /// their own locking externally to avoid multiple people writing + /// to the file at the same time. + /// + /// @param[in] buf + /// A buffer containing the bytes to write. + /// + /// @param[in/out] num_bytes + /// The number of bytes to write to the file at offset \a offset. + /// \a num_bytes gets modified with the number of bytes that + /// were read. + /// + /// @param[in/out] offset + /// The offset within the file at which to write \a num_bytes + /// bytes. This offset gets incremented by the number of bytes + /// that were written. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ + Error + Write (const void *src, size_t &num_bytes, off_t &offset); + + + //------------------------------------------------------------------ + /// Sync to disk. + /// + /// @return + /// An error object that indicates success or the reason for + /// failure. + //------------------------------------------------------------------ Error Sync (); @@ -182,4 +349,4 @@ } // namespace lldb_private #endif // #if defined(__cplusplus) -#endif // liblldb_FileSpec_h_ +#endif // liblldb_File_h_ Modified: lldb/trunk/source/Host/common/File.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=125110&r1=125109&r2=125110&view=diff ============================================================================== --- lldb/trunk/source/Host/common/File.cpp (original) +++ lldb/trunk/source/Host/common/File.cpp Tue Feb 8 13:54:44 2011 @@ -13,6 +13,7 @@ #include #include "lldb/Core/Error.h" +#include "lldb/Host/FileSpec.h" using namespace lldb; using namespace lldb_private; @@ -186,6 +187,7 @@ } return error; } + Error File::Read (void *buf, size_t &num_bytes) { @@ -232,3 +234,58 @@ return error; } + +Error +File::Read (void *buf, size_t &num_bytes, off_t &offset) +{ + Error error; + if (IsValid ()) + { + ssize_t bytes_read = ::pread (m_file_desc, buf, num_bytes, offset); + if (bytes_read < 0) + { + num_bytes = 0; + error.SetErrorToErrno(); + } + else + { + offset += bytes_read; + num_bytes = bytes_read; + } + } + else + { + num_bytes = 0; + error.SetErrorString("invalid file handle"); + } + return error; +} + +Error +File::Write (const void *buf, size_t &num_bytes, off_t &offset) +{ + Error error; + if (IsValid()) + { + ssize_t bytes_written = ::pwrite (m_file_desc, buf, num_bytes, offset); + if (bytes_written < 0) + { + num_bytes = 0; + error.SetErrorToErrno(); + } + else + { + offset += bytes_written; + num_bytes = bytes_written; + } + } + else + { + num_bytes = 0; + error.SetErrorString("invalid file handle"); + } + return error; +} + + + From johnny.chen at apple.com Tue Feb 8 14:36:35 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 08 Feb 2011 20:36:35 -0000 Subject: [Lldb-commits] [lldb] r125112 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110208203635.1DA4B2A6C12C@llvm.org> Author: johnny Date: Tue Feb 8 14:36:34 2011 New Revision: 125112 URL: http://llvm.org/viewvc/llvm-project?rev=125112&view=rev Log: Add missing implementation for "BL, BLX (immediate)" Encoding T1 and an entry for "bl