Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-30 Thread Kirill Lapshin via lldb-commits
KLapshin added inline comments.


Comment at: test/tools/lldb-mi/control/TestMiExec.py:16
@@ +15,3 @@
+@skipIfFreeBSD # Failure presumably due to StopAtEntry most likely not 
implemented
+def test_lldbmi_exec_run(self):
+"""Test that 'lldb-mi --interpreter' can stop at entry."""

KLapshin wrote:
> ki.stfu wrote:
> > This test doesn't pass on Linux due to missing *stopped notification:
> > ```
> > $ bin/lldb-mi echo
> > (gdb)
> > -file-exec-and-symbols "echo"
> > ^done
> > (gdb)
> > =library-loaded,id="/bin/echo",target-name="/bin/echo",host-name="/bin/echo",symbols-loaded="0",loaded_addr="-",size="0"
> > -exec-run --start
> > ^running
> > =thread-group-started,id="i1",pid="28031"
> > (gdb)
> > =thread-created,id="1",group-id="i1"
> > =thread-selected,id="1"
> > (gdb)
> > =library-loaded,id="/bin/echo",target-name="/bin/echo",host-name="/bin/echo",symbols-loaded="0",loaded_addr="-",size="0"
> > process status
> > Process 28031 stopped
> > * thread #1: tid = 28031, 0x77dd9cd0, name = 'echo', stop reason = 
> > signal SIGSTOP
> > frame #0: 0x77dd9cd0
> > ->  0x77dd9cd0: movq   %rsp, %rdi
> > 0x77dd9cd3: callq  0x77dddc30
> > 0x77dd9cd8: movq   %rax, %r12
> > 0x77dd9cdb: movl   0x22310f(%rip), %eax
> > ^done
> > (gdb)
> > ```
> > 
> > You can XFAIL this test case with the link to the corresponding issue on 
> > bug tracker (create a new one if needed).
> Ilia, thank you for checking on Linux - I just don't have lldb Linux build on 
> hands yet, will setup it and do checks on Linux as well.
> 
> Will mark test as expected to fail on Linux yet with reference to issue on 
> bug tracker.
Bug about missing *stopped notification on Linux platform has been entered: 
https://llvm.org/bugs/show_bug.cgi?id=25000


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-30 Thread Kirill Lapshin via lldb-commits
KLapshin updated this revision to Diff 36128.
KLapshin added a comment.

Test has been marked as XFAILed for Linux (x86_64) case.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977

Files:
  test/tools/lldb-mi/control/TestMiExec.py
  tools/lldb-mi/MICmdCmdExec.cpp
  tools/lldb-mi/MICmdCmdExec.h
  tools/lldb-mi/MICmdCmdSupportList.cpp

Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -48,6 +48,7 @@
 // Throws:  None.
 //--
 CMICmdCmdExecRun::CMICmdCmdExecRun()
+: m_constStrArgStart("start")
 {
 // Command factory matches this name with that received from the stdin stream
 m_strMiCmd = "exec-run";
@@ -68,6 +69,23 @@
 }
 
 //++ 
+// Details: The invoker requires this function. The parses the command line options
+//  arguments to extract values for each of those arguments.
+// Type:Overridden.
+// Args:None.
+// Return:  MIstatus::success - Functional succeeded.
+//  MIstatus::failure - Functional failed.
+// Throws:  None.
+//--
+bool
+CMICmdCmdExecRun::ParseArgs()
+{
+m_setCmdArgs.Add(
+new CMICmdArgValOptionLong(m_constStrArgStart, false, true, CMICmdArgValListBase::eArgValType_OptionLong, 0));
+return ParseValidateCmdOptions();
+}
+
+//++ 
 // Details: The invoker requires this function. The command does work in this function.
 //  The command is likely to communicate with the LLDB SBDebugger in here.
 // Type:Overridden.
@@ -84,6 +102,15 @@
 lldb::SBStream errMsg;
 lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
 launchInfo.SetListener(rSessionInfo.GetListener());
+
+CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart);
+
+// Run to first instruction or main() requested ?
+if (pArgStart->GetFound())
+{
+launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() | lldb::eLaunchFlagStopAtEntry);
+}
+
 lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
 if ((!process.IsValid()) || (error.Fail()))
 {
@@ -103,6 +130,7 @@
 //++ 
 // Details: The invoker requires this function. The command prepares a MI Record Result
 //  for the work carried out in the Execute().
+//  Called only in case if Execute() set status as successful on completion.
 // Type:Overridden.
 // Args:None.
 // Return:  MIstatus::success - Functional succeeded.
@@ -112,31 +140,21 @@
 bool
 CMICmdCmdExecRun::Acknowledge()
 {
-if (m_lldbResult.GetErrorSize() > 0)
-{
-const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
-const CMICmnMIValueResult miValueResult("message", miValueConst);
-const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
-m_miResultRecord = miRecordResult;
-}
-else
-{
-const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
-m_miResultRecord = miRecordResult;
+const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+m_miResultRecord = miRecordResult;
 
-CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
-lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
-// Give the client '=thread-group-started,id="i1" pid="xyz"'
-m_bHasResultRecordExtra = true;
-const CMICmnMIValueConst miValueConst2("i1");
-const CMICmnMIValueResult miValueResult2("id", miValueConst2);
-const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
-const CMICmnMIValueConst miValueConst(strPid);
-const CMICmnMIValueResult miValueResult("pid", miValueConst);
-CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2);
-miOutOfBand.Add(miValueResult);
-m_miResultRecordExtra = miOutOfBand.GetString();
-}
+CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
+// Give the client '=thread-group-started,id="i1" pid="xyz"'
+m_bHasResultRecordExtra = true;
+const CMICmnMIValueConst miValueConst2("i1");
+const CMICmnMIValueResult miValueResult2("id", miValueConst2);
+const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
+const CMICmnMIValueConst miValueConst(strPid);
+const CMICmnMIValueResult miValueResult("pid", miValueConst);
+CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_Th

Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-30 Thread Kirill Lapshin via lldb-commits
KLapshin marked an inline comment as done.
KLapshin added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-30 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

In http://reviews.llvm.org/D12968#256563, @labath wrote:

> This is definitely not a proper fix for this problem, it merely sweeps the 
> problem under the carpet. If something like this makes a difference then it 
> means something has gone horribly wrong a long time ago. I haven't been able 
> to reproduce this locally, but I'd recommend trying to set up some 
> memory-allocation/thread-race checker and see what it produces.
>
> I still think the original solution of hijacking the listener was correct, 
> but we need to figure out what is the right point at which to hijack it. I'll 
> try to look into this when I get a bit of time.


@labath,

Yes, I even noticed what latest "fix" patch is just hint to fact what whole 
Process m_listener object looks like freed or unitialized memory - m_events 
collection size in Listener before crash happened looks invalid absolutely - 
random value, in my case about 8 millions events (!).

This looks about threads race condition, so still investigating - slow because 
bit bust with other issues, excuse me.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-30 Thread Kirill Lapshin via lldb-commits
KLapshin added inline comments.


Comment at: test/tools/lldb-mi/control/TestMiExec.py:16
@@ +15,3 @@
+@skipIfFreeBSD # Failure presumably due to StopAtEntry most likely not 
implemented
+@expectedFailureAll("llvm.org/pr25000", oslist=["linux"])
+def test_lldbmi_exec_run(self):

It looks like lldb-mi didn't received SIGSTOP evbent on Linux platform because 
event was not rebroadcasted because "Process::WaitForProcessToStop (timeout = 
(nil))
Process::WaitForProcessToStop returning without waiting for events; process 
private and public states are already 'stopped'.
" - see full log (process, event channel) attached to llvm.org/pr25000 bug.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-10-01 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

@labath,

Regarding how to reproduce - this problem looks remote target specific only - 
in my case gdb-remote modules involved.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-10-07 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

In http://reviews.llvm.org/D12968#261762, @labath wrote:

> I have committed http://reviews.llvm.org/D13056 with the event hijacking 
> portion from your patch. I think your use case should be working now. I am 
> planning to return to this later, as I believe there are still some edge 
> cases lurking here.


Yes, of course - hijacked listener setup solves (or hides) issue.

Problem on my side (if no hijacking listener used and without your patch for 
race condition) is - halt listener often just got timeout (10 secs), then 
target process killed without crash. Or may work without timeout - this is 
really threads conflict issue - m_listener in process object unusable because 
operates with invalid data - I even saw strings in log belongs to RSP module - 
just random memory areas, memory corrupted. If you set hijacked listener - no 
problem because it looks has non-shared m_events collection.

Again - this is remote debugging issue only. Also I checked on Linux host 
debugging - process killed just fine.

I will try pure public lldb build with your patch and will see then, thanks.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-10-07 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

In http://reviews.llvm.org/D12968#259931, @clayborg wrote:

> This can't be the real fix for this. We must be able to trust the empty() 
> function call. We must have someone playing with the collection without 
> locking the mutex. Please find the real bug.


Hello @clayborg,

I will continue investigation why it works unstable without hijacked listener 
setup.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-18 Thread Kirill Lapshin via lldb-commits
KLapshin created this revision.
KLapshin added reviewers: dawn, ki.stfu, abidh.
KLapshin added a subscriber: lldb-commits.
KLapshin set the repository for this revision to rL LLVM.

This patch fixes lldb core crash in Listener waiting for process ended and 
operates with already invalid data if lldb-mi requested process destroy in 
-exec-abort command handler without getting process stopped at first.

To avoid crash in existing code MI user should do process stop explicitly:

-exec-interrupt
-exec-abort

With this patch MI ExecAbort handler make sure process stopped safely, then 
process destroyed, so MI user can invoke just -exec-abort MI command  to finish 
debug session regardless of process running or stopped already.

-exec-abort use "process interrupt" command via command interpreter class.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968

Files:
  tools/lldb-mi/MICmdCmdExec.cpp
  tools/lldb-mi/MICmdCmdExec.h

Index: tools/lldb-mi/MICmdCmdExec.h
===
--- tools/lldb-mi/MICmdCmdExec.h
+++ tools/lldb-mi/MICmdCmdExec.h
@@ -328,4 +328,7 @@
 bool Acknowledge() override;
 // From CMICmnBase
 /* dtor */ ~CMICmdCmdExecAbort() override;
+// Attributes:
+  private:
+lldb::SBCommandReturnObject m_lldbResult;
 };
Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -1167,6 +1167,18 @@
 {
 CMICmnLLDBDebugSessionInfo 
&rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
 lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+CMIUtilString strCmd("process interrupt");
+const lldb::ReturnStatus status = 
rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, 
false);
+MIunused(status);
+
+if (!CMIDriver::Instance().SetDriverStateRunningNotDebugging())
+{
+const CMIUtilString 
&rErrMsg(CMIDriver::Instance().GetErrorDescription());
+
SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
 strCmd.c_str(), rErrMsg.c_str()));
+return MIstatus::failure;
+}
+
 if (!sbProcess.IsValid())
 {
 SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), 
m_cmdData.strMiCmd.c_str()));


Index: tools/lldb-mi/MICmdCmdExec.h
===
--- tools/lldb-mi/MICmdCmdExec.h
+++ tools/lldb-mi/MICmdCmdExec.h
@@ -328,4 +328,7 @@
 bool Acknowledge() override;
 // From CMICmnBase
 /* dtor */ ~CMICmdCmdExecAbort() override;
+// Attributes:
+  private:
+lldb::SBCommandReturnObject m_lldbResult;
 };
Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -1167,6 +1167,18 @@
 {
 CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
 lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+CMIUtilString strCmd("process interrupt");
+const lldb::ReturnStatus status = rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
+MIunused(status);
+
+if (!CMIDriver::Instance().SetDriverStateRunningNotDebugging())
+{
+const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
+SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), strCmd.c_str(), rErrMsg.c_str()));
+return MIstatus::failure;
+}
+
 if (!sbProcess.IsValid())
 {
 SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-18 Thread Kirill Lapshin via lldb-commits
KLapshin created this revision.
KLapshin added reviewers: dawn, ki.stfu, abidh.
KLapshin added a subscriber: lldb-commits.
KLapshin set the repository for this revision to rL LLVM.

In some cases debugger user may want to get debugged process stopped at very 
early point - at first instruction.

With lldb command line interpreter this may be done easily with exisiting 
option to "process launch" command:

process launch -s

Currently, if lldb-mi user want to use pure MI only - important for IDEs - 
there is no possibility to run debugged process and getting it stopped right on 
first instruction.

This patch is implementation of such option with additional boolean flag set by 
-gdb-set and launch program in -exec-run handler with checking this flag.

-gdb-set/show option, patch for -exec-run handler and lldb-mi tests for added 
-gdb-set/show option.

Example:

-gdb-set process-stopatentry on/off
-exec-run
...

Repository:
  rL LLVM

http://reviews.llvm.org/D12977

Files:
  test/tools/lldb-mi/TestMiGdbSetShow.py
  tools/lldb-mi/MICmdCmdExec.cpp
  tools/lldb-mi/MICmdCmdGdbSet.cpp
  tools/lldb-mi/MICmdCmdGdbSet.h
  tools/lldb-mi/MICmdCmdGdbShow.cpp
  tools/lldb-mi/MICmdCmdGdbShow.h
  tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
  tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
  tools/lldb-mi/MICmnResources.cpp
  tools/lldb-mi/MICmnResources.h

Index: tools/lldb-mi/MICmnResources.h
===
--- tools/lldb-mi/MICmnResources.h
+++ tools/lldb-mi/MICmnResources.h
@@ -266,6 +266,7 @@
 IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH,
 IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS,
 IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION,
+IDS_CMD_ERR_GDBSET_OPT_PROCESS_STOPATENTRY, // LLDB_EMBARCADERO_MI_STOPATENTRY
 IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS,
 IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION,
 IDS_CMD_ERR_EXPR_INVALID,
Index: tools/lldb-mi/MICmnResources.cpp
===
--- tools/lldb-mi/MICmnResources.cpp
+++ tools/lldb-mi/MICmnResources.cpp
@@ -249,6 +249,7 @@
 {IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH, "'solib-search-path' requires at least one argument"},
 {IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS, "'print' expects option-name and \"on\" or \"off\""},
 {IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION, "'print' error. The option '%s' not found"},
+{IDS_CMD_ERR_GDBSET_OPT_PROCESS_STOPATENTRY, "'process-stopatentry' expects \"on\" or \"off\""}, // LLDB_EMBARCADERO_MI_STOPATENTRY
 {IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS, "'print' expects option-name and \"on\" or \"off\""},
 {IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION, "'print' error. The option '%s' not found"},
 {IDS_CMD_ERR_EXPR_INVALID, "Failed to evaluate expression: %s"},
Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
===
--- tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
+++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
@@ -182,6 +182,7 @@
 const CMIUtilString m_constStrPrintCharArrayAsString;
 const CMIUtilString m_constStrPrintExpandAggregates;
 const CMIUtilString m_constStrPrintAggregateFieldNames;
+const CMIUtilString m_constStrProcessStopAtEntry; // LLDB_EMBARCADERO_MI_STOPATENTRY
 
 // Typedefs:
   private:
Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
===
--- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -42,6 +42,7 @@
 , m_constStrSharedDataSolibPath("Solib Path")
 , m_constStrPrintCharArrayAsString("Print CharArrayAsString")
 , m_constStrPrintExpandAggregates("Print ExpandAggregates")
+, m_constStrProcessStopAtEntry("Process StopAtEntry") // LLDB_EMBARCADERO_MI_STOPATENTRY
 , m_constStrPrintAggregateFieldNames("Print AggregateFieldNames")
 {
 }
Index: tools/lldb-mi/MICmdCmdGdbShow.h
===
--- tools/lldb-mi/MICmdCmdGdbShow.h
+++ tools/lldb-mi/MICmdCmdGdbShow.h
@@ -70,6 +70,7 @@
 bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
 bool OptionFnLanguage(const CMIUtilString::VecString_t &vrWords);
 bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
+bool OptionFnProcessStopAtEntry(const CMIUtilString::VecString_t &vrWords); // LLDB_EMBARCADERO_MI_STOPATENTRY
 
 // Attributes:
   private:
Index: tools/lldb-mi/MICmdCmdGdbShow.cpp
===
--- tools/lldb-mi/MICmdCmdGdbShow.cpp
+++ tools/lldb-mi/MICmdCmdGdbShow.cpp
@@ -27,6 +27,7 @@
 // Instantiations:
 const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_mapGdbOptionNameToFnGdbOptionPtr = {
 {"target-async", &CMICmdCmdGdbShow::OptionFnTargetAsync},
+{"process-stopatentry", &CMICmdCmdGdbShow::OptionFnProcessStopAtEntry}, // LLDB_EMBARCADERO_MI_STOPATENTRY
 

Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-18 Thread Kirill Lapshin via lldb-commits
KLapshin updated the summary for this revision.
KLapshin removed rL LLVM as the repository for this revision.
KLapshin updated this revision to Diff 35109.
KLapshin added a comment.

Minor initial diff cleanup.


http://reviews.llvm.org/D12977

Files:
  test/tools/lldb-mi/TestMiGdbSetShow.py
  tools/lldb-mi/MICmdCmdExec.cpp
  tools/lldb-mi/MICmdCmdGdbSet.cpp
  tools/lldb-mi/MICmdCmdGdbSet.h
  tools/lldb-mi/MICmdCmdGdbShow.cpp
  tools/lldb-mi/MICmdCmdGdbShow.h
  tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
  tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
  tools/lldb-mi/MICmnResources.cpp
  tools/lldb-mi/MICmnResources.h

Index: tools/lldb-mi/MICmnResources.h
===
--- tools/lldb-mi/MICmnResources.h
+++ tools/lldb-mi/MICmnResources.h
@@ -266,6 +266,7 @@
 IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH,
 IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS,
 IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION,
+IDS_CMD_ERR_GDBSET_OPT_PROCESS_STOPATENTRY,
 IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS,
 IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION,
 IDS_CMD_ERR_EXPR_INVALID,
Index: tools/lldb-mi/MICmnResources.cpp
===
--- tools/lldb-mi/MICmnResources.cpp
+++ tools/lldb-mi/MICmnResources.cpp
@@ -249,6 +249,7 @@
 {IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH, "'solib-search-path' requires at least one argument"},
 {IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS, "'print' expects option-name and \"on\" or \"off\""},
 {IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION, "'print' error. The option '%s' not found"},
+{IDS_CMD_ERR_GDBSET_OPT_PROCESS_STOPATENTRY, "'process-stopatentry' expects \"on\" or \"off\""},
 {IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS, "'print' expects option-name and \"on\" or \"off\""},
 {IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION, "'print' error. The option '%s' not found"},
 {IDS_CMD_ERR_EXPR_INVALID, "Failed to evaluate expression: %s"},
Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
===
--- tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
+++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
@@ -182,6 +182,7 @@
 const CMIUtilString m_constStrPrintCharArrayAsString;
 const CMIUtilString m_constStrPrintExpandAggregates;
 const CMIUtilString m_constStrPrintAggregateFieldNames;
+const CMIUtilString m_constStrProcessStopAtEntry;
 
 // Typedefs:
   private:
Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
===
--- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -42,6 +42,7 @@
 , m_constStrSharedDataSolibPath("Solib Path")
 , m_constStrPrintCharArrayAsString("Print CharArrayAsString")
 , m_constStrPrintExpandAggregates("Print ExpandAggregates")
+, m_constStrProcessStopAtEntry("Process StopAtEntry")
 , m_constStrPrintAggregateFieldNames("Print AggregateFieldNames")
 {
 }
Index: tools/lldb-mi/MICmdCmdGdbShow.h
===
--- tools/lldb-mi/MICmdCmdGdbShow.h
+++ tools/lldb-mi/MICmdCmdGdbShow.h
@@ -70,6 +70,7 @@
 bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
 bool OptionFnLanguage(const CMIUtilString::VecString_t &vrWords);
 bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
+bool OptionFnProcessStopAtEntry(const CMIUtilString::VecString_t &vrWords);
 
 // Attributes:
   private:
Index: tools/lldb-mi/MICmdCmdGdbShow.cpp
===
--- tools/lldb-mi/MICmdCmdGdbShow.cpp
+++ tools/lldb-mi/MICmdCmdGdbShow.cpp
@@ -27,6 +27,7 @@
 // Instantiations:
 const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_mapGdbOptionNameToFnGdbOptionPtr = {
 {"target-async", &CMICmdCmdGdbShow::OptionFnTargetAsync},
+{"process-stopatentry", &CMICmdCmdGdbShow::OptionFnProcessStopAtEntry},
 {"print", &CMICmdCmdGdbShow::OptionFnPrint},
 {"language", &CMICmdCmdGdbShow::OptionFnLanguage},
 {"fallback", &CMICmdCmdGdbShow::OptionFnFallback}};
@@ -246,6 +247,31 @@
 }
 
 //++ 
+// Details: Carry out work to complete the GDB show option 'process-stopatentry' to prepare
+//  and send back the requested information.
+// Type:Method.
+// Args:vrWords - (R) List of additional parameters used by this option.
+// Return:  MIstatus::success - Function succeeded.
+//  MIstatus::failure - Function failed.
+// Throws:  None.
+//--
+bool
+CMICmdCmdGdbShow::OptionFnProcessStopAtEntry(const CMIUtilString::VecString_t &vrWords)
+{
+MIunused(vrWords);
+
+CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+
+bool bProcessMustStopAtEntry = false;
+
+// Get current process stopatent

Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-21 Thread Kirill Lapshin via lldb-commits
KLapshin added inline comments.


Comment at: tools/lldb-mi/MICmdCmdExec.cpp:92
@@ +91,3 @@
+const char *pCmd = bProcessMustStopAtEntry ? "process launch -s" : 
"process launch";
+const lldb::ReturnStatus rtn = 
rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, 
m_lldbResult);
+MIunused(rtn);

enlight wrote:
> The process should be launched through the SB API, not the command 
> interpreter. I'm not very familiar with the SB API but I'd try using the 
> **lldb::eLaunchFlagStopAtEntry** flag with **SBLaunchInfo::SetLaunchFlags()**.
You are right, no doubt - this is clear what Target and Process API direct 
usage is faster and straightforward manner.

Just couple words regarding why interpreter used instead here - patch was 
prepared at moment when lldb-MI had lack synchronization (via Listener) with 
lldb Core, so setting corresponding flag gave random results - app may stop or 
not. Via interpreter it worked fine always - that's why I stated "more 
reliable" in review header.

I will check if flag pass is enough currently - this will make patch shorter 
and clearer.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-21 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

In http://reviews.llvm.org/D12977#249437, @enlight wrote:

> According to the GDB-MI spec the exec-run 
> 
>  command already has a **start** option. Support for the **start** option can 
> be detected by checking for **exec-run-start-option** in the list of features 
> returned by the list-features 
> 
>  command. So, what's the rationale for diverging from the spec in this case?
>
> In GDB your example would be written as:
>  -exec-run --start


Fully agreed.

At same time - this option is relatively new, was not present in older GDBs. 
For example - GDB used in Xcode before switch to lldb just do stop at 
_dyld_start unconditionally always, no option.

Thanks for review, patch will be changed.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-21 Thread Kirill Lapshin via lldb-commits
KLapshin added inline comments.


Comment at: tools/lldb-mi/MICmdCmdExec.cpp:92
@@ +91,3 @@
+const char *pCmd = bProcessMustStopAtEntry ? "process launch -s" : 
"process launch";
+const lldb::ReturnStatus rtn = 
rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, 
m_lldbResult);
+MIunused(rtn);

KLapshin wrote:
> enlight wrote:
> > The process should be launched through the SB API, not the command 
> > interpreter. I'm not very familiar with the SB API but I'd try using the 
> > **lldb::eLaunchFlagStopAtEntry** flag with 
> > **SBLaunchInfo::SetLaunchFlags()**.
> You are right, no doubt - this is clear what Target and Process API direct 
> usage is faster and straightforward manner.
> 
> Just couple words regarding why interpreter used instead here - patch was 
> prepared at moment when lldb-MI had lack synchronization (via Listener) with 
> lldb Core, so setting corresponding flag gave random results - app may stop 
> or not. Via interpreter it worked fine always - that's why I stated "more 
> reliable" in review header.
> 
> I will check if flag pass is enough currently - this will make patch shorter 
> and clearer.
Also - in many other places lldb-MI still use interpreter for cmds.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-22 Thread Kirill Lapshin via lldb-commits
KLapshin updated the summary for this revision.
KLapshin updated this revision to Diff 35390.

Repository:
  rL LLVM

http://reviews.llvm.org/D12968

Files:
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -3930,7 +3930,15 @@
 // Consume the halt event.
 TimeValue timeout (TimeValue::Now());
 timeout.OffsetWithSeconds(1);
-StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
+
+ListenerSP listener_sp (new 
Listener("lldb.Process.HaltForDestroyOrDetach.hijack"));
+HijackProcessEvents(listener_sp.get());
+
+StateType state = WaitForProcessToStop (NULL, &exit_event_sp, 
true, listener_sp.get());
+
+// Don't forget to notify other listeners.
+RestoreProcessEvents();
+BroadcastEvent(exit_event_sp);
 
 // If the process exited while we were waiting for it to stop, put 
the exited event into
 // the shared pointer passed in and return.  Our caller doesn't 
need to do anything else, since


Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -3930,7 +3930,15 @@
 // Consume the halt event.
 TimeValue timeout (TimeValue::Now());
 timeout.OffsetWithSeconds(1);
-StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
+
+ListenerSP listener_sp (new Listener("lldb.Process.HaltForDestroyOrDetach.hijack"));
+HijackProcessEvents(listener_sp.get());
+
+StateType state = WaitForProcessToStop (NULL, &exit_event_sp, true, listener_sp.get());
+
+// Don't forget to notify other listeners.
+RestoreProcessEvents();
+BroadcastEvent(exit_event_sp);
 
 // If the process exited while we were waiting for it to stop, put the exited event into
 // the shared pointer passed in and return.  Our caller doesn't need to do anything else, since
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13056: Fix race condition during process detach

2015-09-22 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

See http://reviews.llvm.org/D12968 also - fix for missed hijacked listener set 
in Process::HaltForDestroyOrDetach()


http://reviews.llvm.org/D13056



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-22 Thread Kirill Lapshin via lldb-commits
KLapshin updated this revision to Diff 35392.

Repository:
  rL LLVM

http://reviews.llvm.org/D12968

Files:
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -3930,7 +3930,15 @@
 // Consume the halt event.
 TimeValue timeout (TimeValue::Now());
 timeout.OffsetWithSeconds(1);
-StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
+
+ListenerSP listener_sp (new 
Listener("lldb.Process.HaltForDestroyOrDetach.hijack"));
+HijackProcessEvents(listener_sp.get());
+
+StateType state = WaitForProcessToStop (&timeout, &exit_event_sp, 
true, listener_sp.get());
+
+// Don't forget to notify other listeners.
+RestoreProcessEvents();
+BroadcastEvent(exit_event_sp);
 
 // If the process exited while we were waiting for it to stop, put 
the exited event into
 // the shared pointer passed in and return.  Our caller doesn't 
need to do anything else, since


Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -3930,7 +3930,15 @@
 // Consume the halt event.
 TimeValue timeout (TimeValue::Now());
 timeout.OffsetWithSeconds(1);
-StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
+
+ListenerSP listener_sp (new Listener("lldb.Process.HaltForDestroyOrDetach.hijack"));
+HijackProcessEvents(listener_sp.get());
+
+StateType state = WaitForProcessToStop (&timeout, &exit_event_sp, true, listener_sp.get());
+
+// Don't forget to notify other listeners.
+RestoreProcessEvents();
+BroadcastEvent(exit_event_sp);
 
 // If the process exited while we were waiting for it to stop, put the exited event into
 // the shared pointer passed in and return.  Our caller doesn't need to do anything else, since
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-22 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

Greg, I reworked initial workaround solution, now this is exact fix.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-22 Thread Kirill Lapshin via lldb-commits
KLapshin added a subscriber: labath.
KLapshin added a comment.

