[Lldb-commits] [PATCH] D28858: Replace getcwd with the llvm equivalent
labath added a comment. Any objections to this, Zach? https://reviews.llvm.org/D28858 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D28858: Replace getcwd with the llvm equivalent
Sorry forgot about this, looks good On Mon, Jan 23, 2017 at 7:55 AM Pavel Labath via Phabricator < revi...@reviews.llvm.org> wrote: > labath added a comment. > > Any objections to this, Zach? > > > https://reviews.llvm.org/D28858 > > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D28858: Replace getcwd with the llvm equivalent
This revision was automatically updated to reflect the committed changes. Closed by commit rL292795: Replace getcwd with the llvm equivalent (authored by labath). Changed prior to commit: https://reviews.llvm.org/D28858?vs=84828&id=85399#toc Repository: rL LLVM https://reviews.llvm.org/D28858 Files: lldb/trunk/include/lldb/Host/windows/PosixApi.h lldb/trunk/source/Host/windows/Windows.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/source/Target/ProcessLaunchInfo.cpp lldb/trunk/source/Target/TargetList.cpp Index: lldb/trunk/source/Host/windows/Windows.cpp === --- lldb/trunk/source/Host/windows/Windows.cpp +++ lldb/trunk/source/Host/windows/Windows.cpp @@ -23,10 +23,9 @@ #include #include -// These prototypes are defined in , but it also defines chdir() and -// getcwd(), giving multiply defined errors +// These prototypes are defined in , but it also defines chdir(), +// giving multiply defined errors extern "C" { -char *_getcwd(char *buffer, int maxlen); int _chdir(const char *path); } @@ -190,28 +189,6 @@ return &l1[1]; } -// use _getcwd() instead of GetCurrentDirectory() because it updates errno -char *getcwd(char *path, int max) { - assert(path == NULL || max <= PATH_MAX); - wchar_t wpath[PATH_MAX]; - if (wchar_t *wresult = _wgetcwd(wpath, PATH_MAX)) { -// Caller is allowed to pass in NULL for `path`. -// In that case, we're supposed to allocate a -// buffer on the caller's behalf. -if (path == NULL) { - max = UNI_MAX_UTF8_BYTES_PER_CODE_POINT * wcslen(wresult) + 1; - path = (char *)malloc(max); - if (path == NULL) { -errno = ENOMEM; -return NULL; - } -} -if (wideToUtf8(wresult, path, max)) - return path; - } - return NULL; -} - // use _chdir() instead of SetCurrentDirectory() because it updates errno int chdir(const char *path) { return _chdir(path); } Index: lldb/trunk/source/Target/TargetList.cpp === --- lldb/trunk/source/Target/TargetList.cpp +++ lldb/trunk/source/Target/TargetList.cpp @@ -7,11 +7,6 @@ // //===--===// -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "llvm/ADT/SmallString.h" - // Project includes #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" @@ -29,6 +24,10 @@ #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" +// Other libraries and framework includes +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/FileSystem.h" + using namespace lldb; using namespace lldb_private; @@ -369,12 +368,11 @@ if (file.IsRelative() && !user_exe_path.empty()) { // Ignore paths that start with "./" and "../" if (!user_exe_path.startswith("./") && !user_exe_path.startswith("../")) { -char cwd[PATH_MAX]; -if (getcwd(cwd, sizeof(cwd))) { - std::string cwd_user_exe_path(cwd); - cwd_user_exe_path += '/'; - cwd_user_exe_path += user_exe_path; - FileSpec cwd_file(cwd_user_exe_path, false); +llvm::SmallString<64> cwd; +if (! llvm::sys::fs::current_path(cwd)) { + cwd += '/'; + cwd += user_exe_path; + FileSpec cwd_file(cwd, false); if (cwd_file.Exists()) file = cwd_file; } Index: lldb/trunk/source/Target/ProcessLaunchInfo.cpp === --- lldb/trunk/source/Target/ProcessLaunchInfo.cpp +++ lldb/trunk/source/Target/ProcessLaunchInfo.cpp @@ -23,6 +23,7 @@ #include "lldb/Target/Target.h" #include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/FileSystem.h" #if !defined(_WIN32) #include @@ -368,10 +369,8 @@ if (working_dir) { new_path += working_dir.GetPath(); } else { -char current_working_dir[PATH_MAX]; -const char *cwd = -getcwd(current_working_dir, sizeof(current_working_dir)); -if (cwd && cwd[0]) +llvm::SmallString<64> cwd; +if (! llvm::sys::fs::current_path(cwd)) new_path += cwd; } std::string curr_path; Index: lldb/trunk/source/Target/Platform.cpp === --- lldb/trunk/source/Target/Platform.cpp +++ lldb/trunk/source/Target/Platform.cpp @@ -523,11 +523,11 @@ FileSpec Platform::GetWorkingDirectory() { if (IsHost()) { -char cwd[PATH_MAX]; -if (getcwd(cwd, sizeof(cwd))) - return FileSpec{cwd, true}; -else +llvm::SmallString<64> cwd; +if (llvm::sys::fs::current_path(cwd)) return FileSpec{}; +else + return FileSpec(cwd, true); } else { if (!m_working_dir
[Lldb-commits] [lldb] r292795 - Replace getcwd with the llvm equivalent
Author: labath Date: Mon Jan 23 09:56:45 2017 New Revision: 292795 URL: http://llvm.org/viewvc/llvm-project?rev=292795&view=rev Log: Replace getcwd with the llvm equivalent Summary: getcwd() is not available (well.. um.. deprecated?) on windows, and the way PosixApi.h is providing it causes strange compile errors when it's included in the wrong order. The best way to avoid that is to just not use chdir. This replaces all uses of getcwd in generic code. There are still a couple of more uses, but these are in platform-specific code. chdir() is causing a similar problem, but for that there is no llvm equivalent for that (yet). Reviewers: zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D28858 Modified: lldb/trunk/include/lldb/Host/windows/PosixApi.h lldb/trunk/source/Host/windows/Windows.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/source/Target/ProcessLaunchInfo.cpp lldb/trunk/source/Target/TargetList.cpp Modified: lldb/trunk/include/lldb/Host/windows/PosixApi.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/PosixApi.h?rev=292795&r1=292794&r2=292795&view=diff == --- lldb/trunk/include/lldb/Host/windows/PosixApi.h (original) +++ lldb/trunk/include/lldb/Host/windows/PosixApi.h Mon Jan 23 09:56:45 2017 @@ -82,7 +82,6 @@ char *strcasestr(const char *s, const ch char *realpath(const char *name, char *resolved); int usleep(uint32_t useconds); -char *getcwd(char *path, int max); int chdir(const char *path); char *basename(char *path); char *dirname(char *path); Modified: lldb/trunk/source/Host/windows/Windows.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Windows.cpp?rev=292795&r1=292794&r2=292795&view=diff == --- lldb/trunk/source/Host/windows/Windows.cpp (original) +++ lldb/trunk/source/Host/windows/Windows.cpp Mon Jan 23 09:56:45 2017 @@ -23,10 +23,9 @@ #include #include -// These prototypes are defined in , but it also defines chdir() and -// getcwd(), giving multiply defined errors +// These prototypes are defined in , but it also defines chdir(), +// giving multiply defined errors extern "C" { -char *_getcwd(char *buffer, int maxlen); int _chdir(const char *path); } @@ -190,28 +189,6 @@ char *basename(char *path) { return &l1[1]; } -// use _getcwd() instead of GetCurrentDirectory() because it updates errno -char *getcwd(char *path, int max) { - assert(path == NULL || max <= PATH_MAX); - wchar_t wpath[PATH_MAX]; - if (wchar_t *wresult = _wgetcwd(wpath, PATH_MAX)) { -// Caller is allowed to pass in NULL for `path`. -// In that case, we're supposed to allocate a -// buffer on the caller's behalf. -if (path == NULL) { - max = UNI_MAX_UTF8_BYTES_PER_CODE_POINT * wcslen(wresult) + 1; - path = (char *)malloc(max); - if (path == NULL) { -errno = ENOMEM; -return NULL; - } -} -if (wideToUtf8(wresult, path, max)) - return path; - } - return NULL; -} - // use _chdir() instead of SetCurrentDirectory() because it updates errno int chdir(const char *path) { return _chdir(path); } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=292795&r1=292794&r2=292795&view=diff == --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp Mon Jan 23 09:56:45 2017 @@ -356,12 +356,12 @@ GDBRemoteCommunicationServerPlatform::Ha // If this packet is sent to a platform, then change the current working // directory - char cwd[PATH_MAX]; - if (getcwd(cwd, sizeof(cwd)) == NULL) -return SendErrorResponse(errno); + llvm::SmallString<64> cwd; + if (std::error_code ec = llvm::sys::fs::current_path(cwd)) +return SendErrorResponse(ec.value()); StreamString response; - response.PutBytesAsRawHex8(cwd, strlen(cwd)); + response.PutBytesAsRawHex8(cwd.data(), cwd.size()); return SendPacketNoLock(response.GetString()); } Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=292795&r1=292794&r2=292795&view=diff == --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Mon Jan 23 09:56:45 2017 @@ -523,11 +523,11 @@ void Platform::AddClangModuleCompilation FileSpec Platform::GetWorkin
[Lldb-commits] [PATCH] D28944: Provide option to set pc of the file loaded in memory.
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Looks good. https://reviews.llvm.org/D28944 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D28808: Fix a bug where lldb does not respect the packet size.
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Looks good. https://reviews.llvm.org/D28808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29036: Add format_provider for lldb::StateType
labath created this revision. Herald added a subscriber: mgorny. https://reviews.llvm.org/D29036 Files: include/lldb/Core/State.h source/Plugins/Process/Linux/NativeProcessLinux.cpp unittests/Core/CMakeLists.txt unittests/Core/StateTest.cpp Index: unittests/Core/StateTest.cpp === --- /dev/null +++ unittests/Core/StateTest.cpp @@ -0,0 +1,20 @@ +//===-- StateTest.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/State.h" +#include "llvm/Support/FormatVariadic.h" +#include "gtest/gtest.h" + +using namespace lldb; +using namespace lldb_private; + +TEST(StateTest, Formatv) { + EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str()); + EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str()); +} Index: unittests/Core/CMakeLists.txt === --- unittests/Core/CMakeLists.txt +++ unittests/Core/CMakeLists.txt @@ -6,6 +6,7 @@ ListenerTest.cpp LogTest.cpp ScalarTest.cpp + StateTest.cpp StructuredDataTest.cpp TimerTest.cpp ) Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp === --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -567,7 +567,7 @@ pid, thread_found ? "stopped tracking thread metadata" : "thread metadata not found", -StateAsCString(GetState())); +GetState()); // The main thread exited. We're done monitoring. Report to delegate. SetExitStatus(convert_pid_status_to_exit_type(status), convert_pid_status_to_return_code(status), nullptr, true); @@ -1033,7 +1033,7 @@ LLDB_LOG(log, "pid {0} tid {1}, thread was already marked as a stopped " "state (state={2}), leaving stop signal as is", - GetID(), thread.GetID(), StateAsCString(thread_state)); + GetID(), thread.GetID(), thread_state); SignalIfAllThreadsStopped(); } @@ -1263,7 +1263,7 @@ } LLDB_LOG(log, "processing resume action state {0} for pid {1} tid {2}", - StateAsCString(action->state), GetID(), thread_sp->GetID()); + action->state, GetID(), thread_sp->GetID()); switch (action->state) { case eStateRunning: @@ -1393,7 +1393,7 @@ case StateType::eStateUnloaded: // Nothing to do - the process is already dead. LLDB_LOG(log, "ignored for PID {0} due to current state: {1}", GetID(), - StateAsCString(m_state)); + m_state); return error; case StateType::eStateConnected: @@ -2273,7 +2273,7 @@ return step_result; } default: -LLDB_LOG(log, "Unhandled state {0}.", StateAsCString(state)); +LLDB_LOG(log, "Unhandled state {0}.", state); llvm_unreachable("Unhandled state for resume"); } } Index: include/lldb/Core/State.h === --- include/lldb/Core/State.h +++ include/lldb/Core/State.h @@ -10,11 +10,8 @@ #ifndef liblldb_State_h_ #define liblldb_State_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" +#include "llvm/Support/FormatProviders.h" namespace lldb_private { @@ -71,4 +68,13 @@ } // namespace lldb_private +namespace llvm { +template <> struct format_provider { + static void format(const lldb::StateType &state, raw_ostream &Stream, + StringRef Style) { +Stream << lldb_private::StateAsCString(state); + } +}; +} + #endif // liblldb_State_h_ ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29036: Add format_provider for lldb::StateType
clayborg requested changes to this revision. clayborg added a comment. This revision now requires changes to proceed. Very close, just add a test for a bad value since someone can have code like: StateType state; llvm::formatv("{0}", state); Just to make sure we don't crash during logging. Can remember what lldb_private::StateAsCString(...) returns, but I am guessing it is NULL for a bad state, so we need to make sure the logging won't crash with that. https://reviews.llvm.org/D29036 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29036: Add format_provider for lldb::StateType
clayborg added inline comments. Comment at: unittests/Core/StateTest.cpp:19 + EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str()); + EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str()); +} Add a test like: ``` EXPECT_EQ("(null)", llvm::formatv("{0}", static_cast(-1)).str()); ``` https://reviews.llvm.org/D29036 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29036: Add format_provider for lldb::StateType
labath updated this revision to Diff 85419. labath added a comment. In this case, StateAsCString was returning a pointer to a static buffer in a scarily non-thread-safe way. I've changed it to print "unknown" instead and test for that. https://reviews.llvm.org/D29036 Files: include/lldb/Core/State.h source/Core/State.cpp source/Plugins/Process/Linux/NativeProcessLinux.cpp unittests/Core/CMakeLists.txt unittests/Core/StateTest.cpp Index: unittests/Core/StateTest.cpp === --- /dev/null +++ unittests/Core/StateTest.cpp @@ -0,0 +1,21 @@ +//===-- StateTest.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/State.h" +#include "llvm/Support/FormatVariadic.h" +#include "gtest/gtest.h" + +using namespace lldb; +using namespace lldb_private; + +TEST(StateTest, Formatv) { + EXPECT_EQ("exited", llvm::formatv("{0}", eStateExited).str()); + EXPECT_EQ("stopped", llvm::formatv("{0}", eStateStopped).str()); + EXPECT_EQ("unknown", llvm::formatv("{0}", StateType(-1)).str()); +} Index: unittests/Core/CMakeLists.txt === --- unittests/Core/CMakeLists.txt +++ unittests/Core/CMakeLists.txt @@ -6,6 +6,7 @@ ListenerTest.cpp LogTest.cpp ScalarTest.cpp + StateTest.cpp StructuredDataTest.cpp TimerTest.cpp ) Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp === --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -567,7 +567,7 @@ pid, thread_found ? "stopped tracking thread metadata" : "thread metadata not found", -StateAsCString(GetState())); +GetState()); // The main thread exited. We're done monitoring. Report to delegate. SetExitStatus(convert_pid_status_to_exit_type(status), convert_pid_status_to_return_code(status), nullptr, true); @@ -1033,7 +1033,7 @@ LLDB_LOG(log, "pid {0} tid {1}, thread was already marked as a stopped " "state (state={2}), leaving stop signal as is", - GetID(), thread.GetID(), StateAsCString(thread_state)); + GetID(), thread.GetID(), thread_state); SignalIfAllThreadsStopped(); } @@ -1263,7 +1263,7 @@ } LLDB_LOG(log, "processing resume action state {0} for pid {1} tid {2}", - StateAsCString(action->state), GetID(), thread_sp->GetID()); + action->state, GetID(), thread_sp->GetID()); switch (action->state) { case eStateRunning: @@ -1393,7 +1393,7 @@ case StateType::eStateUnloaded: // Nothing to do - the process is already dead. LLDB_LOG(log, "ignored for PID {0} due to current state: {1}", GetID(), - StateAsCString(m_state)); + m_state); return error; case StateType::eStateConnected: @@ -2273,7 +2273,7 @@ return step_result; } default: -LLDB_LOG(log, "Unhandled state {0}.", StateAsCString(state)); +LLDB_LOG(log, "Unhandled state {0}.", state); llvm_unreachable("Unhandled state for resume"); } } Index: source/Core/State.cpp === --- source/Core/State.cpp +++ source/Core/State.cpp @@ -44,10 +44,7 @@ case eStateSuspended: return "suspended"; } - static char unknown_state_string[64]; - snprintf(unknown_state_string, sizeof(unknown_state_string), "StateType = %i", - state); - return unknown_state_string; + return "unknown"; } const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) { Index: include/lldb/Core/State.h === --- include/lldb/Core/State.h +++ include/lldb/Core/State.h @@ -10,11 +10,8 @@ #ifndef liblldb_State_h_ #define liblldb_State_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" +#include "llvm/Support/FormatProviders.h" namespace lldb_private { @@ -71,4 +68,13 @@ } // namespace lldb_private +namespace llvm { +template <> struct format_provider { + static void format(const lldb::StateType &state, raw_ostream &Stream, + StringRef Style) { +Stream << lldb_private::StateAsCString(state); + } +}; +} + #endif // liblldb_State_h_ ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D28945: Add completed_plan_stack to LLDB ThreadStateCheckpoint
boris.ulasevich added a comment. In https://reviews.llvm.org/D28945#651806, @jingham wrote: > The plans should do whatever cleanup they are going to do when they get > popped, and should not rely on the destructors to do this work. Yes, you already made a note a time ago: r123869 | jingham | 2011-01-20 Back up both the register AND the stop state when calling functions. 123869jingham // N.B. Don't wait to do clean up target state till the destructor, since that will usually get called when 123869jingham // the target resumes, and you want to leave the target state correct for new plans in the time between when 123869jingham // your plan gets unshipped and the next resume. > I don't think that letting the completed plans live a little longer should > pose any problems It is not something extraordinary, but just a life frame the plans intended to live without unexpected internall call. By the way, I fixed my issue by restoring specific Thread's property - don't you think it is a potential bug for somebody who will use another property (destroyed plans?) without proper treatment in Thread State Checkpoint? > But it would be worth a quick audit As I see, actually destructors clears breakpoints - it is important, but not urgent job. > we should document that requirement in the ThreadPlan dissertation at the > beginning of ThreadPlan.h For me the ThreadPlan dissertation is like the Bible: I feel it is very old and complicated, a lot on wisdom is hidden there, but nobody around have ever read it attentively :) I would add words about Thread State there and define stack direction to make words 'below' and 'higher' more definite. Please see new diff. Repository: rL LLVM https://reviews.llvm.org/D28945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D28945: Add completed_plan_stack to LLDB ThreadStateCheckpoint
boris.ulasevich updated this revision to Diff 85424. boris.ulasevich added a comment. description update https://reviews.llvm.org/D28945 Files: lldb/include/lldb/Target/Thread.h lldb/include/lldb/Target/ThreadPlan.h lldb/source/Target/Thread.cpp Index: lldb/source/Target/Thread.cpp === --- lldb/source/Target/Thread.cpp +++ lldb/source/Target/Thread.cpp @@ -540,7 +540,8 @@ if (process_sp) saved_state.orig_stop_id = process_sp->GetStopID(); saved_state.current_inlined_depth = GetCurrentInlinedDepth(); - + saved_state.m_completed_plan_stack = m_completed_plan_stack; + return true; } @@ -573,6 +574,7 @@ SetStopInfo(saved_state.stop_info_sp); GetStackFrameList()->SetCurrentInlinedDepth( saved_state.current_inlined_depth); + m_completed_plan_stack = saved_state.m_completed_plan_stack; return true; } Index: lldb/include/lldb/Target/ThreadPlan.h === --- lldb/include/lldb/Target/ThreadPlan.h +++ lldb/include/lldb/Target/ThreadPlan.h @@ -40,9 +40,10 @@ // The thread maintaining a thread plan stack, and you program the actions of a // particular thread // by pushing plans onto the plan stack. -// There is always a "Current" plan, which is the head of the plan stack, +// There is always a "Current" plan, which is the top of the plan stack, // though in some cases -// a plan may defer to plans higher in the stack for some piece of information. +// a plan may defer to plans higher in the stack for some piece of information +// (let us define that the plan stack grows downwards). // // The plan stack is never empty, there is always a Base Plan which persists // through the life @@ -109,6 +110,15 @@ // plans in the time between when // your plan gets unshipped and the next resume. // +// Thread State Checkpoint: +// +// Note that calling functions on target process (ThreadPlanCallFunction) changes +// current thread state. The function can be called either by direct user demand or +// internally, for example lldb allocates memory on device to calculate breakpoint +// condition expression - on Linux it is performed by calling mmap on device. +// ThreadStateCheckpoint saves Thread state (stop info and completed +// plan stack) to restore it after completing function call. +// // Over the lifetime of the plan, various methods of the ThreadPlan are then // called in response to changes of state in // the process we are debugging as follows: @@ -149,7 +159,7 @@ // If the Current plan answers "true" then it is asked if the stop should // percolate all the way to the // user by calling the ShouldStop method. If the current plan doesn't explain -// the stop, then we query down +// the stop, then we query up // the plan stack for a plan that does explain the stop. The plan that does // explain the stop then needs to // figure out what to do about the plans below it in the stack. If the stop is @@ -241,9 +251,9 @@ // // When the process stops, the thread is given a StopReason, in the form of a // StopInfo object. If there is a completed -// plan corresponding to the stop, then the "actual" stop reason will be +// plan corresponding to the stop, then the "actual" stop reason can be // suppressed, and instead a StopInfoThreadPlan -// object will be cons'ed up from the highest completed plan in the stack. +// object will be cons'ed up from the top completed plan in the stack. // However, if the plan doesn't want to be // the stop reason, then it can call SetPlanComplete and pass in "false" for // the "success" parameter. In that case, Index: lldb/include/lldb/Target/Thread.h === --- lldb/include/lldb/Target/Thread.h +++ lldb/include/lldb/Target/Thread.h @@ -126,6 +126,7 @@ // bit of data. lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you // might continue with the wrong signals. +std::vector m_completed_plan_stack; lldb::RegisterCheckpointSP register_backup_sp; // You need to restore the registers, of course... uint32_t current_inlined_depth; Index: lldb/source/Target/Thread.cpp === --- lldb/source/Target/Thread.cpp +++ lldb/source/Target/Thread.cpp @@ -540,7 +540,8 @@ if (process_sp) saved_state.orig_stop_id = process_sp->GetStopID(); saved_state.current_inlined_depth = GetCurrentInlinedDepth(); - + saved_state.m_completed_plan_stack = m_completed_plan_stack; + return true; } @@ -573,6 +574,7 @@ SetStopInfo(saved_state.stop_info_sp); GetStackFrameList()->SetCurrentInlinedDepth( saved_state.current_inlined_depth); + m_completed_plan_stack = saved_state.m_completed_plan_stack; return true; } Index
[Lldb-commits] [PATCH] D29036: Add format_provider for lldb::StateType
clayborg accepted this revision. clayborg added a comment. This revision is now accepted and ready to land. Looks good as long as the test suite is happy. https://reviews.llvm.org/D29036 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D28945: Add completed_plan_stack to LLDB ThreadStateCheckpoint
jingham accepted this revision. jingham added a comment. This revision is now accepted and ready to land. I can't think of a case where you would need the discarded plans to stick around across a function call, I don't think you need to preserve that stack. I do worry a bit about how the completed plans go away, mostly as you say because of breakpoints which could be left without their ThreadPlan handlers. The simplest proceeding is to convert all the Destructor cleanups to WillPop and then just call that in the destructor. That way the real cleanup goes on when the plan is popped and the destructor is just a safety backup. Leaving the plans around longer increases the risk of this: especially when we know we are changing behavior to leave completed plans around while running a function call thread plan. I did that conversion for the Function call thread plans a while back, but must have gotten interrupted on the way to doing them all. Anyway, I doesn't make sense to gate this change on completing that piece of work. https://reviews.llvm.org/D28945 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r292880 - weak-link debugserver against the LoggingSupport framework;
Author: jmolenda Date: Mon Jan 23 22:16:03 2017 New Revision: 292880 URL: http://llvm.org/viewvc/llvm-project?rev=292880&view=rev Log: weak-link debugserver against the LoggingSupport framework; systems without this framework will not get a link error. Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=292880&r1=292879&r2=292880&view=diff == --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Jan 23 22:16:03 2017 @@ -713,6 +713,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.10; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ""; + "OTHER_LDFLAGS[sdk=macosx*]" = ""; STRIP_INSTALLED_PRODUCT = NO; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_BUILDER = "$(USER)"; @@ -883,6 +884,8 @@ MobileCoreServices, "$(LLDB_COMPRESSION_LDFLAGS)", "$(LLDB_ZLIB_LDFLAGS)", + "-weak_framework", + LoggingSupport, ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "-sectcreate", @@ -892,6 +895,8 @@ "$(LLDB_ENERGY_LFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", "$(LLDB_ZLIB_LDFLAGS)", + "-weak_framework", + LoggingSupport, ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; @@ -985,6 +990,8 @@ MobileCoreServices, "$(LLDB_COMPRESSION_LDFLAGS)", "$(LLDB_ZLIB_LDFLAGS)", + "-weak_framework", + LoggingSupport, ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "-sectcreate", @@ -994,6 +1001,8 @@ "$(LLDB_ENERGY_LFLAGS)", "$(LLDB_ZLIB_LDFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", + "-weak_framework", + LoggingSupport, ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; @@ -1086,6 +1095,8 @@ MobileCoreServices, "$(LLDB_COMPRESSION_LDFLAGS)", "$(LLDB_ZLIB_LDFLAGS)", + "-weak_framework", + LoggingSupport, ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "-sectcreate", @@ -1095,6 +1106,8 @@ "$(LLDB_ENERGY_LFLAGS)", "$(LLDB_COMPRESSION_LDFLAGS)", "$(LLDB_ZLIB_LDFLAGS)", + "-weak_framework", + LoggingSupport, ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; @@ -1175,6 +1188,8 @@ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( "-framework", Foundation, + "-weak_framework", + LoggingSupport, ); "OTHER_LDFLAGS[sdk=macosx*]" = ( "-sectcreate", @@ -1182,6 +1197,8 @@ __info_plist, "$(PROJECT_DIR)/resources/lldb-debugserver-Info.plist", "$(LLDB_ENERGY_LFLAGS)", +
[Lldb-commits] [lldb] r292882 - Enable compression capability in debugserver for all of ios/watchos/tvos
Author: jmolenda Date: Mon Jan 23 22:43:40 2017 New Revision: 292882 URL: http://llvm.org/viewvc/llvm-project?rev=292882&view=rev Log: Enable compression capability in debugserver for all of ios/watchos/tvos environments. Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=292882&r1=292881&r2=292882&view=diff == --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Mon Jan 23 22:43:40 2017 @@ -3611,15 +3611,10 @@ rnb_err_t RNBRemote::HandlePacket_qSuppo snprintf(buf, sizeof(buf), "qXfer:features:read+;PacketSize=%x;qEcho+", max_packet_size); - // By default, don't enable compression. It's only worth doing when we are - // working - // with a low speed communication channel. bool enable_compression = false; (void)enable_compression; -// Enable compression when debugserver is running on a watchOS device where -// communication may be over Bluetooth. -#if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1 +#if defined (TARGET_OS_WATCH) || defined (TARGET_OS_IOS) || defined (TARGET_OS_TVOS) enable_compression = true; #endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r292884 - Prefer lzfse if it is an available compression method (this was
Author: jmolenda Date: Mon Jan 23 23:06:14 2017 New Revision: 292884 URL: http://llvm.org/viewvc/llvm-project?rev=292884&view=rev Log: Prefer lzfse if it is an available compression method (this was defaulting to zlib previously). Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=292884&r1=292883&r2=292884&view=diff == --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Mon Jan 23 23:06:14 2017 @@ -607,10 +607,10 @@ bool GDBRemoteCommunication::DecompressP m_compression_type == CompressionType::LZFSE || m_compression_type == CompressionType::LZ4)) { compression_algorithm compression_type; -if (m_compression_type == CompressionType::ZlibDeflate) - compression_type = COMPRESSION_ZLIB; -else if (m_compression_type == CompressionType::LZFSE) +if (m_compression_type == CompressionType::LZFSE) compression_type = COMPRESSION_LZFSE; +else if (m_compression_type == CompressionType::ZlibDeflate) + compression_type = COMPRESSION_ZLIB; else if (m_compression_type == CompressionType::LZ4) compression_type = COMPRESSION_LZ4_RAW; else if (m_compression_type == CompressionType::LZMA) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r292890 - Fix the last commit; compression was being enabled on mac native
Author: jmolenda Date: Tue Jan 24 00:09:06 2017 New Revision: 292890 URL: http://llvm.org/viewvc/llvm-project?rev=292890&view=rev Log: Fix the last commit; compression was being enabled on mac native which led to ERROR: test_auxv_chunked_reads_work_debugserver (tools/lldb-server/TestGdbRemoteAuxvSupport.py) ERROR: test_auxv_data_is_correct_size_debugserver (tools/lldb-server/TestGdbRemoteAuxvSupport.py) ERROR: test_auxv_keys_look_valid_debugserver (tools/lldb-server/TestGdbRemoteAuxvSupport.py) ERROR: test_qSupported_returns_known_stub_features_debugserver (tools/lldb-server/TestLldbGdbServer.py) failures because debugserver was advertising compression being available, e.g. send packet: $qSupported:xmlRegisters=i386,arm,mips#12 read packet: $qXfer:features:read+;PacketSize=2;qEcho+;SupportedCompressions=zlib-deflate;DefaultCompressionMinSize=384#00 maybe these tests should be a little more accepting of additional features. but I didn't mean for this to be enabled on mac native. Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=292890&r1=292889&r2=292890&view=diff == --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Tue Jan 24 00:09:06 2017 @@ -3614,7 +3614,7 @@ rnb_err_t RNBRemote::HandlePacket_qSuppo bool enable_compression = false; (void)enable_compression; -#if defined (TARGET_OS_WATCH) || defined (TARGET_OS_IOS) || defined (TARGET_OS_TVOS) +#if (defined (TARGET_OS_WATCH) && TARGET_OS_WATCHOS == 1) || (defined (TARGET_OS_IOS) && TARGET_OS_IOS == 1) || (defined (TARGET_OS_TVOS) && TARGET_OS_TVOS == 1) enable_compression = true; #endif ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits