[Lldb-commits] [PATCH] D52788: Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 168450.
sgraenitz added a comment.

Minor fixes


https://reviews.llvm.org/D52788

Files:
  include/lldb/API/SBCommandInterpreter.h
  include/lldb/Interpreter/CommandInterpreter.h
  lit/Settings/Resources/EchoCommandsAll.out
  lit/Settings/Resources/EchoCommandsNoComments.out
  lit/Settings/Resources/EchoCommandsNone.out
  lit/Settings/Resources/EchoCommandsQuiet.out
  lit/Settings/Resources/EchoCommandsTest.in
  lit/Settings/TestEchoCommands.test
  source/API/SBCommandInterpreter.cpp
  source/Commands/CommandObjectCommands.cpp
  source/Interpreter/CommandInterpreter.cpp

Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -76,26 +76,43 @@
 
 static const char *k_white_space = " \t\v";
 
+static constexpr bool NoGlobalSetting = true;
+static constexpr uintptr_t DefaultValueTrue = true;
+static constexpr uintptr_t DefaultValueFalse = false;
+static constexpr const char *NoCStrDefault = nullptr;
+
 static constexpr PropertyDefinition g_properties[] = {
-{"expand-regex-aliases", OptionValue::eTypeBoolean, true, false, nullptr,
- {}, "If true, regular expression alias commands will show the "
-  "expanded command that will be executed. This can be used to "
-  "debug new regular expression alias commands."},
-{"prompt-on-quit", OptionValue::eTypeBoolean, true, true, nullptr, {},
+{"expand-regex-aliases", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueFalse, NoCStrDefault, {},
+ "If true, regular expression alias commands will show the "
+ "expanded command that will be executed. This can be used to "
+ "debug new regular expression alias commands."},
+{"prompt-on-quit", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
  "If true, LLDB will prompt you before quitting if there are any live "
  "processes being debugged. If false, LLDB will quit without asking in any "
  "case."},
-{"stop-command-source-on-error", OptionValue::eTypeBoolean, true, true,
- nullptr, {}, "If true, LLDB will stop running a 'command source' "
-  "script upon encountering an error."},
-{"space-repl-prompts", OptionValue::eTypeBoolean, true, false, nullptr, {},
- "If true, blank lines will be printed between between REPL submissions."}};
+{"stop-command-source-on-error", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, LLDB will stop running a 'command source' "
+ "script upon encountering an error."},
+{"space-repl-prompts", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueFalse, NoCStrDefault, {},
+ "If true, blank lines will be printed between between REPL submissions."},
+{"echo-commands", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, commands will be echoed before they are evaluated."},
+{"echo-comment-commands", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, commands will be echoed even if they are pure comment lines."}};
 
 enum {
   ePropertyExpandRegexAliases = 0,
   ePropertyPromptOnQuit = 1,
   ePropertyStopCmdSourceOnError = 2,
-  eSpaceReplPrompts = 3
+  eSpaceReplPrompts = 3,
+  eEchoCommands = 4,
+  eEchoCommentCommands = 5
 };
 
 ConstString &CommandInterpreter::GetStaticBroadcasterClass() {
@@ -142,6 +159,28 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool CommandInterpreter::GetEchoCommands() const {
+  const uint32_t idx = eEchoCommands;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetEchoCommands(bool b) {
+  const uint32_t idx = eEchoCommands;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
+bool CommandInterpreter::GetEchoCommentCommands() const {
+  const uint32_t idx = eEchoCommentCommands;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetEchoCommentCommands(bool b) {
+  const uint32_t idx = eEchoCommentCommands;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 void CommandInterpreter::AllowExitCodeOnQuit(bool allow) {
   m_allow_exit_code = allow;
   if (!allow)
@@ -2296,8 +2335,9 @@
   eHandleCommandFlagStopOnContinue = (1u << 0),
   eHandleCommandFlagStopOnError = (1u << 1),
   eHandleCommandFlagEchoCommand = (1u << 2),
-  eHandleCommandFlagPrintResult = (1u << 3),
-  eHandleCommandFlagStopOnCrash = (1u << 4)
+  eHandleCommandFlagEchoCommentCommand = (1u << 3),
+  eHandleCommandFlagPrintResult = (1u << 4),
+  eHandleCommandFlagStopOnCrash = (1u << 5)
 };
 
 void CommandInterpreter

[Lldb-commits] [PATCH] D52788: Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 168453.
sgraenitz added a comment.

Enable interpreter.echo-comment-commands in lit-lldb-init. All tests still 
passing.


https://reviews.llvm.org/D52788

Files:
  include/lldb/API/SBCommandInterpreter.h
  include/lldb/Interpreter/CommandInterpreter.h
  lit/Settings/Resources/EchoCommandsAll.out
  lit/Settings/Resources/EchoCommandsNoComments.out
  lit/Settings/Resources/EchoCommandsNone.out
  lit/Settings/Resources/EchoCommandsQuiet.out
  lit/Settings/Resources/EchoCommandsTest.in
  lit/Settings/TestEchoCommands.test
  lit/lit-lldb-init
  source/API/SBCommandInterpreter.cpp
  source/Commands/CommandObjectCommands.cpp
  source/Interpreter/CommandInterpreter.cpp

Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -76,26 +76,43 @@
 
 static const char *k_white_space = " \t\v";
 
+static constexpr bool NoGlobalSetting = true;
+static constexpr uintptr_t DefaultValueTrue = true;
+static constexpr uintptr_t DefaultValueFalse = false;
+static constexpr const char *NoCStrDefault = nullptr;
+
 static constexpr PropertyDefinition g_properties[] = {
-{"expand-regex-aliases", OptionValue::eTypeBoolean, true, false, nullptr,
- {}, "If true, regular expression alias commands will show the "
-  "expanded command that will be executed. This can be used to "
-  "debug new regular expression alias commands."},
-{"prompt-on-quit", OptionValue::eTypeBoolean, true, true, nullptr, {},
+{"expand-regex-aliases", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueFalse, NoCStrDefault, {},
+ "If true, regular expression alias commands will show the "
+ "expanded command that will be executed. This can be used to "
+ "debug new regular expression alias commands."},
+{"prompt-on-quit", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
  "If true, LLDB will prompt you before quitting if there are any live "
  "processes being debugged. If false, LLDB will quit without asking in any "
  "case."},
-{"stop-command-source-on-error", OptionValue::eTypeBoolean, true, true,
- nullptr, {}, "If true, LLDB will stop running a 'command source' "
-  "script upon encountering an error."},
-{"space-repl-prompts", OptionValue::eTypeBoolean, true, false, nullptr, {},
- "If true, blank lines will be printed between between REPL submissions."}};
+{"stop-command-source-on-error", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, LLDB will stop running a 'command source' "
+ "script upon encountering an error."},
+{"space-repl-prompts", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueFalse, NoCStrDefault, {},
+ "If true, blank lines will be printed between between REPL submissions."},
+{"echo-commands", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, commands will be echoed before they are evaluated."},
+{"echo-comment-commands", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, commands will be echoed even if they are pure comment lines."}};
 
 enum {
   ePropertyExpandRegexAliases = 0,
   ePropertyPromptOnQuit = 1,
   ePropertyStopCmdSourceOnError = 2,
-  eSpaceReplPrompts = 3
+  eSpaceReplPrompts = 3,
+  eEchoCommands = 4,
+  eEchoCommentCommands = 5
 };
 
 ConstString &CommandInterpreter::GetStaticBroadcasterClass() {
@@ -142,6 +159,28 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool CommandInterpreter::GetEchoCommands() const {
+  const uint32_t idx = eEchoCommands;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetEchoCommands(bool b) {
+  const uint32_t idx = eEchoCommands;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
+bool CommandInterpreter::GetEchoCommentCommands() const {
+  const uint32_t idx = eEchoCommentCommands;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetEchoCommentCommands(bool b) {
+  const uint32_t idx = eEchoCommentCommands;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 void CommandInterpreter::AllowExitCodeOnQuit(bool allow) {
   m_allow_exit_code = allow;
   if (!allow)
@@ -2296,8 +2335,9 @@
   eHandleCommandFlagStopOnContinue = (1u << 0),
   eHandleCommandFlagStopOnError = (1u << 1),
   eHandleCommandFlagEchoCommand = (1u << 2),
-  eHandleCommandFlagPrintResult = (1u << 3),
-  eHandleCommandFlagStopOnCrash = (1u << 4)
+  eHandleCommandFlagEchoCommentCommand = (1u << 3),
+  eHandleCommandFlagPrintRe

[Lldb-commits] [PATCH] D52788: Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added a comment.

IMO Ready now.




Comment at: source/Interpreter/CommandInterpreter.cpp:2417
 flags |= eHandleCommandFlagPrintResult;
   }
 

sgraenitz wrote:
> Could reduce boilerplate in the code above. Just wonder whether there is 
> anything special about `GetStopOnCrash()` or if I could handle it like all 
> the others? Looks no different to `GetStopOnError()`.
Not doing this.


https://reviews.llvm.org/D52788



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


[Lldb-commits] [PATCH] D52270: TestMultilineExpr: validate evaluation for expressions spread over multiple lines

2018-10-05 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 168466.
sgraenitz added a comment.

Simplify test as proposed in review


https://reviews.llvm.org/D52270

Files:
  lit/Expr/TestMultilineExpr.test
  packages/Python/lldbsuite/test/expression_command/multiline/Makefile
  
packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
  packages/Python/lldbsuite/test/expression_command/multiline/main.c

Index: packages/Python/lldbsuite/test/expression_command/multiline/main.c
===
--- packages/Python/lldbsuite/test/expression_command/multiline/main.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include 
-
-int main(int argc, char const *argv[]) {
-printf("Hello world.\n"); // break here
-return 0;
-}
Index: packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
===
--- packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
+++ /dev/null
@@ -1,90 +0,0 @@
-"""Test multiline expressions."""
-
-from __future__ import print_function
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class MultilineExpressionsTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break on inside main.cpp.
-self.line = line_number('main.c', 'break')
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_with_run_commands(self):
-"""Test that multiline expressions work correctly"""
-self.build()
-import pexpect
-exe = self.getBuildArtifact("a.out")
-prompt = "(lldb) "
-
-# So that the child gets torn down after the test.
-self.child = pexpect.spawn(
-'%s %s %s' %
-(lldbtest_config.lldbExec, self.lldbOption, exe))
-child = self.child
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-
-# Set the breakpoint, run the inferior, when it breaks, issue print on
-# the various convenience variables.
-child.expect_exact(prompt)
-child.sendline('breakpoint set -f main.c -l %d' % self.line)
-child.expect_exact(prompt)
-child.sendline('run')
-child.expect_exact("stop reason = breakpoint 1.1")
-child.expect_exact(prompt)
-child.sendline('expr')
-child.expect_exact('1:')
-
-child.sendline('2+')
-child.expect_exact('2:')
-
-child.sendline('3')
-child.expect_exact('3:')
-
-child.sendline('')
-child.expect_exact(prompt)
-self.expect(child.before, exe=False,
-patterns=['= 5'])
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_empty_list(self):
-"""Test printing an empty list of expressions"""
-import pexpect
-prompt = "(lldb) "
-
-# So that the child gets torn down after the test
-self.child = pexpect.spawn(
-"%s %s" %
-(lldbtest_config.lldbExec, self.lldbOption))
-child = self.child
-
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-
-# We expect a prompt, then send "print" to start a list of expressions,
-# then an empty line. We expect a prompt back.
-child.expect_exact(prompt)
-child.sendline("print")
-child.expect_exact('1:')
-child.sendline("")
-child.expect_exact(prompt)
Index: packages/Python/lldbsuite/test/expression_command/multiline/Makefile
===
--- packages/Python/lldbsuite/test/expression_command/multiline/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-LEVEL = ../../make
-
-C_SOURCES := main.c
-
-include $(LEVEL)/Makefile.rules
Index: lit/Expr/TestMultilineExpr.test
===
--- /dev/null
+++ lit/Expr/TestMultilineExpr.test
@@ -0,0 +1,9 @@
+# RUN: %lldb -b -s %s | FileCheck %s
+
+# In terminal sessions LLDB hides input from subsequent lines so it's not visible in the output we check below.
+expression
+2+
+3
+
+# CHECK: (lldb) expression
+# CHECK: (int) {{.*}} = 5
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D52270: TestMultilineExpr: validate evaluation for expressions spread over multiple lines

2018-10-05 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked an inline comment as done.
sgraenitz added a comment.

Requires: https://reviews.llvm.org/D52788 (Add EchoCommentCommands to 
CommandInterpreterRunOptions in addition to the existing EchoCommands and 
expose both as interpreter settings)


https://reviews.llvm.org/D52270



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


[Lldb-commits] [PATCH] D52788: Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

One final inline comment but otherwise I think this is good to go. Thanks!




Comment at: lit/Settings/Resources/EchoCommandsAll.out:1
+# CHECK: (lldb) command source -s {{.*\n}}
+# CHECK: (lldb) command source -s {{.*\n}}

We usually call this directory `Inputs` instead of `Resources`  (at least in 
LLVM).


https://reviews.llvm.org/D52788



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


[Lldb-commits] [PATCH] D52788: Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 168478.
sgraenitz marked an inline comment as done.
sgraenitz added a comment.

Rename folder lit/Settings/Resources to lit/Settings/Inputs


https://reviews.llvm.org/D52788

Files:
  include/lldb/API/SBCommandInterpreter.h
  include/lldb/Interpreter/CommandInterpreter.h
  lit/Settings/Inputs/EchoCommandsAll.out
  lit/Settings/Inputs/EchoCommandsNoComments.out
  lit/Settings/Inputs/EchoCommandsNone.out
  lit/Settings/Inputs/EchoCommandsQuiet.out
  lit/Settings/Inputs/EchoCommandsTest.in
  lit/Settings/TestEchoCommands.test
  lit/lit-lldb-init
  source/API/SBCommandInterpreter.cpp
  source/Commands/CommandObjectCommands.cpp
  source/Interpreter/CommandInterpreter.cpp

Index: source/Interpreter/CommandInterpreter.cpp
===
--- source/Interpreter/CommandInterpreter.cpp
+++ source/Interpreter/CommandInterpreter.cpp
@@ -76,26 +76,43 @@
 
 static const char *k_white_space = " \t\v";
 
+static constexpr bool NoGlobalSetting = true;
+static constexpr uintptr_t DefaultValueTrue = true;
+static constexpr uintptr_t DefaultValueFalse = false;
+static constexpr const char *NoCStrDefault = nullptr;
+
 static constexpr PropertyDefinition g_properties[] = {
-{"expand-regex-aliases", OptionValue::eTypeBoolean, true, false, nullptr,
- {}, "If true, regular expression alias commands will show the "
-  "expanded command that will be executed. This can be used to "
-  "debug new regular expression alias commands."},
-{"prompt-on-quit", OptionValue::eTypeBoolean, true, true, nullptr, {},
+{"expand-regex-aliases", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueFalse, NoCStrDefault, {},
+ "If true, regular expression alias commands will show the "
+ "expanded command that will be executed. This can be used to "
+ "debug new regular expression alias commands."},
+{"prompt-on-quit", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
  "If true, LLDB will prompt you before quitting if there are any live "
  "processes being debugged. If false, LLDB will quit without asking in any "
  "case."},
-{"stop-command-source-on-error", OptionValue::eTypeBoolean, true, true,
- nullptr, {}, "If true, LLDB will stop running a 'command source' "
-  "script upon encountering an error."},
-{"space-repl-prompts", OptionValue::eTypeBoolean, true, false, nullptr, {},
- "If true, blank lines will be printed between between REPL submissions."}};
+{"stop-command-source-on-error", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, LLDB will stop running a 'command source' "
+ "script upon encountering an error."},
+{"space-repl-prompts", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueFalse, NoCStrDefault, {},
+ "If true, blank lines will be printed between between REPL submissions."},
+{"echo-commands", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, commands will be echoed before they are evaluated."},
+{"echo-comment-commands", OptionValue::eTypeBoolean, NoGlobalSetting,
+ DefaultValueTrue, NoCStrDefault, {},
+ "If true, commands will be echoed even if they are pure comment lines."}};
 
 enum {
   ePropertyExpandRegexAliases = 0,
   ePropertyPromptOnQuit = 1,
   ePropertyStopCmdSourceOnError = 2,
-  eSpaceReplPrompts = 3
+  eSpaceReplPrompts = 3,
+  eEchoCommands = 4,
+  eEchoCommentCommands = 5
 };
 
 ConstString &CommandInterpreter::GetStaticBroadcasterClass() {
@@ -142,6 +159,28 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool CommandInterpreter::GetEchoCommands() const {
+  const uint32_t idx = eEchoCommands;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetEchoCommands(bool b) {
+  const uint32_t idx = eEchoCommands;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
+bool CommandInterpreter::GetEchoCommentCommands() const {
+  const uint32_t idx = eEchoCommentCommands;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
+void CommandInterpreter::SetEchoCommentCommands(bool b) {
+  const uint32_t idx = eEchoCommentCommands;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 void CommandInterpreter::AllowExitCodeOnQuit(bool allow) {
   m_allow_exit_code = allow;
   if (!allow)
@@ -2296,8 +2335,9 @@
   eHandleCommandFlagStopOnContinue = (1u << 0),
   eHandleCommandFlagStopOnError = (1u << 1),
   eHandleCommandFlagEchoCommand = (1u << 2),
-  eHandleCommandFlagPrintResult = (1u << 3),
-  eHandleCommandFlagStopOnCrash = (1u << 4)
+  eHandleCommandFlagEchoCommentCommand = (1u << 3),
+  eHandleCommandFlagPri

[Lldb-commits] [lldb] r343859 - Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Oct  5 09:49:47 2018
New Revision: 343859

URL: http://llvm.org/viewvc/llvm-project?rev=343859&view=rev
Log:
Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the 
existing EchoCommands and expose both as interpreter settings.

Summary:
Add settings to control command echoing:
```
(lldb) settings set interpreter.echo-commands true
(lldb) settings set interpreter.echo-comment-commands true
```

Both settings default to true, which keeps LLDB's existing behavior in 
non-interactive mode (echo all command inputs to the output).

So far the only way to change this behavior was the `--source-quietly` flag, 
which disables all output including evaluation results.
Now `echo-commands` allows to turn off echoing for commands, while evaluation 
results are still printed. No effect if `--source-quietly` was present.
`echo-comment-commands` allows to turn off echoing for commands in case they 
are pure comment lines. No effect if `echo-commands` is false.

Note that the behavior does not change immediately! The new settings take 
effect only with the next command source.

LLDB lit test are the main motivation for this feature. So far incoming 
`#CHECK` line have always been echoed to the output and so they could never 
fail. Now we can disable it in lit-lldb-init.
Todos: Finish test for this feature. Add to lit-lldb-init. Check for failing 
lit tests.

Reviewers: aprantl, jasonmolenda, JDevlieghere

Subscribers: friss, lldb-commits

Differential Revision: https://reviews.llvm.org/D52788

Added:
lldb/trunk/lit/Settings/Inputs/
lldb/trunk/lit/Settings/Inputs/EchoCommandsAll.out
lldb/trunk/lit/Settings/Inputs/EchoCommandsNoComments.out
lldb/trunk/lit/Settings/Inputs/EchoCommandsNone.out
lldb/trunk/lit/Settings/Inputs/EchoCommandsQuiet.out
lldb/trunk/lit/Settings/Inputs/EchoCommandsTest.in
lldb/trunk/lit/Settings/TestEchoCommands.test
Modified:
lldb/trunk/include/lldb/API/SBCommandInterpreter.h
lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
lldb/trunk/lit/lit-lldb-init
lldb/trunk/source/API/SBCommandInterpreter.cpp
lldb/trunk/source/Commands/CommandObjectCommands.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=343859&r1=343858&r2=343859&view=diff
==
--- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Fri Oct  5 09:49:47 2018
@@ -45,6 +45,10 @@ public:
 
   void SetEchoCommands(bool);
 
+  bool GetEchoCommentCommands() const;
+
+  void SetEchoCommentCommands(bool echo);
+
   bool GetPrintResults() const;
 
   void SetPrintResults(bool);

Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=343859&r1=343858&r2=343859&view=diff
==
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Fri Oct  5 
09:49:47 2018
@@ -35,55 +35,60 @@ namespace lldb_private {
 class CommandInterpreterRunOptions {
 public:
   //--
-  /// Construct a CommandInterpreterRunOptions object.
-  /// This class is used to control all the instances where we run multiple
-  /// commands, e.g.
+  /// Construct a CommandInterpreterRunOptions object. This class is used to
+  /// control all the instances where we run multiple commands, e.g.
   /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter.
+  ///
   /// The meanings of the options in this object are:
   ///
   /// @param[in] stop_on_continue
-  ///If \b true execution will end on the first command that causes the
-  ///process in the
-  ///execution context to continue.  If \false, we won't check the 
execution
-  ///status.
+  ///If \b true, execution will end on the first command that causes the
+  ///process in the execution context to continue. If \b false, we won't
+  ///check the execution status.
   /// @param[in] stop_on_error
-  ///If \b true execution will end on the first command that causes an
+  ///If \b true, execution will end on the first command that causes an
   ///error.
   /// @param[in] stop_on_crash
-  ///If \b true when a command causes the target to run, and the end of the
-  ///run is a
-  ///signal or exception, stop executing the commands.
+  ///If \b true, when a command causes the target to run, and the end of 
the
+  ///run is a signal or exception, stop executing the commands.
   /// @param[in] echo_commands
-  ///If \b true echo the command befor

[Lldb-commits] [lldb] r343860 - TestMultilineExpr: validate evaluation for expressions that span multiple lines

2018-10-05 Thread Stefan Granitz via lldb-commits
Author: stefan.graenitz
Date: Fri Oct  5 09:49:53 2018
New Revision: 343860

URL: http://llvm.org/viewvc/llvm-project?rev=343860&view=rev
Log:
TestMultilineExpr: validate evaluation for expressions that span multiple lines

Summary:
When LLDB successfully parses a command (like "expression" in this case) and 
determines incomplete input, the user can continue typing on multiple lines (in 
this case "2+3"). This should provide the correct result.
Note that LLDB reverts input from the additional lines, so they are not present 
in the output.

Reviewers: vsk, davide, aprantl

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D52270

Added:
lldb/trunk/lit/Expr/TestMultilineExpr.test
Removed:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile

lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c

Added: lldb/trunk/lit/Expr/TestMultilineExpr.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Expr/TestMultilineExpr.test?rev=343860&view=auto
==
--- lldb/trunk/lit/Expr/TestMultilineExpr.test (added)
+++ lldb/trunk/lit/Expr/TestMultilineExpr.test Fri Oct  5 09:49:53 2018
@@ -0,0 +1,9 @@
+# RUN: %lldb -b -s %s | FileCheck %s
+
+# In terminal sessions LLDB hides input from subsequent lines so it's not 
visible in the output we check below.
+expression
+2+
+3
+
+# CHECK: (lldb) expression
+# CHECK: (int) {{.*}} = 5

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile?rev=343859&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile 
(removed)
@@ -1,5 +0,0 @@
-LEVEL = ../../make
-
-C_SOURCES := main.c
-
-include $(LEVEL)/Makefile.rules

Removed: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py?rev=343859&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
 (removed)
@@ -1,90 +0,0 @@
-"""Test multiline expressions."""
-
-from __future__ import print_function
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class MultilineExpressionsTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break on inside main.cpp.
-self.line = line_number('main.c', 'break')
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_with_run_commands(self):
-"""Test that multiline expressions work correctly"""
-self.build()
-import pexpect
-exe = self.getBuildArtifact("a.out")
-prompt = "(lldb) "
-
-# So that the child gets torn down after the test.
-self.child = pexpect.spawn(
-'%s %s %s' %
-(lldbtest_config.lldbExec, self.lldbOption, exe))
-child = self.child
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-
-# Set the breakpoint, run the inferior, when it breaks, issue print on
-# the various convenience variables.
-child.expect_exact(prompt)
-child.sendline('breakpoint set -f main.c -l %d' % self.line)
-child.expect_exact(prompt)
-child.sendline('run')
-child.expect_exact("stop reason = breakpoint 1.1")
-child.expect_exact(prompt)
-child.sendline('expr')
-child.expect_exact('1:')
-
-child.sendline('2+')
-child.expect_exact('2:')
-
-child.sendline('3')
-child.expect_exact('3:')
-
-child.sendline('')
-child.expect_exact(prompt)
-self.expect(child.before, exe=False,
-patterns=['= 5'])
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_emp

[Lldb-commits] [PATCH] D52270: TestMultilineExpr: validate evaluation for expressions spread over multiple lines

2018-10-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343860: TestMultilineExpr: validate evaluation for 
expressions that span multiple lines (authored by stefan.graenitz, committed by 
).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52270

Files:
  lldb/trunk/lit/Expr/TestMultilineExpr.test
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
  lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c

Index: lldb/trunk/lit/Expr/TestMultilineExpr.test
===
--- lldb/trunk/lit/Expr/TestMultilineExpr.test
+++ lldb/trunk/lit/Expr/TestMultilineExpr.test
@@ -0,0 +1,9 @@
+# RUN: %lldb -b -s %s | FileCheck %s
+
+# In terminal sessions LLDB hides input from subsequent lines so it's not visible in the output we check below.
+expression
+2+
+3
+
+# CHECK: (lldb) expression
+# CHECK: (int) {{.*}} = 5
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/main.c
@@ -1,6 +0,0 @@
-#include 
-
-int main(int argc, char const *argv[]) {
-printf("Hello world.\n"); // break here
-return 0;
-}
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/Makefile
@@ -1,5 +0,0 @@
-LEVEL = ../../make
-
-C_SOURCES := main.c
-
-include $(LEVEL)/Makefile.rules
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/multiline/TestMultilineExpressions.py
@@ -1,90 +0,0 @@
-"""Test multiline expressions."""
-
-from __future__ import print_function
-
-import os
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class MultilineExpressionsTestCase(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-# Find the line number to break on inside main.cpp.
-self.line = line_number('main.c', 'break')
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_with_run_commands(self):
-"""Test that multiline expressions work correctly"""
-self.build()
-import pexpect
-exe = self.getBuildArtifact("a.out")
-prompt = "(lldb) "
-
-# So that the child gets torn down after the test.
-self.child = pexpect.spawn(
-'%s %s %s' %
-(lldbtest_config.lldbExec, self.lldbOption, exe))
-child = self.child
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-child.logfile_read = sys.stdout
-
-# Set the breakpoint, run the inferior, when it breaks, issue print on
-# the various convenience variables.
-child.expect_exact(prompt)
-child.sendline('breakpoint set -f main.c -l %d' % self.line)
-child.expect_exact(prompt)
-child.sendline('run')
-child.expect_exact("stop reason = breakpoint 1.1")
-child.expect_exact(prompt)
-child.sendline('expr')
-child.expect_exact('1:')
-
-child.sendline('2+')
-child.expect_exact('2:')
-
-child.sendline('3')
-child.expect_exact('3:')
-
-child.sendline('')
-child.expect_exact(prompt)
-self.expect(child.before, exe=False,
-patterns=['= 5'])
-
-@skipIfRemote
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
-def test_empty_list(self):
-"""Test printing an empty list of expressions"""
-import pexpect
-prompt = "(lldb) "
-
-# So that the child gets torn down after the test
-self.child = pexpect.spawn(
-"%s %s" %
-(lldbtest_config.lldbExec, self.lldbOption))
-child = self.child
-
-# Turn on logging for what the child sends back.
-if self.TraceOn():
-  

[Lldb-commits] [PATCH] D52788: Add EchoCommentCommands to CommandInterpreterRunOptions in addition to the existing EchoCommands and expose both as interpreter settings.

2018-10-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343859: Add EchoCommentCommands to 
CommandInterpreterRunOptions in addition to the… (authored by stefan.graenitz, 
committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52788

Files:
  lldb/trunk/include/lldb/API/SBCommandInterpreter.h
  lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
  lldb/trunk/lit/Settings/Inputs/EchoCommandsAll.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsNoComments.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsNone.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsQuiet.out
  lldb/trunk/lit/Settings/Inputs/EchoCommandsTest.in
  lldb/trunk/lit/Settings/TestEchoCommands.test
  lldb/trunk/lit/lit-lldb-init
  lldb/trunk/source/API/SBCommandInterpreter.cpp
  lldb/trunk/source/Commands/CommandObjectCommands.cpp
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Index: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
===
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
@@ -35,55 +35,60 @@
 class CommandInterpreterRunOptions {
 public:
   //--
-  /// Construct a CommandInterpreterRunOptions object.
-  /// This class is used to control all the instances where we run multiple
-  /// commands, e.g.
+  /// Construct a CommandInterpreterRunOptions object. This class is used to
+  /// control all the instances where we run multiple commands, e.g.
   /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter.
+  ///
   /// The meanings of the options in this object are:
   ///
   /// @param[in] stop_on_continue
-  ///If \b true execution will end on the first command that causes the
-  ///process in the
-  ///execution context to continue.  If \false, we won't check the execution
-  ///status.
+  ///If \b true, execution will end on the first command that causes the
+  ///process in the execution context to continue. If \b false, we won't
+  ///check the execution status.
   /// @param[in] stop_on_error
-  ///If \b true execution will end on the first command that causes an
+  ///If \b true, execution will end on the first command that causes an
   ///error.
   /// @param[in] stop_on_crash
-  ///If \b true when a command causes the target to run, and the end of the
-  ///run is a
-  ///signal or exception, stop executing the commands.
+  ///If \b true, when a command causes the target to run, and the end of the
+  ///run is a signal or exception, stop executing the commands.
   /// @param[in] echo_commands
-  ///If \b true echo the command before executing it.  If \false, execute
+  ///If \b true, echo the command before executing it. If \b false, execute
   ///silently.
+  /// @param[in] echo_comments
+  ///If \b true, echo command even if it is a pure comment line. If
+  ///\b false, print no ouput in this case. This setting has an effect only
+  ///if \param echo_commands is \b true.
   /// @param[in] print_results
-  ///If \b true print the results of the command after executing it.  If
-  ///\false, execute silently.
+  ///If \b true print the results of the command after executing it. If
+  ///\b false, execute silently.
   /// @param[in] add_to_history
-  ///If \b true add the commands to the command history.  If \false, don't
+  ///If \b true add the commands to the command history. If \b false, don't
   ///add them.
   //--
   CommandInterpreterRunOptions(LazyBool stop_on_continue,
LazyBool stop_on_error, LazyBool stop_on_crash,
-   LazyBool echo_commands, LazyBool print_results,
-   LazyBool add_to_history)
+   LazyBool echo_commands, LazyBool echo_comments,
+   LazyBool print_results, LazyBool add_to_history)
   : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error),
 m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands),
-m_print_results(print_results), m_add_to_history(add_to_history) {}
+m_echo_comment_commands(echo_comments), m_print_results(print_results),
+m_add_to_history(add_to_history) {}
 
   CommandInterpreterRunOptions()
   : m_stop_on_continue(eLazyBoolCalculate),
 m_stop_on_error(eLazyBoolCalculate),
 m_stop_on_crash(eLazyBoolCalculate),
 m_echo_commands(eLazyBoolCalculate),
+m_echo_comment_commands(eLazyBoolCalculate),
 m_print_results(eLazyBoolCalculate),
 m_add_to_history(eLazyBoolCalculate) {}
 
   void SetSilent(bool silent) {
 LazyBool value = silent ? eLazyBoolNo

[Lldb-commits] [PATCH] D52941: NativeProcessProtocol: Simplify breakpoint setting code

2018-10-05 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: krytarowski, zturner, clayborg.
Herald added a subscriber: mgorny.

A fairly simple operation as setting a breakpoint (writing a breakpoint
opcode) at a given address was going through three classes:
NativeProcessProtocol which called NativeBreakpointList, which then
called SoftwareBrekpoint, only to end up again in NativeProcessProtocol
to do the actual writing itself. This is unnecessarily complex and can
be simplified by moving all of the logic into NativeProcessProtocol
class itself, removing a lot of boilerplate.

One of the reeasons for this complexity was that (it seems)
NativeBreakpointList class was meant to hold both software and hardware
breakpoints. However, that never materialized, and hardware breakpoints
are stored in a separate map holding only hardware breakpoints.
Essentially, this patch makes software breakpoints follow that approach
by replacing the heavy SoftwareBraekpoint with a light struct of the
same name, which holds only the data necessary to describe one
breakpoint. The rest of the logic is in the main class. As, at the
lldb-server level, handling software and hardware breakpoints is very
different, this seems like a reasonable state of things.


https://reviews.llvm.org/D52941

Files:
  include/lldb/Host/common/NativeBreakpoint.h
  include/lldb/Host/common/NativeBreakpointList.h
  include/lldb/Host/common/NativeProcessProtocol.h
  include/lldb/Host/common/SoftwareBreakpoint.h
  include/lldb/lldb-private-forward.h
  lldb.xcodeproj/project.pbxproj
  source/Host/CMakeLists.txt
  source/Host/common/NativeBreakpoint.cpp
  source/Host/common/NativeBreakpointList.cpp
  source/Host/common/NativeProcessProtocol.cpp
  source/Host/common/NativeThreadProtocol.cpp
  source/Host/common/SoftwareBreakpoint.cpp
  source/Plugins/Process/Linux/NativeProcessLinux.cpp
  source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp

Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
===
--- source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -16,7 +16,6 @@
 // Other libraries and framework includes
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
 #include "lldb/Host/HostProcess.h"
-#include "lldb/Host/common/NativeBreakpoint.h"
 #include "lldb/Host/common/NativeRegisterContext.h"
 #include "lldb/Host/posix/ProcessLauncherPosixFork.h"
 #include "lldb/Target/Process.h"
Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
===
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -29,7 +29,6 @@
 #include "lldb/Host/HostProcess.h"
 #include "lldb/Host/PseudoTerminal.h"
 #include "lldb/Host/ThreadLauncher.h"
-#include "lldb/Host/common/NativeBreakpoint.h"
 #include "lldb/Host/common/NativeRegisterContext.h"
 #include "lldb/Host/linux/Ptrace.h"
 #include "lldb/Host/linux/Uio.h"
Index: source/Host/common/SoftwareBreakpoint.cpp
===
--- source/Host/common/SoftwareBreakpoint.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-//===-- SoftwareBreakpoint.cpp --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "lldb/Host/common/SoftwareBreakpoint.h"
-
-#include "lldb/Host/Debug.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Status.h"
-
-#include "lldb/Host/common/NativeProcessProtocol.h"
-
-using namespace lldb_private;
-
-// --- static
-// members ---
-
-Status SoftwareBreakpoint::CreateSoftwareBreakpoint(
-NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint,
-NativeBreakpointSP &breakpoint_sp) {
-  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
-  if (log)
-log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
-
-  // Validate the address.
-  if (addr == LLDB_INVALID_ADDRESS)
-return Status("SoftwareBreakpoint::%s invalid load address specified.",
-  __FUNCTION__);
-
-  // Ask the NativeProcessProtocol subclass to fill in the correct software
-  // breakpoint trap for the breakpoint site.
-  auto expected_opcode = process.GetSoftwareBreakpointTrapOpcode(size_hint);
-  if (!expected_opcode)
-return Status(expected_opcode.takeError());
-
-  assert(expected_opcode->size() > 0);
-  assert(expected_opcode->size() <= MAX_TRAP_OPCODE_SIZE);
-
-  // Enable the breakpoint.
-  uint8_t saved_opcode_bytes[MAX_TRAP_OPCODE_SIZE];
-  Status error =
-  EnableSoftwareB

[Lldb-commits] [lldb] r343899 - Relax a data formatter test

2018-10-05 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Fri Oct  5 16:14:13 2018
New Revision: 343899

URL: http://llvm.org/viewvc/llvm-project?rev=343899&view=rev
Log:
Relax a data formatter test

Before inspecting the contents of a list, make sure that we've stepped
past the push_back() that inserts the element we're interested in.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py?rev=343899&r1=343898&r2=343899&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py
 Fri Oct  5 16:14:13 2018
@@ -190,6 +190,7 @@ class LibcxxListDataFormatterTestCase(Te
 
 self.runCmd("n") # This gets us past the printf
 self.runCmd("n")
+self.runCmd("n")
 
 # check access-by-index
 self.expect("frame variable text_list[0]",


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


[Lldb-commits] [lldb] r343900 - Add support for artificial tail call frames

2018-10-05 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Fri Oct  5 16:23:15 2018
New Revision: 343900

URL: http://llvm.org/viewvc/llvm-project?rev=343900&view=rev
Log:
Add support for artificial tail call frames

This patch teaches lldb to detect when there are missing frames in a
backtrace due to a sequence of tail calls, and to fill in the backtrace
with artificial tail call frames when this happens. This is only done
when the execution history can be determined from the call graph and
from the return PC addresses of calls on the stack. Ambiguous sequences
of tail calls (e.g anything involving tail calls and recursion) are
detected and ignored.

Depends on D49887.

Differential Revision: https://reviews.llvm.org/D50478

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/TestInliningAndTailCalls.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/TestArtificialFrameStepOutMessage.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return

[Lldb-commits] [PATCH] D50478: Add support for artificial tail call frames

2018-10-05 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB343900: Add support for artificial tail call frames 
(authored by vedantk, committed by ).
Herald added subscribers: teemperor, abidh.

Changed prior to commit:
  https://reviews.llvm.org/D50478?vs=168155&id=168552#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50478

Files:
  include/lldb/API/SBFrame.h
  include/lldb/Core/FormatEntity.h
  include/lldb/Symbol/Block.h
  include/lldb/Symbol/Function.h
  include/lldb/Symbol/SymbolFile.h
  include/lldb/Target/StackFrame.h
  include/lldb/Target/StackFrameList.h
  include/lldb/Target/ThreadPlanStepOut.h
  packages/Python/lldbsuite/test/decorators.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/TestInliningAndTailCalls.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/TestTailCallFrameSBAPI.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/sbapi_support/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/TestArtificialFrameStepOutMessage.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/TestSteppingOutWithArtificialFrames.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_or_return/main.cpp
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/Makefile
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py
  
packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/main.cpp
  scripts/interface/SBFrame.i
  source/API/SBFrame.cpp
  source/Core/Debugger.cpp
  source/Core/FormatEntity.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  source/Symbol/Block.cpp
  source/Symbol/Function.cpp
  source/Target/StackFrame.cpp
  source/Target/StackFrameList.cpp
  source/Target/ThreadPlanStepOut.cpp

Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3742,6 +3742,60 @@
   return vars_added;
 }
 
+/// Collect call graph edges present in a function DIE.
+static std::vector
+CollectCallEdges(DWARFDIE function_die) {
+  // Check if the function has a supported call site-related attribute.
+  // TODO: In the future it may be worthwhile to support call_all_source_call