Due to @labath reworked and replaced HaltForDestroyOrDetach to 
StopHaltForDestroyOrDetach method (see http://reviews.llvm.org/D13056) and his 
patch already approved by @clayborg and crash still reproducible with just race 
condition fix patch from @labath I suggest to apply this patch first, then 
patch for race condition - merge should be fine.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-23 Thread Kirill Lapshin via lldb-commits
KLapshin removed rL LLVM as the repository for this revision.
KLapshin updated this revision to Diff 35491.

http://reviews.llvm.org/D12968

Files:
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -3930,8 +3930,16 @@
 // Consume the interrupt event.
 TimeValue timeout (TimeValue::Now());
 timeout.OffsetWithSeconds(10);
-StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
 
+ListenerSP listener_sp (new 
Listener("lldb.Process.StopForDestroyOrDetach.hijack"));
+HijackProcessEvents(listener_sp.get());
+
+StateType state = WaitForProcessToStop (&timeout, &exit_event_sp, 
true, listener_sp.get());
+
+// Don't forget to notify other listeners.
+RestoreProcessEvents();
+BroadcastEvent(exit_event_sp);
+
 // If the process exited while we were waiting for it to stop, put the 
exited event into
 // the shared pointer passed in and return.  Our caller doesn't need 
to do anything else, since
 // they don't have a process anymore...


Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -3930,8 +3930,16 @@
 // Consume the interrupt event.
 TimeValue timeout (TimeValue::Now());
 timeout.OffsetWithSeconds(10);
-StateType state = WaitForProcessToStop (&timeout, &exit_event_sp);
 
+ListenerSP listener_sp (new Listener("lldb.Process.StopForDestroyOrDetach.hijack"));
+HijackProcessEvents(listener_sp.get());
+
+StateType state = WaitForProcessToStop (&timeout, &exit_event_sp, true, listener_sp.get());
+
+// Don't forget to notify other listeners.
+RestoreProcessEvents();
+BroadcastEvent(exit_event_sp);
+
 // If the process exited while we were waiting for it to stop, put the exited event into
 // the shared pointer passed in and return.  Our caller doesn't need to do anything else, since
 // they don't have a process anymore...
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-23 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

@labath,

I updated patch against actual source in SVN - i.e. with taking into account 
your change (Halt*->Stop*).

Regarding matter of this patch - I just tried to make process stop synchronous, 
see Process::ResumeSynchronous() - same technique was applied month ago.

Agreed what crash may be related to freed memory reuse, but not investigated it 
yet in deep.


http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-23 Thread Kirill Lapshin via lldb-commits
KLapshin marked an inline comment as done.
KLapshin added a comment.

Done.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-23 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

In http://reviews.llvm.org/D12968#251719, @labath wrote:

> In http://reviews.llvm.org/D12968#251696, @KLapshin wrote:
>
> > Regarding matter of this patch - I just tried to make process stop 
> > synchronous, see Process::ResumeSynchronous() - same technique was applied 
> > months ago (@ki.stfu).
> >
> > Agreed what crash may be related to freed memory reuse, but not 
> > investigated it yet in deep.
>
>
> Fair enough, your patch definitely makes things better. I'm just trying to 
> understand the root cause so we can fix this definitively.
>
> If you look at ResumeSynchronous, you see that the hijacking happens there 
> before we attempt to resume the process (PrivateResume()). This makes it 
> race-free because we grab the events before it gets a chance to generate any. 
> In your case, things are a bit more complicated, since the process is already 
> running and can come to a stop at any moment, and we need to make sure we 
> don't miss those events.
>
> Do you have the ability to run lldb-mi under valgrind or msan? If you can, 
> I'd be interested in taking a look at the output they produce in this case. 
> Or if you have a simple repro case, I can try to do it myself.
>
> pl


@labath,

No, I didn't tried to use valgrind yet, as testcase you can create some Cocoa 
app in Xcode (actually Empty Form template is enough - just to make sure what 
app will not ended by itself), then start debug session on iOS device or OSX 
using lldb-mi (i.e. - via MI) and just do -exec-run, then do -exec-abort while 
app running - without this patch you will be able to reproduce crash easily. I 
checked if crash may be reproduced with your race condition patch - yes, 
reproducible.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-23 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

As little summary what should be added to existing lldb-mi in context of this 
review:

- list-features MI command (for getting supported features in future, currently 
only one "exec-run-start-option" feature will be reported)
- add --start option to -exec-run, set StopAtEntry flag in LaunchInfo if 
--start option specified on input
- rework process launch in way SB target API only allowed,
- add tests




Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-24 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

@clayborg, @labath,

After more deep investigation I think setting listener for hijacking also looks 
like workaround. Setting additional listener just change code flow path and 
buggy path not executed, thus no crash. At top level - crash appeared in 
Process::m_listener involved - as no hijacked listener was set in Destroy().

See code below:

  StateType
  Process::WaitForProcessToStop (const TimeValue *timeout,
 EventSP *event_sp_ptr,
 bool wait_always,
 Listener *hijack_listener,
 Stream *stream)
  {
  // We can't just wait for a "stopped" event, because the stopped event 
may have restarted the target.
  // We have to actually check each event, and in the case of a stopped 
event check the restarted flag
  // on the event.
  if (event_sp_ptr)
  event_sp_ptr->reset();
  StateType state = GetState();
  // If we are exited or detached, we won't ever get back to any
  // other valid state...
  if (state == eStateDetached || state == eStateExited)
  return state;
  
  Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
  if (log)
  log->Printf ("Process::%s (timeout = %p)", __FUNCTION__,
   static_cast(timeout));
  
  if (!wait_always &&
  StateIsStoppedState(state, true) &&
  StateIsStoppedState(GetPrivateState(), true))
  {
  if (log)
  log->Printf("Process::%s returning without waiting for events; 
process private and public states are already 'stopped'.",
  __FUNCTION__);
  // We need to toggle the run lock as this won't get done in
  // SetPublicState() if the process is hijacked.
  if (hijack_listener)
  m_public_run_lock.SetStopped();
  return state;
  }
  
  while (state != eStateInvalid)
  {
  EventSP event_sp;
  state = WaitForStateChangedEvents (timeout, event_sp, 
hijack_listener);  <---
  if (event_sp_ptr && event_sp)
  *event_sp_ptr = event_sp;
  



  StateType
  Process::WaitForStateChangedEvents (const TimeValue *timeout, EventSP 
&event_sp, Listener *hijack_listener)
  {
  Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
  
  if (log)
  log->Printf ("Process::%s (timeout = %p, event_sp)...", __FUNCTION__,
   static_cast(timeout));
  
  Listener *listener = hijack_listener;
  if (listener == NULL)
  listener = &m_listener;  <--- what if m_listener was set as 
unitialized or deallocated Listener instance, "dummy" listener ?
  
  StateType state = eStateInvalid;
  if (listener->WaitForEventForBroadcasterWithType (timeout,
this,

eBroadcastBitStateChanged | eBroadcastBitInterrupt,
event_sp))
  {
  if (event_sp && event_sp->GetType() == eBroadcastBitStateChanged)
  state = 
Process::ProcessEventData::GetStateFromEvent(event_sp.get());
  else if (log)
  log->Printf ("Process::%s got no event or was interrupted.", 
__FUNCTION__);
  }
  ...

You can reproduce crash even without lldb-MI driver - just with remote iOS 
target and "process launch", then "process kill".

Corresponding log ("log enable lldb events"):

  (lldb) process launch
  ...
  Process::ShouldBroadcastEvent (0x7ff1fa4a1260) => new state: running, last 
broadcast state: running - NO
  0x7ff1fad1b110 Listener::WaitForEventsInternal (timeout = { 0x0 }) for 
lldb.process.internal_state_listener
  (lldb) process kill
  0x7ff1fad1afa0 
Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent 
(event_sp = {0x7ff1fce160d0 Event: broadcaster = 0x7ff1fad1afa0 
(lldb.process.internal_state_broadcaster), type = 0x0002, data = }, 
unique =0) hijack = 0x0
  0x7ff1fad1b110 Listener('lldb.process.internal_state_listener')::AddEvent 
(event_sp = {0x7ff1fce160d0})
  0x7ff1fa48e300 Listener::WaitForEventsInternal (timeout = { 0x7fff57d47240 }) 
for  <-- WHAT ?! Listener without name - Process::m_listener may be ?
  0x7ff1fad1b110 'lldb.process.internal_state_listener' 
Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], 
event_type_mask=0x, remove=1) event 0x7ff1fce160d0
  0x7ff1fad1ae38 Broadcaster("lldb.process")::HijackBroadcaster 
(listener("lldb.process.halt_listener")=0x7ff1fe01ca00)
  CRASH !

Will continue investigation.


Repository:
  rL LLVM

http://reviews.llvm.org/D12968



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-25 Thread Kirill Lapshin via lldb-commits
KLapshin updated the summary for this revision.
KLapshin updated this revision to Diff 35740.
KLapshin added a comment.

Patch reworked for suggested "-exec-run --start" manner, no "CLI" interpreter 
use and check if --start option supported via -list-features.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977

Files:
  test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
  tools/lldb-mi/MICmdCmdExec.cpp
  tools/lldb-mi/MICmdCmdExec.h
  tools/lldb-mi/MICmdCmdSupportList.cpp

Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -48,6 +48,7 @@
 // Throws:  None.
 //--
 CMICmdCmdExecRun::CMICmdCmdExecRun()
+: m_constStrArgStart("start")
 {
 // Command factory matches this name with that received from the stdin stream
 m_strMiCmd = "exec-run";
@@ -68,6 +69,23 @@
 }
 
 //++ 
+// Details: The invoker requires this function. The parses the command line options
+//  arguments to extract values for each of those arguments.
+// Type:Overridden.
+// Args:None.
+// Return:  MIstatus::success - Functional succeeded.
+//  MIstatus::failure - Functional failed.
+// Throws:  None.
+//--
+bool
+CMICmdCmdExecRun::ParseArgs()
+{
+m_setCmdArgs.Add(
+new CMICmdArgValOptionLong(m_constStrArgStart, false, true, CMICmdArgValListBase::eArgValType_OptionLong, 0));
+return ParseValidateCmdOptions();
+}
+
+//++ 
 // Details: The invoker requires this function. The command does work in this function.
 //  The command is likely to communicate with the LLDB SBDebugger in here.
 // Type:Overridden.
@@ -84,6 +102,15 @@
 lldb::SBStream errMsg;
 lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
 launchInfo.SetListener(rSessionInfo.GetListener());
+
+CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart);
+
+// Run to first instruction or main() requested ?
+if (pArgStart->GetFound())
+{
+launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() | lldb::eLaunchFlagStopAtEntry);
+}
+
 lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
 if ((!process.IsValid()) || (error.Fail()))
 {
Index: tools/lldb-mi/MICmdCmdExec.h
===
--- tools/lldb-mi/MICmdCmdExec.h
+++ tools/lldb-mi/MICmdCmdExec.h
@@ -55,6 +55,7 @@
 // From CMICmdInvoker::ICmd
 bool Execute() override;
 bool Acknowledge() override;
+bool ParseArgs() override;
 // From CMICmnBase
 /* dtor */ ~CMICmdCmdExecRun() override;
 
@@ -61,6 +62,7 @@
 // Attributes:
   private:
 lldb::SBCommandReturnObject m_lldbResult;
+const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first instruction or main(), just run process if not specified
 };
 
 //++ 
Index: tools/lldb-mi/MICmdCmdSupportList.cpp
===
--- tools/lldb-mi/MICmdCmdSupportList.cpp
+++ tools/lldb-mi/MICmdCmdSupportList.cpp
@@ -71,8 +71,13 @@
 bool
 CMICmdCmdSupportListFeatures::Acknowledge()
 {
-const CMICmnMIValueConst miValueConst("data-read-memory-bytes");
-const CMICmnMIValueList miValueList(miValueConst);
+// Declare supported features here
+const CMICmnMIValueConst miValueConst1("data-read-memory-bytes");
+const CMICmnMIValueConst miValueConst2("exec-run-start-option");
+CMICmnMIValueList miValueList(true);
+// Some of features may depend on host or/and target, decide what to add below
+miValueList.Add(miValueConst1);
+miValueList.Add(miValueConst2);
 const CMICmnMIValueResult miValueResult("features", miValueList);
 const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
 m_miResultRecord = miRecordResult;
Index: test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
===
--- test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
+++ test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
@@ -12,6 +12,26 @@
 
 @lldbmi_test
 @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
+@skipIfFreeBSD # Failure presumably due to StopAtEntry most likely not implemented
+def test_lldbmi_gdb_set_process_stopatentry_on(self):
+"""Test that 'lldb-mi --interpreter' can stop at entry."""
+
+self.spawnLldbMi(args = None)
+
+# Load executable
+self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+self.expect("\^done")
+
+# Test that program is stopped at entry
+sel

Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-25 Thread Kirill Lapshin via lldb-commits
KLapshin marked an inline comment as done.
KLapshin added a comment.

"CLI" intepreter not used in ExecRun handler in reworked patch.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-26 Thread Kirill Lapshin via lldb-commits
KLapshin added a comment.

@brucem, @enlight

Is this patch is fine for you now ?


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-28 Thread Kirill Lapshin via lldb-commits
KLapshin updated the summary for this revision.
KLapshin updated this revision to Diff 35865.

Repository:
  rL LLVM

http://reviews.llvm.org/D12977

Files:
  test/tools/lldb-mi/control/TestMiExec.py
  tools/lldb-mi/MICmdCmdExec.cpp
  tools/lldb-mi/MICmdCmdExec.h
  tools/lldb-mi/MICmdCmdSupportList.cpp

Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -48,6 +48,7 @@
 // Throws:  None.
 //--
 CMICmdCmdExecRun::CMICmdCmdExecRun()
+: m_constStrArgStart("start")
 {
 // Command factory matches this name with that received from the stdin stream
 m_strMiCmd = "exec-run";
@@ -68,6 +69,23 @@
 }
 
 //++ 
+// Details: The invoker requires this function. The parses the command line options
+//  arguments to extract values for each of those arguments.
+// Type:Overridden.
+// Args:None.
+// Return:  MIstatus::success - Functional succeeded.
+//  MIstatus::failure - Functional failed.
+// Throws:  None.
+//--
+bool
+CMICmdCmdExecRun::ParseArgs()
+{
+m_setCmdArgs.Add(
+new CMICmdArgValOptionLong(m_constStrArgStart, false, true, CMICmdArgValListBase::eArgValType_OptionLong, 0));
+return ParseValidateCmdOptions();
+}
+
+//++ 
 // Details: The invoker requires this function. The command does work in this function.
 //  The command is likely to communicate with the LLDB SBDebugger in here.
 // Type:Overridden.
@@ -84,6 +102,15 @@
 lldb::SBStream errMsg;
 lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
 launchInfo.SetListener(rSessionInfo.GetListener());
+
+CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart);
+
+// Run to first instruction or main() requested ?
+if (pArgStart->GetFound())
+{
+launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() | lldb::eLaunchFlagStopAtEntry);
+}
+
 lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
 if ((!process.IsValid()) || (error.Fail()))
 {
Index: tools/lldb-mi/MICmdCmdExec.h
===
--- tools/lldb-mi/MICmdCmdExec.h
+++ tools/lldb-mi/MICmdCmdExec.h
@@ -55,6 +55,7 @@
 // From CMICmdInvoker::ICmd
 bool Execute() override;
 bool Acknowledge() override;
+bool ParseArgs() override;
 // From CMICmnBase
 /* dtor */ ~CMICmdCmdExecRun() override;
 
@@ -61,6 +62,7 @@
 // Attributes:
   private:
 lldb::SBCommandReturnObject m_lldbResult;
+const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first instruction or main(), just run process if not specified
 };
 
 //++ 
Index: tools/lldb-mi/MICmdCmdSupportList.cpp
===
--- tools/lldb-mi/MICmdCmdSupportList.cpp
+++ tools/lldb-mi/MICmdCmdSupportList.cpp
@@ -71,8 +71,13 @@
 bool
 CMICmdCmdSupportListFeatures::Acknowledge()
 {
-const CMICmnMIValueConst miValueConst("data-read-memory-bytes");
-const CMICmnMIValueList miValueList(miValueConst);
+// Declare supported features here
+const CMICmnMIValueConst miValueConst1("data-read-memory-bytes");
+const CMICmnMIValueConst miValueConst2("exec-run-start-option");
+CMICmnMIValueList miValueList(true);
+// Some features may depend on host or/and target, decide what to add below
+miValueList.Add(miValueConst1);
+miValueList.Add(miValueConst2);
 const CMICmnMIValueResult miValueResult("features", miValueList);
 const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
 m_miResultRecord = miRecordResult;
Index: test/tools/lldb-mi/control/TestMiExec.py
===
--- test/tools/lldb-mi/control/TestMiExec.py
+++ test/tools/lldb-mi/control/TestMiExec.py
@@ -12,6 +12,25 @@
 
 @lldbmi_test
 @skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
+@skipIfFreeBSD # Failure presumably due to StopAtEntry most likely not implemented
+def test_lldbmi_exec_run(self):
+"""Test that 'lldb-mi --interpreter' can stop at entry."""
+
+self.spawnLldbMi(args = None)
+
+# Load executable
+self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+self.expect("\^done")
+
+# Test that program is stopped at entry
+self.runCmd("-exec-run --start")
+self.expect("\^running")
+self.expect("\*stopped,reason=\"signal-received\",signal-name=\"SIGSTOP\",signal-meaning=\"Stop\",.*?thread-id=\"1\",stopped-threads=\"all\"")
+# Test that lldb-mi is ready to execute n

Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-28 Thread Kirill Lapshin via lldb-commits
KLapshin marked an inline comment as done.
KLapshin added a comment.

Requested changes applied, updated patch uploaded.



Comment at: tools/lldb-mi/MICmdCmdExec.h:58
@@ -57,2 +57,3 @@
 bool Acknowledge() override;
+bool ParseArgs() override;
 // From CMICmnBase

Ilia, I checked string positions for ParseArgs() method in MICmdCmdExec.h and 
other command headers - ParseArgs() placed always third, so this change done in 
accordance with current, at least public, lldb-mi headers and minimal patching 
as possible.

What inconsistency you mentioned ?

Please take a look on ExecRun command class modified with ParseArgs() method 
added and non-modified classes in lldb-mi - ExecFinish or ExecNext, for example:


```
class CMICmdCmdExecRun : public CMICmdBase
{
// Statics:
  public:
// Required by the CMICmdFactory when registering *this command
static CMICmdBase *CreateSelf();

// Methods:
  public:
/* ctor */ CMICmdCmdExecRun();

// Overridden:
  public:
// From CMICmdInvoker::ICmd
bool Execute() override;
bool Acknowledge() override;
bool ParseArgs() override;
// From CMICmnBase
/* dtor */ ~CMICmdCmdExecRun() override;

// Attributes:
  private:
lldb::SBCommandReturnObject m_lldbResult;
const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first 
instruction or main(), just run process if not specified
};
```


```
class CMICmdCmdExecFinish : public CMICmdBase
{
// Statics:
  public:
// Required by the CMICmdFactory when registering *this command
static CMICmdBase *CreateSelf();

// Methods:
  public:
/* ctor */ CMICmdCmdExecFinish();

// Overridden:
  public:
// From CMICmdInvoker::ICmd
bool Execute() override;
bool Acknowledge() override;
bool ParseArgs() override;  <---
// From CMICmnBase
/* dtor */ ~CMICmdCmdExecFinish() override;

// Attributes:
  private:
lldb::SBCommandReturnObject m_lldbResult;
const CMIUtilString m_constStrArgThread; // Not specified in MI spec but 
Eclipse gives this option
const CMIUtilString m_constStrArgFrame;  // Not specified in MI spec but 
Eclipse gives this option
};
```


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-29 Thread Kirill Lapshin via lldb-commits
KLapshin updated the summary for this revision.
KLapshin updated this revision to Diff 35969.

Repository:
  rL LLVM

http://reviews.llvm.org/D12977

Files:
  test/tools/lldb-mi/control/TestMiExec.py
  tools/lldb-mi/MICmdCmdExec.cpp
  tools/lldb-mi/MICmdCmdExec.h
  tools/lldb-mi/MICmdCmdSupportList.cpp

Index: tools/lldb-mi/MICmdCmdExec.cpp
===
--- tools/lldb-mi/MICmdCmdExec.cpp
+++ tools/lldb-mi/MICmdCmdExec.cpp
@@ -48,6 +48,7 @@
 // Throws:  None.
 //--
 CMICmdCmdExecRun::CMICmdCmdExecRun()
+: m_constStrArgStart("start")
 {
 // Command factory matches this name with that received from the stdin stream
 m_strMiCmd = "exec-run";
@@ -68,6 +69,23 @@
 }
 
 //++ 
+// Details: The invoker requires this function. The parses the command line options
+//  arguments to extract values for each of those arguments.
+// Type:Overridden.
+// Args:None.
+// Return:  MIstatus::success - Functional succeeded.
+//  MIstatus::failure - Functional failed.
+// Throws:  None.
+//--
+bool
+CMICmdCmdExecRun::ParseArgs()
+{
+m_setCmdArgs.Add(
+new CMICmdArgValOptionLong(m_constStrArgStart, false, true, CMICmdArgValListBase::eArgValType_OptionLong, 0));
+return ParseValidateCmdOptions();
+}
+
+//++ 
 // Details: The invoker requires this function. The command does work in this function.
 //  The command is likely to communicate with the LLDB SBDebugger in here.
 // Type:Overridden.
@@ -84,6 +102,15 @@
 lldb::SBStream errMsg;
 lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
 launchInfo.SetListener(rSessionInfo.GetListener());
+
+CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart);
+
+// Run to first instruction or main() requested ?
+if (pArgStart->GetFound())
+{
+launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() | lldb::eLaunchFlagStopAtEntry);
+}
+
 lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
 if ((!process.IsValid()) || (error.Fail()))
 {
@@ -103,6 +130,7 @@
 //++ 
 // Details: The invoker requires this function. The command prepares a MI Record Result
 //  for the work carried out in the Execute().
+//  Called only in case if Execute() set status as successful on completion.
 // Type:Overridden.
 // Args:None.
 // Return:  MIstatus::success - Functional succeeded.
@@ -112,31 +140,21 @@
 bool
 CMICmdCmdExecRun::Acknowledge()
 {
-if (m_lldbResult.GetErrorSize() > 0)
-{
-const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
-const CMICmnMIValueResult miValueResult("message", miValueConst);
-const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
-m_miResultRecord = miRecordResult;
-}
-else
-{
-const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
-m_miResultRecord = miRecordResult;
+const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+m_miResultRecord = miRecordResult;
 
-CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
-lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
-// Give the client '=thread-group-started,id="i1" pid="xyz"'
-m_bHasResultRecordExtra = true;
-const CMICmnMIValueConst miValueConst2("i1");
-const CMICmnMIValueResult miValueResult2("id", miValueConst2);
-const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
-const CMICmnMIValueConst miValueConst(strPid);
-const CMICmnMIValueResult miValueResult("pid", miValueConst);
-CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2);
-miOutOfBand.Add(miValueResult);
-m_miResultRecordExtra = miOutOfBand.GetString();
-}
+CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
+// Give the client '=thread-group-started,id="i1" pid="xyz"'
+m_bHasResultRecordExtra = true;
+const CMICmnMIValueConst miValueConst2("i1");
+const CMICmnMIValueResult miValueResult2("id", miValueConst2);
+const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
+const CMICmnMIValueConst miValueConst(strPid);
+const CMICmnMIValueResult miValueResult("pid", miValueConst);
+CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2);
+ 

Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-29 Thread Kirill Lapshin via lldb-commits
KLapshin marked an inline comment as done.
KLapshin added a comment.

In http://reviews.llvm.org/D12977#255390, @ki.stfu wrote:

> lgtm apart a lack of description about the changes in 
> tools/lldb-mi/MICmdCmdSupportList.cpp


I added description about changes in list-features cmd handler in review 
summary. In source two comments present already.



Comment at: tools/lldb-mi/MICmdCmdExec.h:64
@@ -62,3 +63,3 @@
   private:
-lldb::SBCommandReturnObject m_lldbResult;
+const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first 
instruction or main(), just run process if not specified
 };

Yes, @abidh added process start via Target Launch() method instead of "CLI" 
process command on 14 Aug 2014. But he forgot to remove m_lldbResult member 
usage (checking for error string has non-zero size) in Acknowledge() method. I 
removed this member usage finally.

BTW - as ExecRun is sync only command by its meaning (process started or not), 
Acknowledge() method called only if Execute() method reported successful status 
on completion, so we can skip any Process creation checks in Acknowledge(), 
thus m_lldbResult really not needed.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-29 Thread Kirill Lapshin via lldb-commits
KLapshin marked an inline comment as done.
KLapshin added a comment.

m_lldbResult usage has beed removed in ExecRun::Acknowledge() method, 
corresponding member removed from cmd class.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D12968: Fix for lldb-mi crash in Listener code if -exec-abort MI command was invoked without getting process stopped

2015-09-29 Thread Kirill Lapshin via lldb-commits
KLapshin updated this revision to Diff 36005.
KLapshin added a comment.

I realized what m_events.empty check in Listener::FindNextEventInternal() 
method returned event collection is NOT empty - probably because list.empty() 
just compare begin != end pointers, but pointers may be absolutely invalid.

So, as another workaround - switch to m_events.size() == 0 check.

I know - this looks funny because list.size() has O(N) complexity - i.e. - 
linear and time consuming, but works in this case because it do real empty list 
check.

I consider latest diff at moment just as some hint.

Actually two threads may modify events collection - one associated with Process 
and another one with GDBProcess module.

Full log (process and events) below corresponding to m_events.empty replaced 
with m_events collection size checking:

  0x7f9f3d535110 Listener::WaitForEventsInternal (timeout = { 0x0 }) for 
lldb.process.internal_state_listener
  -exec-abort
  0x7f9f3d534fa0 
Broadcaster("lldb.process.internal_state_broadcaster")::HijackBroadcaster 
(listener("lldb.process.halt_listener")=0x7fff5ac24580)
  Process::SetPrivateState (stopped)
  0x7fff5ac24580 Listener::WaitForEventsInternal (timeout = { 0x7fff5ac244e0 }) 
for lldb.process.halt_listener
  Process::SetPrivateState (stopped) stop_id = 16
  0x7f9f3d534fa0 
Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent 
(event_sp = {0x7f9f39f16ff0 Event: broadcaster = 0x7f9f3d534fa0 
(lldb.process.internal_state_broadcaster), type = 0x0001, data = { process 
= 0x7f9f3d534e00 (pid = 258), state = stopped}}, unique =0) hijack = 
0x7fff5ac24580
  0x7fff5ac24580 Listener('lldb.process.halt_listener')::AddEvent (event_sp = 
{0x7f9f39f16ff0})
  0x7f9f3d536660 Listener::WaitForEventsInternal (timeout = { 0x0 }) for 
lldb.process.gdb-remote.async-listener
  0x7fff5ac24580 'lldb.process.halt_listener' 
Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], 
event_type_mask=0x, remove=1) event 0x7f9f39f16ff0
  0x7f9f3d534fa0 
Broadcaster("lldb.process.internal_state_broadcaster")::RestoreBroadcaster 
(about to pop listener("lldb.process.halt_listener")=0x7fff5ac24580)
  0x7f9f3d534fa0 
Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent 
(event_sp = {0x7f9f39f16ff0 Event: broadcaster = 0x7f9f3d534fa0 
(lldb.process.internal_state_broadcaster), type = 0x0001, data = { process 
= 0x7f9f3d534e00 (pid = 258), state = stopped}}, unique =0) hijack = 0x0
  0x7f9f3d535110 Listener('lldb.process.internal_state_listener')::AddEvent 
(event_sp = {0x7f9f39f16ff0})
  0x7f9f3d535110 'lldb.process.internal_state_listener' 
Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], 
event_type_mask=0x, remove=1) event 0x7f9f39f16ff0
  Process::StopForDestroyOrDetach() About to stop.
  0x70428840 Listener::StartListeningForEvents (broadcaster = 
0x7f9f3d5356a0, mask = 0x0020) acquired_mask = 0x0020 for 
Communication::SyncronizeWithReadThread
  0x7f9f3d534fa0 
Broadcaster("lldb.process.internal_state_broadcaster")::BroadcastEvent 
(event_sp = {0x7f9f39e16fa0 Event: broadcaster = 0x7f9f3d534fa0 
(lldb.process.internal_state_broadcaster), type = 0x0002, data = }, 
unique =0) hijack = 0x0
  0x7f9f3d535110 Listener('lldb.process.internal_state_listener')::AddEvent 
(event_sp = {0x7f9f39e16fa0})
  Process::WaitForProcessToStop (timeout = 0x7fff5ac25b40)
  Process::WaitForStateChangedEvents (timeout = 0x7fff5ac25b40, event_sp)...
  0x7f9f3b0ed920 Listener::WaitForEventsInternal (timeout = { 0x7fff5ac25b40 }) 
for
  0x7f9f3b0ed920 Listener::WaitForEventsInternal() unknown error for
  Process::WaitForStateChangedEvents (timeout = 0x7fff5ac25b40, event_sp) => 
invalid
  Process::StopForDestroyOrDetach() failed to stop, state is: invalid
  0x7f9f3d535db8 Broadcaster("gdb-remote.client")::HijackBroadcaster 
(listener("lldb.NotifyHijacker")=0x109d0bfa8)
  Process::ShouldBroadcastEvent (0x7f9f39f16ff0) stopped due to an interrupt, 
state: stopped
  Process::ShouldBroadcastEvent (0x7f9f39f16ff0) => new state: stopped, last 
broadcast state: stopped - YES
  Process::HandlePrivateEvent (pid = 258) broadcasting new state stopped (old 
state running) to public
  0x7f9f3d534e38 Broadcaster("lldb.process")::BroadcastEvent (event_sp = 
{0x7f9f39f16ff0 Event: broadcaster = 0x7f9f3d534e38 (lldb.process), type = 
0x0001 (state-changed), data = { process = 0x7f9f3d534e00 (pid = 258), 
state = stopped}}, unique =0) hijack = 0x0
  0x7f9f3a058278 Listener('lldb.Debugger')::AddEvent (event_sp = 
{0x7f9f39f16ff0})
  Process::WaitForEventsPrivate (timeout = 0x0, event_sp)...
  0x7f9f3d535110 Listener::WaitForEventsInternal (timeout = { 0x0 }) for 
lldb.process.internal_state_listener
  0x7f9f3d535110 'lldb.process.internal_state_listener' 
Listener::FindNextEventInternal(broadcaster=0x0, broadcaster_names=0x0[0], 
event_type_mask=0x, remove=1) event 0x7f9f39e16fa0
  0x7f9f3d534fa0 
Broadcaster("lldb.process.

Re: [Lldb-commits] [PATCH] D12977: LLDB MI addition for getting process stopped at first instruction right after launch via -exec-run

2015-09-29 Thread Kirill Lapshin via lldb-commits
KLapshin added inline comments.


Comment at: test/tools/lldb-mi/control/TestMiExec.py:16
@@ +15,3 @@
+@skipIfFreeBSD # Failure presumably due to StopAtEntry most likely not 
implemented
+def test_lldbmi_exec_run(self):
+"""Test that 'lldb-mi --interpreter' can stop at entry."""

ki.stfu wrote:
> This test doesn't pass on Linux due to missing *stopped notification:
> ```
> $ bin/lldb-mi echo
> (gdb)
> -file-exec-and-symbols "echo"
> ^done
> (gdb)
> =library-loaded,id="/bin/echo",target-name="/bin/echo",host-name="/bin/echo",symbols-loaded="0",loaded_addr="-",size="0"
> -exec-run --start
> ^running
> =thread-group-started,id="i1",pid="28031"
> (gdb)
> =thread-created,id="1",group-id="i1"
> =thread-selected,id="1"
> (gdb)
> =library-loaded,id="/bin/echo",target-name="/bin/echo",host-name="/bin/echo",symbols-loaded="0",loaded_addr="-",size="0"
> process status
> Process 28031 stopped
> * thread #1: tid = 28031, 0x77dd9cd0, name = 'echo', stop reason = 
> signal SIGSTOP
> frame #0: 0x77dd9cd0
> ->  0x77dd9cd0: movq   %rsp, %rdi
> 0x77dd9cd3: callq  0x77dddc30
> 0x77dd9cd8: movq   %rax, %r12
> 0x77dd9cdb: movl   0x22310f(%rip), %eax
> ^done
> (gdb)
> ```
> 
> You can XFAIL this test case with the link to the corresponding issue on bug 
> tracker (create a new one if needed).
Ilia, thank you for checking on Linux - I just don't have lldb Linux build on 
hands yet, will setup it and do checks on Linux as well.

Will mark test as expected to fail on Linux yet with reference to issue on bug 
tracker.


Repository:
  rL LLVM

http://reviews.llvm.org/D12977



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits