[Lldb-commits] [PATCH] D48802: [lldb-mi] Re-implement symbol-list-lines command.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 153847.
apolyakov added a comment.

Removed `sb_target.IsDummy()` since `IsDummy` won't be a member of SBTarget 
class. Now `sb_target == rSessionInfo.GetDebugger().GetDummyTarget()` is used 
for this goal.


https://reviews.llvm.org/D48802

Files:
  lit/tools/lldb-mi/symbol/inputs/list-lines-helper.c
  lit/tools/lldb-mi/symbol/inputs/list-lines-helper.h
  lit/tools/lldb-mi/symbol/inputs/main.c
  lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.c
  lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.h
  lit/tools/lldb-mi/symbol/lit.local.cfg
  lit/tools/lldb-mi/symbol/symbol-list-lines.test
  packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile
  packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp
  
packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp
  
packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h
  
packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp
  tools/lldb-mi/MICmdCmdSymbol.cpp
  tools/lldb-mi/MICmdCmdSymbol.h

Index: tools/lldb-mi/MICmdCmdSymbol.h
===
--- tools/lldb-mi/MICmdCmdSymbol.h
+++ tools/lldb-mi/MICmdCmdSymbol.h
@@ -24,10 +24,10 @@
 #pragma once
 
 // Third party headers:
-#include "lldb/API/SBCommandReturnObject.h"
 
 // In-house headers:
 #include "MICmdBase.h"
+#include "MICmnMIValueList.h"
 
 //++
 //
@@ -55,6 +55,6 @@
 
   // Attributes:
 private:
-  lldb::SBCommandReturnObject m_lldbResult;
+  CMICmnMIValueList m_resultList;
   const CMIUtilString m_constStrArgNameFile;
 };
Index: tools/lldb-mi/MICmdCmdSymbol.cpp
===
--- tools/lldb-mi/MICmdCmdSymbol.cpp
+++ tools/lldb-mi/MICmdCmdSymbol.cpp
@@ -10,18 +10,28 @@
 // Overview:CMICmdCmdSymbolListLines implementation.
 
 // Third Party Headers:
-#include "lldb/API/SBCommandInterpreter.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Regex.h"
+#include "llvm/ADT/Twine.h"
 
 // In-house headers:
 #include "MICmdArgValFile.h"
 #include "MICmdCmdSymbol.h"
 #include "MICmnLLDBDebugSessionInfo.h"
 #include "MICmnMIResultRecord.h"
-#include "MICmnMIValueList.h"
 #include "MICmnMIValueTuple.h"
+#include "MICmnMIValueResult.h"
+
+namespace {
+const CMICmnMIValueTuple
+CreateMITuplePCLine(const uint32_t addr, const uint32_t line_number) {
+  const CMICmnMIValueConst miValueConstAddr("0x" + llvm::Twine::utohexstr(addr).str());
+  const CMICmnMIValueConst miValueConstLine(llvm::Twine(line_number).str());
+  const CMICmnMIValueResult miValueResultAddr("pc", miValueConstAddr);
+  const CMICmnMIValueResult miValueResultLine("line", miValueConstLine);
+  CMICmnMIValueTuple miValueTuple(miValueResultAddr);
+  miValueTuple.Add(miValueResultLine);
+  return miValueTuple;
+}
+} // namespace
 
 //++
 //
@@ -32,7 +42,7 @@
 // Throws:  None.
 //--
 CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines()
-: m_constStrArgNameFile("file") {
+: m_resultList(false), m_constStrArgNameFile("file") {
   // Command factory matches this name with that received from the stdin stream
   m_strMiCmd = "symbol-list-lines";
 
@@ -84,93 +94,51 @@
 bool CMICmdCmdSymbolListLines::Execute() {
   CMICMDBASE_GETOPTION(pArgFile, File, m_constStrArgNameFile);
 
-  const CMIUtilString (pArgFile->GetValue());
-  const CMIUtilString strCmd(CMIUtilString::Format(
-  "source info --file \"%s\"", strFilePath.AddSlashes().c_str()));
-
-  CMICmnLLDBDebugSessionInfo (
-  CMICmnLLDBDebugSessionInfo::Instance());
-  const lldb::ReturnStatus rtn =
-  rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(
-  strCmd.c_str(), m_lldbResult);
-  MIunused(rtn);
-
-  return MIstatus::success;
-}
-
-//++
-//
-// Details: Helper function for parsing the header returned from lldb for the
-// command:
-//  target modules dump line-table 
-//  where the header is of the format:
-//  Line table for /path/to/file in `/path/to/module
-// Args:input - (R) Input string to parse.
-//  file  - (W) String representing the file.
-// Return:  bool - True = input was parsed successfully, false = input could not
-// be parsed.
-// Throws:  None.
-//--
-static bool ParseLLDBLineAddressHeader(const char *input, CMIUtilString ) {
-  // Match LineEntry using regex.
-  static llvm::Regex g_lineentry_header_regex(llvm::StringRef(
-  "^ *Lines found for file (.+) in compilation unit (.+) in `(.+)$"));
-  //   ^1=file  ^2=cu
-  //   ^3=module
-
-  llvm::SmallVector match;
-
-  

[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 153846.
apolyakov added a comment.

Updated passing an argument to `find_compile_units` function.


https://reviews.llvm.org/D48801

Files:
  include/lldb/API/SBModule.h
  include/lldb/API/SBTarget.h
  
packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
  packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
  scripts/interface/SBModule.i
  scripts/interface/SBTarget.i
  source/API/SBModule.cpp
  source/API/SBTarget.cpp

Index: source/API/SBTarget.cpp
===
--- source/API/SBTarget.cpp
+++ source/API/SBTarget.cpp
@@ -1548,6 +1548,18 @@
   return sb_module;
 }
 
+SBSymbolContextList
+SBTarget::FindCompileUnits(const SBFileSpec _file_spec) {
+  SBSymbolContextList sb_sc_list;
+  const TargetSP target_sp(GetSP());
+  if (target_sp && sb_file_spec.IsValid()) {
+const bool append = true;
+target_sp->GetImages().FindCompileUnits(*sb_file_spec,
+append, *sb_sc_list);
+  }
+  return sb_sc_list;
+}
+
 lldb::ByteOrder SBTarget::GetByteOrder() {
   TargetSP target_sp(GetSP());
   if (target_sp)
Index: source/API/SBModule.cpp
===
--- source/API/SBModule.cpp
+++ source/API/SBModule.cpp
@@ -253,6 +253,17 @@
   return sb_cu;
 }
 
+SBSymbolContextList
+SBModule::FindCompileUnits(const SBFileSpec _file_spec) {
+  SBSymbolContextList sb_sc_list;
+  const ModuleSP module_sp(GetSP());
+  if (sb_file_spec.IsValid() && module_sp) {
+const bool append = true;
+module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list);
+  }
+  return sb_sc_list;
+}
+
 static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP _sp) {
   if (module_sp) {
 SymbolVendor *symbols = module_sp->GetSymbolVendor();
Index: scripts/interface/SBTarget.i
===
--- scripts/interface/SBTarget.i
+++ scripts/interface/SBTarget.i
@@ -410,6 +410,23 @@
 lldb::SBModule
 FindModule (const lldb::SBFileSpec _spec);
 
+%feature("docstring", "
+//--
+/// Find compile units related to *this target and passed source
+/// file.
+///
+/// @param[in] sb_file_spec
+/// A lldb::SBFileSpec object that contains source file
+/// specification.
+///
+/// @return
+/// A lldb::SBSymbolContextList that gets filled in with all of
+/// the symbol contexts for all the matches.
+//--
+") FindCompileUnits;
+lldb::SBSymbolContextList
+FindCompileUnits (const lldb::SBFileSpec _file_spec);
+
 lldb::ByteOrder
 GetByteOrder ();
 
Index: scripts/interface/SBModule.i
===
--- scripts/interface/SBModule.i
+++ scripts/interface/SBModule.i
@@ -179,6 +179,23 @@
 lldb::SBCompileUnit
 GetCompileUnitAtIndex (uint32_t);
 
+%feature("docstring", "
+//--
+/// Find compile units related to *this module and passed source
+/// file.
+///
+/// @param[in] sb_file_spec
+/// A lldb::SBFileSpec object that contains source file
+/// specification.
+///
+/// @return
+/// A lldb::SBSymbolContextList that gets filled in with all of
+/// the symbol contexts for all the matches.
+//--
+") FindCompileUnits;
+lldb::SBSymbolContextList
+FindCompileUnits (const lldb::SBFileSpec _file_spec);
+
 size_t
 GetNumSymbols ();
 
Index: packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
===
--- packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
+++ packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
@@ -46,6 +46,14 @@
 self.find_global_variables('b.out')
 
 @add_test_categories(['pyapi'])
+def test_find_compile_units(self):
+"""Exercise SBTarget.FindCompileUnits() API."""
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+self.find_compile_units(self.getBuildArtifact('b.out'))
+
+@add_test_categories(['pyapi'])
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
 def test_find_functions(self):
 """Exercise SBTarget.FindFunctions() API."""
@@ -219,6 +227,20 @@
 value_list.GetValueAtIndex(0).GetValue() == "'X'")
 break
 
+def find_compile_units(self, exe):
+"""Exercise SBTarget.FindCompileUnits() API."""
+source_name = "main.c"
+
+# Create a target by the debugger.
+target = 

Re: [Lldb-commits] [lldb] r336158 - Re-sort the lldb.xcodeproj project file and commit the script

2018-07-02 Thread Davide Italiano via lldb-commits
Thank you Jason!
On Mon, Jul 2, 2018 at 5:48 PM Jason Molenda via lldb-commits
 wrote:
>
> Author: jmolenda
> Date: Mon Jul  2 17:43:57 2018
> New Revision: 336158
>
> URL: http://llvm.org/viewvc/llvm-project?rev=336158=rev
> Log:
> Re-sort the lldb.xcodeproj project file and commit the script
> that I used to sort it to scripts/sort-pbxproj.rb.  It turns
> out that Xcode will perturb the order of the file lists
> every time we add a file, following its own logic, and unfortunately
> we'll still end up with lots of merge conflicts when that tries
> to merge to the github swift repositories.  We talked this over
> and we're going to keep it in a canonical state by running this
> script over it when Xcode tries to reorder it.
>
> Added:
> lldb/trunk/scripts/sort-pbxproj.rb   (with props)
> Modified:
> lldb/trunk/lldb.xcodeproj/project.pbxproj
>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov abandoned this revision.
apolyakov added a comment.

Abandoned since suggested functionality is optional.


https://reviews.llvm.org/D48775



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


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-07-02 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Okay then let's not do this for now. It's fine to revisit this later if there 
turns out to be a good use-case for it, but every SBAPI call we introduce has 
to be supported indefinitely and can therefore be quite expensive to maintain.


https://reviews.llvm.org/D48775



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


[Lldb-commits] [lldb] r336158 - Re-sort the lldb.xcodeproj project file and commit the script

2018-07-02 Thread Jason Molenda via lldb-commits
Added: lldb/trunk/scripts/sort-pbxproj.rb
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/sort-pbxproj.rb?rev=336158=auto
==
--- lldb/trunk/scripts/sort-pbxproj.rb (added)
+++ lldb/trunk/scripts/sort-pbxproj.rb Mon Jul  2 17:43:57 2018
@@ -0,0 +1,241 @@
+#! /usr/bin/ruby
+#
+
+# A script to impose order on the Xcode project file, to make merging
+# across branches were many additional files are present, easier.
+
+
+
+
+## Sort the BuildFile and FileReference sections of an Xcode project file,
+## putting Apple/github-local files at the front to avoid merge conflicts.
+#
+## Run this in a directory with a project.pbxproj file.  The sorted version
+## is printed on standard output.
+#
+
+
+# Files with these words in the names will be sorted into a separate section;
+# they are only present in some repositories and so having them intermixed 
+# can lead to merge failures.
+segregated_filenames = ["Swift", "repl", "RPC"]
+
+if !File.exists?("project.pbxproj")
+STDERR.puts "ERROR: project.pbxproj does not exist."
+exit(1)
+end
+
+def read_pbxproj(fn)
+beginning  = Array.new   # All lines before "PBXBuildFile section"
+files  = Array.new   # PBXBuildFile section lines -- sort these
+middle = Array.new   # All lines between PBXBuildFile and 
PBXFileReference sections
+refs   = Array.new   # PBXFileReference section lines -- sort these
+ending = Array.new   # All lines after PBXFileReference section
+
+all_lines = File.readlines fn
+
+state = 1 # "begin"
+all_lines.each do |l|
+l.chomp
+if state == 1 && l =~ /Begin PBXBuildFile section/
+beginning.push(l)
+state = 2
+next
+end
+if state == 2 && l =~ /End PBXBuildFile section/
+middle.push(l)
+state = 3
+next
+end
+if state == 3 && l =~ /Begin PBXFileReference section/
+middle.push(l)
+state = 4
+next
+end
+if state == 4 && l =~ /End PBXFileReference section/
+ending.push(l)
+state = 5
+next
+end
+
+if state == 1
+beginning.push(l)
+elsif state == 2
+files.push(l)
+elsif state == 3
+middle.push(l)
+elsif state == 4
+refs.push(l)
+else
+ending.push(l)
+end
+end
+
+return beginning, files, middle, refs, ending
+end
+
+beginning, files, middle, refs, ending = read_pbxproj("project.pbxproj")
+
+
+### If we're given a "canonical" project.pbxproj file, get the uuid and 
fileref ids for
+### every source file in this project.pbxproj and the canonical one, and fix 
any of
+### the identifiers that don't match in the project file we're updating.
+### this comes up when people add the file independently on different branches 
and it
+### gets different identifiers.
+
+if ARGV.size() > 0
+canonical_pbxproj = nil
+if ARGV.size == 2 && ARGV[0] == "--canonical"
+canonical_pbxproj = ARGV[1]
+elsif ARGV.size == 1 && ARGV[0] =~ /--canonical=(.+)/
+canonical_pbxproj = $1
+end
+
+if File.exists?(canonical_pbxproj)
+ignore1, canon_files, ignore2, ignore3, ignore4 = 
read_pbxproj(canonical_pbxproj)
+canon_files_by_filename = Hash.new { |k, v| k[v] = Array.new }
+
+canon_files.each do |l|
+# 2669421A1A6DC2AC0063BE93 /* MICmdCmdTarget.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 266941941A6DC2AC0063BE93 /* MICmdCmdTarget.cpp 
*/; };
+
+if l =~ /^\s+([A-F0-9]{24})\s+\/\*\s+(.*?)\sin.*?\*\/.*?fileRef = 
([A-F0-9]{24})\s.*$/
+uuid = $1
+filename = $2
+fileref = $3
+canon_files_by_filename[filename].push({ :uuid => uuid, 
:fileref => fileref })
+end
+end
+
+this_project_files = Hash.new { |k, v| k[v] = Array.new }
+
+files.each do |l|
+# 2669421A1A6DC2AC0063BE93 /* MICmdCmdTarget.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 266941941A6DC2AC0063BE93 /* MICmdCmdTarget.cpp 
*/; };
+
+if l =~ /^\s+([A-F0-9]{24})\s+\/\*\s+(.*?)\sin.*?\*\/.*?fileRef = 
([A-F0-9]{24})\s.*$/
+uuid = $1
+filename = $2
+fileref = $3
+this_project_files[filename].push({ :uuid => uuid, :fileref => 
fileref })
+end
+end
+
+this_project_files.keys.each do |fn|
+next if !canon_files_by_filename.has_key?(fn)
+next if this_project_files[fn].size() > 1 || 
canon_files_by_filename[fn].size() > 1
+this_ent = this_project_files[fn][0]
+canon_ent = canon_files_by_filename[fn][0]
+if this_ent[:uuid] != canon_ent[:uuid]
+STDERR.puts "#{fn} has uuid #{this_ent[:uuid]} in this 

[Lldb-commits] [lldb] r336158 - Re-sort the lldb.xcodeproj project file and commit the script

2018-07-02 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Mon Jul  2 17:43:57 2018
New Revision: 336158

URL: http://llvm.org/viewvc/llvm-project?rev=336158=rev
Log:
Re-sort the lldb.xcodeproj project file and commit the script
that I used to sort it to scripts/sort-pbxproj.rb.  It turns
out that Xcode will perturb the order of the file lists 
every time we add a file, following its own logic, and unfortunately
we'll still end up with lots of merge conflicts when that tries
to merge to the github swift repositories.  We talked this over
and we're going to keep it in a canonical state by running this
script over it when Xcode tries to reorder it.

Added:
lldb/trunk/scripts/sort-pbxproj.rb   (with props)
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj

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


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov added a comment.

It's hard to choose something, both variants are good enough. But, if there is 
no necessity in such a method, we can drop it.


https://reviews.llvm.org/D48775



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


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-07-02 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Have you seen my earlier question:

> Is the dummy target something we need to expose over the SBAPI? 
>  I see that other places in lldb-mi query if (sbTarget == 
> rSessionInfo.GetDebugger().GetDummyTarget()).
>  Would that be sufficient?


https://reviews.llvm.org/D48775



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


[Lldb-commits] [PATCH] D48775: Add new SBTarget::IsDummy method.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov added a comment.

I think we can remove comments added by me and commit patch as it is. Any 
thoughts about it?


https://reviews.llvm.org/D48775



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


[Lldb-commits] [PATCH] D48520: [lldb-mi] Re-implement a few MI commands.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336155: [lldb-mi] Re-implement a few MI commands. (authored 
by apolyakov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48520?vs=152715=153828#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48520

Files:
  lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test
  lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test
  lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test
  lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test
  lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
  lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
  lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
  lldb/trunk/tools/lldb-mi/MICmdCmdExec.h

Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test
===
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-step-instruction command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-step-instruction --thread 0
+# Check that exec-step-instruction can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-step-instruction'. Thread ID invalid"
+
+-exec-next-instruction --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
+
+-exec-step-instruction
+# Check exec-step-instruction in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
Index: lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
===
--- lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
+++ lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c
@@ -1,4 +1,9 @@
+void dummyFunction() {
+  int a = 0;
+}
+
 int main(void) {
   int x = 0;
+  dummyFunction();
   return x;
 }
Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test
===
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test
@@ -0,0 +1,33 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-finish command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-break-insert dummyFunction
+# CHECK: ^done,bkpt={number="2"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-finish --thread 0
+# Check that exec-finish can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-finish'. Thread ID invalid"
+
+-exec-finish --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-finish
+# Check exec-finish in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test
===
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-next-instruction command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-next-instruction --thread 0
+# Check that exec-next-instruction can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-next-instruction'. Thread ID invalid"
+
+-exec-next-instruction --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
+
+-exec-next-instruction
+# Check exec-next-instruction in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test
===
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test
@@ -0,0 +1,20 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-interrupt command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: 

[Lldb-commits] [lldb] r336155 - [lldb-mi] Re-implement a few MI commands.

2018-07-02 Thread Alexander Polyakov via lldb-commits
Author: apolyakov
Date: Mon Jul  2 16:54:06 2018
New Revision: 336155

URL: http://llvm.org/viewvc/llvm-project?rev=336155=rev
Log:
[lldb-mi] Re-implement a few MI commands.

Summary: This patch updates exec-next-instruction, exec-step-instruction,
exec-finish, exec-interrupt commands to use SB API instead of HandleCommand.

Reviewers: aprantl, clayborg

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

Added:
lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test
lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test
lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test
lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test
Modified:
lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c

lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdExec.h

Added: lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test?rev=336155=auto
==
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test (added)
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-finish.test Mon Jul  2 16:54:06 2018
@@ -0,0 +1,33 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-finish command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-break-insert dummyFunction
+# CHECK: ^done,bkpt={number="2"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-finish --thread 0
+# Check that exec-finish can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-finish'. Thread ID invalid"
+
+-exec-finish --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-finish
+# Check exec-finish in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"

Added: lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test?rev=336155=auto
==
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test (added)
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-interrupt.test Mon Jul  2 16:54:06 
2018
@@ -0,0 +1,20 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-interrupt command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-interrupt
+# CHECK: ^error,msg="Process is not running."

Added: lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test?rev=336155=auto
==
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test (added)
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-next-instruction.test Mon Jul  2 
16:54:06 2018
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-next-instruction command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: ^done
+
+-break-insert main
+# CHECK: ^done,bkpt={number="1"
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit"
+
+-exec-next-instruction --thread 0
+# Check that exec-next-instruction can process the case of invalid thread ID.
+# CHECK: ^error,msg="Command 'exec-next-instruction'. Thread ID invalid"
+
+-exec-next-instruction --thread 1
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"
+
+-exec-next-instruction
+# Check exec-next-instruction in a selected thread.
+# CHECK: ^running
+# CHECK: *stopped,reason="end-stepping-range"

Added: lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test?rev=336155=auto
==
--- lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test (added)
+++ lldb/trunk/lit/tools/lldb-mi/exec/exec-step-instruction.test Mon Jul  2 
16:54:06 2018
@@ -0,0 +1,30 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/main.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test lldb-mi -exec-step-instruction command.
+
+# Check that we have a valid target created via '%lldbmi %t'.
+# CHECK: 

[Lldb-commits] [PATCH] D48858: FIx XCode project files for lldb

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336154: FIx XCode project files for lldb (authored by 
teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48858?vs=153826=153827#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48858

Files:
  lldb/trunk/lldb.xcodeproj/project.pbxproj



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


[Lldb-commits] [PATCH] D48858: FIx XCode project files for lldb

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
Herald added a subscriber: srhines.

Fixes the XCode builds that started failing when i added 
CompletionRequest.cpp/.h.

The patch is so large because XCode decided to write the lines back in its own 
order, but essentially we only added on e file.


https://reviews.llvm.org/D48858

Files:
  lldb.xcodeproj/project.pbxproj



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


[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Fre




Comment at: packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py:54
+self.setTearDownCleanup(dictionary=d)
+self.find_compile_units('b.out')
+

apolyakov wrote:
> aprantl wrote:
> > shouldn't this be `self.getBuildArtifact('b.out')`?
> Do you mean: shouldn't `self.getBuildArtifact` be as a `find_compile_units` 
> parameter?
`self.find_compile_units(self.getBuildArtifact('b.out'))`


https://reviews.llvm.org/D48801



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


[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Alex is right, lldb uses @param everywhere.


https://reviews.llvm.org/D48801



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


[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov added inline comments.



Comment at: include/lldb/API/SBModule.h:136
+  ///
+  /// @param[in] sb_file_spec
+  /// A lldb::SBFileSpec object that contains source file

aprantl wrote:
> We typically use `\param` instead of `@param` in LLVM.
I did it like it's done in other places in lldb. Are you sure about `\param` 
and `@param`?


https://reviews.llvm.org/D48801



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


[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov added inline comments.



Comment at: packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py:54
+self.setTearDownCleanup(dictionary=d)
+self.find_compile_units('b.out')
+

aprantl wrote:
> shouldn't this be `self.getBuildArtifact('b.out')`?
Do you mean: shouldn't `self.getBuildArtifact` be as a `find_compile_units` 
parameter?


https://reviews.llvm.org/D48801



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


[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: include/lldb/API/SBModule.h:136
+  ///
+  /// @param[in] sb_file_spec
+  /// A lldb::SBFileSpec object that contains source file

We typically use `\param` instead of `@param` in LLVM.



Comment at: 
packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py:151
+self.setTearDownCleanup(dictionary=d)
+self.find_compile_units('b.out')
+

shouldn't this be self.getBuildArtifact('b.out')?



Comment at: packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py:54
+self.setTearDownCleanup(dictionary=d)
+self.find_compile_units('b.out')
+

shouldn't this be `self.getBuildArtifact('b.out')`?


https://reviews.llvm.org/D48801



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


[Lldb-commits] [PATCH] D48802: [lldb-mi] Re-implement symbol-list-lines command.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 153818.
apolyakov added a comment.

Removed `inline` keyword.


https://reviews.llvm.org/D48802

Files:
  lit/tools/lldb-mi/symbol/inputs/list-lines-helper.c
  lit/tools/lldb-mi/symbol/inputs/list-lines-helper.h
  lit/tools/lldb-mi/symbol/inputs/main.c
  lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.c
  lit/tools/lldb-mi/symbol/inputs/symbol-list-lines.h
  lit/tools/lldb-mi/symbol/lit.local.cfg
  lit/tools/lldb-mi/symbol/symbol-list-lines.test
  packages/Python/lldbsuite/test/tools/lldb-mi/symbol/Makefile
  packages/Python/lldbsuite/test/tools/lldb-mi/symbol/main.cpp
  
packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.cpp
  
packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test.h
  
packages/Python/lldbsuite/test/tools/lldb-mi/symbol/symbol_list_lines_inline_test2.cpp
  tools/lldb-mi/MICmdCmdSymbol.cpp
  tools/lldb-mi/MICmdCmdSymbol.h

Index: tools/lldb-mi/MICmdCmdSymbol.h
===
--- tools/lldb-mi/MICmdCmdSymbol.h
+++ tools/lldb-mi/MICmdCmdSymbol.h
@@ -24,10 +24,10 @@
 #pragma once
 
 // Third party headers:
-#include "lldb/API/SBCommandReturnObject.h"
 
 // In-house headers:
 #include "MICmdBase.h"
+#include "MICmnMIValueList.h"
 
 //++
 //
@@ -55,6 +55,6 @@
 
   // Attributes:
 private:
-  lldb::SBCommandReturnObject m_lldbResult;
+  CMICmnMIValueList m_resultList;
   const CMIUtilString m_constStrArgNameFile;
 };
Index: tools/lldb-mi/MICmdCmdSymbol.cpp
===
--- tools/lldb-mi/MICmdCmdSymbol.cpp
+++ tools/lldb-mi/MICmdCmdSymbol.cpp
@@ -10,18 +10,28 @@
 // Overview:CMICmdCmdSymbolListLines implementation.
 
 // Third Party Headers:
-#include "lldb/API/SBCommandInterpreter.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Regex.h"
+#include "llvm/ADT/Twine.h"
 
 // In-house headers:
 #include "MICmdArgValFile.h"
 #include "MICmdCmdSymbol.h"
 #include "MICmnLLDBDebugSessionInfo.h"
 #include "MICmnMIResultRecord.h"
-#include "MICmnMIValueList.h"
 #include "MICmnMIValueTuple.h"
+#include "MICmnMIValueResult.h"
+
+namespace {
+const CMICmnMIValueTuple
+CreateMITuplePCLine(const uint32_t addr, const uint32_t line_number) {
+  const CMICmnMIValueConst miValueConstAddr("0x" + llvm::Twine::utohexstr(addr).str());
+  const CMICmnMIValueConst miValueConstLine(llvm::Twine(line_number).str());
+  const CMICmnMIValueResult miValueResultAddr("pc", miValueConstAddr);
+  const CMICmnMIValueResult miValueResultLine("line", miValueConstLine);
+  CMICmnMIValueTuple miValueTuple(miValueResultAddr);
+  miValueTuple.Add(miValueResultLine);
+  return miValueTuple;
+}
+} // namespace
 
 //++
 //
@@ -32,7 +42,7 @@
 // Throws:  None.
 //--
 CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines()
-: m_constStrArgNameFile("file") {
+: m_resultList(false), m_constStrArgNameFile("file") {
   // Command factory matches this name with that received from the stdin stream
   m_strMiCmd = "symbol-list-lines";
 
@@ -84,93 +94,51 @@
 bool CMICmdCmdSymbolListLines::Execute() {
   CMICMDBASE_GETOPTION(pArgFile, File, m_constStrArgNameFile);
 
-  const CMIUtilString (pArgFile->GetValue());
-  const CMIUtilString strCmd(CMIUtilString::Format(
-  "source info --file \"%s\"", strFilePath.AddSlashes().c_str()));
-
-  CMICmnLLDBDebugSessionInfo (
-  CMICmnLLDBDebugSessionInfo::Instance());
-  const lldb::ReturnStatus rtn =
-  rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(
-  strCmd.c_str(), m_lldbResult);
-  MIunused(rtn);
-
-  return MIstatus::success;
-}
-
-//++
-//
-// Details: Helper function for parsing the header returned from lldb for the
-// command:
-//  target modules dump line-table 
-//  where the header is of the format:
-//  Line table for /path/to/file in `/path/to/module
-// Args:input - (R) Input string to parse.
-//  file  - (W) String representing the file.
-// Return:  bool - True = input was parsed successfully, false = input could not
-// be parsed.
-// Throws:  None.
-//--
-static bool ParseLLDBLineAddressHeader(const char *input, CMIUtilString ) {
-  // Match LineEntry using regex.
-  static llvm::Regex g_lineentry_header_regex(llvm::StringRef(
-  "^ *Lines found for file (.+) in compilation unit (.+) in `(.+)$"));
-  //   ^1=file  ^2=cu
-  //   ^3=module
-
-  llvm::SmallVector match;
-
-  const bool ok = g_lineentry_header_regex.match(input, );
-  if (ok)
-file = match[1];
-  return ok;
-}
-
-//++

[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov updated this revision to Diff 153817.
apolyakov added a comment.

Added documentation and tests.


https://reviews.llvm.org/D48801

Files:
  include/lldb/API/SBModule.h
  include/lldb/API/SBTarget.h
  
packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
  packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
  scripts/interface/SBModule.i
  scripts/interface/SBTarget.i
  source/API/SBModule.cpp
  source/API/SBTarget.cpp

Index: source/API/SBTarget.cpp
===
--- source/API/SBTarget.cpp
+++ source/API/SBTarget.cpp
@@ -1548,6 +1548,18 @@
   return sb_module;
 }
 
+SBSymbolContextList
+SBTarget::FindCompileUnits(const SBFileSpec _file_spec) {
+  SBSymbolContextList sb_sc_list;
+  const TargetSP target_sp(GetSP());
+  if (target_sp && sb_file_spec.IsValid()) {
+const bool append = true;
+target_sp->GetImages().FindCompileUnits(*sb_file_spec,
+append, *sb_sc_list);
+  }
+  return sb_sc_list;
+}
+
 lldb::ByteOrder SBTarget::GetByteOrder() {
   TargetSP target_sp(GetSP());
   if (target_sp)
Index: source/API/SBModule.cpp
===
--- source/API/SBModule.cpp
+++ source/API/SBModule.cpp
@@ -253,6 +253,17 @@
   return sb_cu;
 }
 
+SBSymbolContextList
+SBModule::FindCompileUnits(const SBFileSpec _file_spec) {
+  SBSymbolContextList sb_sc_list;
+  const ModuleSP module_sp(GetSP());
+  if (sb_file_spec.IsValid() && module_sp) {
+const bool append = true;
+module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list);
+  }
+  return sb_sc_list;
+}
+
 static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP _sp) {
   if (module_sp) {
 SymbolVendor *symbols = module_sp->GetSymbolVendor();
Index: scripts/interface/SBTarget.i
===
--- scripts/interface/SBTarget.i
+++ scripts/interface/SBTarget.i
@@ -410,6 +410,23 @@
 lldb::SBModule
 FindModule (const lldb::SBFileSpec _spec);
 
+%feature("docstring", "
+//--
+/// Find compile units related to *this target and passed source
+/// file.
+///
+/// @param[in] sb_file_spec
+/// A lldb::SBFileSpec object that contains source file
+/// specification.
+///
+/// @return
+/// A lldb::SBSymbolContextList that gets filled in with all of
+/// the symbol contexts for all the matches.
+//--
+") FindCompileUnits;
+lldb::SBSymbolContextList
+FindCompileUnits (const lldb::SBFileSpec _file_spec);
+
 lldb::ByteOrder
 GetByteOrder ();
 
Index: scripts/interface/SBModule.i
===
--- scripts/interface/SBModule.i
+++ scripts/interface/SBModule.i
@@ -179,6 +179,23 @@
 lldb::SBCompileUnit
 GetCompileUnitAtIndex (uint32_t);
 
+%feature("docstring", "
+//--
+/// Find compile units related to *this module and passed source
+/// file.
+///
+/// @param[in] sb_file_spec
+/// A lldb::SBFileSpec object that contains source file
+/// specification.
+///
+/// @return
+/// A lldb::SBSymbolContextList that gets filled in with all of
+/// the symbol contexts for all the matches.
+//--
+") FindCompileUnits;
+lldb::SBSymbolContextList
+FindCompileUnits (const lldb::SBFileSpec _file_spec);
+
 size_t
 GetNumSymbols ();
 
Index: packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
===
--- packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
+++ packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py
@@ -46,6 +46,14 @@
 self.find_global_variables('b.out')
 
 @add_test_categories(['pyapi'])
+def test_find_compile_units(self):
+"""Exercise SBTarget.FindCompileUnits() API."""
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+self.find_compile_units('b.out')
+
+@add_test_categories(['pyapi'])
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
 def test_find_functions(self):
 """Exercise SBTarget.FindFunctions() API."""
@@ -219,6 +227,21 @@
 value_list.GetValueAtIndex(0).GetValue() == "'X'")
 break
 
+def find_compile_units(self, exe_name):
+"""Exercise SBTarget.FindCompileUnits() API."""
+exe = self.getBuildArtifact(exe_name)
+source_name = "main.c"
+
+# Create a target by the debugger.
+target = 

[Lldb-commits] [PATCH] D48855: Fixed compilation failure after the code completion refactor patch

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336149: Fixed compilation failure after the code completion 
refactor patch (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48855?vs=153809=153812#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48855

Files:
  lldb/trunk/include/lldb/Interpreter/CommandObject.h
  lldb/trunk/include/lldb/Utility/CompletionRequest.h


Index: lldb/trunk/include/lldb/Interpreter/CommandObject.h
===
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes
Index: lldb/trunk/include/lldb/Utility/CompletionRequest.h
===
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 


Index: lldb/trunk/include/lldb/Interpreter/CommandObject.h
===
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes
Index: lldb/trunk/include/lldb/Utility/CompletionRequest.h
===
--- lldb/trunk/include/lldb/Utility/CompletionRequest.h
+++ lldb/trunk/include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D48855: Fixed compilation failure after the code completion refactor patch

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.

https://reviews.llvm.org/D48855

Files:
  include/lldb/Interpreter/CommandObject.h
  include/lldb/Utility/CompletionRequest.h


Index: include/lldb/Utility/CompletionRequest.h
===
--- include/lldb/Utility/CompletionRequest.h
+++ include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
Index: include/lldb/Interpreter/CommandObject.h
===
--- include/lldb/Interpreter/CommandObject.h
+++ include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes


Index: include/lldb/Utility/CompletionRequest.h
===
--- include/lldb/Utility/CompletionRequest.h
+++ include/lldb/Utility/CompletionRequest.h
@@ -10,9 +10,9 @@
 #ifndef LLDB_UTILITY_COMPLETIONREQUEST_H
 #define LLDB_UTILITY_COMPLETIONREQUEST_H
 
-#include 
-#include 
-#include 
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/StringList.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 
Index: include/lldb/Interpreter/CommandObject.h
===
--- include/lldb/Interpreter/CommandObject.h
+++ include/lldb/Interpreter/CommandObject.h
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include "lldb/Utility/CompletionRequest.h"
 
 // Other libraries and framework includes
 // Project includes
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r336147 - [lldbsuite, windows] Don't crash LLDB when we try to retrieve a register on Windows

2018-07-02 Thread Stella Stamenova via lldb-commits
Author: stella.stamenova
Date: Mon Jul  2 14:50:31 2018
New Revision: 336147

URL: http://llvm.org/viewvc/llvm-project?rev=336147=rev
Log:
[lldbsuite, windows] Don't crash LLDB when we try to retrieve a register on 
Windows

Summary:
1) When ReadRegister is called with a null register into on Windows, rather 
than crashing due to an access violation, simply return false. Not all 
registers and properties will be read or calculated correctly, but that is 
consistent with other platforms that also return false in that case
2) Update a couple of tests to reference pr37995 as their reason for failure 
since it is much more accurate. Support for floating point registers doesn't 
exist on Windows at all, rather than having issues.

Reviewers: asmith, labath, zturner

Subscribers: llvm-commits

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py

lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py?rev=336147=336146=336147=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
 Mon Jul  2 14:50:31 2018
@@ -22,6 +22,7 @@ class TestYMMRegister(TestBase):
 @skipIfTargetAndroid()
 @skipIf(archs=no_match(['i386', 'x86_64']))
 @expectedFailureAll(oslist=["linux"], bugnumber="rdar://30523153")
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
 def test(self):
 self.build(dictionary={"CFLAGS_EXTRAS": "-march=haswell"})
 self.setTearDownCleanup()

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py?rev=336147=336146=336147=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/register_command/TestRegisters.py
 Mon Jul  2 14:50:31 2018
@@ -59,7 +59,7 @@ class RegisterCommandsTestCase(TestBase)
 # problem
 @skipIfTargetAndroid(archs=["i386"])
 @skipIf(archs=no_match(['amd64', 'arm', 'i386', 'x86_64']))
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683")
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
 def test_fp_register_write(self):
 """Test commands that write to registers, in particular floating-point 
registers."""
 self.build()
@@ -71,7 +71,7 @@ class RegisterCommandsTestCase(TestBase)
 @skipIfFreeBSD  # llvm.org/pr25057
 @skipIf(archs=no_match(['amd64', 'i386', 'x86_64']))
 @skipIfOutOfTreeDebugserver
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37683")
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
 def test_fp_special_purpose_register_read(self):
 """Test commands that read fpu special purpose registers."""
 self.build()

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py?rev=336147=336146=336147=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py
 Mon Jul  2 14:50:31 2018
@@ -9,25 +9,26 @@ import os
 import time
 import re
 import lldb
-import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import decorators
+from lldbsuite.test import lldbutil
+
 
 class TestTrivialABI(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
-
 NO_DEBUG_INFO_TESTCASE = True
 
-@decorators.skipUnlessSupportedTypeAttribute("trivial_abi")
+@skipUnlessSupportedTypeAttribute("trivial_abi")
+

[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL336146: Refactoring for for the internal command line 
completion API (NFC) (authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D48796?vs=153562=153800#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D48796

Files:
  lldb/trunk/include/lldb/Interpreter/CommandAlias.h
  lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
  lldb/trunk/include/lldb/Interpreter/CommandObject.h
  lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h
  lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h
  lldb/trunk/include/lldb/Utility/CompletionRequest.h
  lldb/trunk/source/Commands/CommandObjectCommands.cpp
  lldb/trunk/source/Commands/CommandObjectFrame.cpp
  lldb/trunk/source/Commands/CommandObjectHelp.cpp
  lldb/trunk/source/Commands/CommandObjectHelp.h
  lldb/trunk/source/Commands/CommandObjectMultiword.cpp
  lldb/trunk/source/Commands/CommandObjectPlatform.cpp
  lldb/trunk/source/Commands/CommandObjectPlugin.cpp
  lldb/trunk/source/Commands/CommandObjectProcess.cpp
  lldb/trunk/source/Commands/CommandObjectSettings.cpp
  lldb/trunk/source/Commands/CommandObjectTarget.cpp
  lldb/trunk/source/Interpreter/CommandAlias.cpp
  lldb/trunk/source/Interpreter/CommandInterpreter.cpp
  lldb/trunk/source/Interpreter/CommandObject.cpp
  lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
  lldb/trunk/source/Utility/CMakeLists.txt
  lldb/trunk/source/Utility/CompletionRequest.cpp
  lldb/trunk/unittests/Utility/CMakeLists.txt
  lldb/trunk/unittests/Utility/CompletionRequestTest.cpp

Index: lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
===
--- lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
+++ lldb/trunk/unittests/Utility/CompletionRequestTest.cpp
@@ -0,0 +1,38 @@
+//===-- CompletionRequestTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/CompletionRequest.h"
+using namespace lldb_private;
+
+TEST(CompletionRequest, Constructor) {
+  std::string command = "a b";
+  const unsigned cursor_pos = 2;
+  Args args(command);
+  const int arg_index = 1;
+  const int arg_cursor_pos = 0;
+  const int match_start = 2345;
+  const int match_max_return = 12345;
+  bool word_complete = false;
+  StringList matches;
+  CompletionRequest request(command, cursor_pos, args, arg_index,
+arg_cursor_pos, match_start, match_max_return,
+word_complete, matches);
+
+  EXPECT_STREQ(request.GetRawLine().str().c_str(), command.c_str());
+  EXPECT_EQ(request.GetRawCursorPos(), cursor_pos);
+  EXPECT_EQ(request.GetCursorIndex(), arg_index);
+  EXPECT_EQ(request.GetCursorCharPosition(), arg_cursor_pos);
+  EXPECT_EQ(request.GetMatchStartPoint(), match_start);
+  EXPECT_EQ(request.GetMaxReturnElements(), match_max_return);
+  EXPECT_EQ(request.GetWordComplete(), word_complete);
+  // This is the generated matches should be equal to our passed string list.
+  EXPECT_EQ((), );
+}
Index: lldb/trunk/unittests/Utility/CMakeLists.txt
===
--- lldb/trunk/unittests/Utility/CMakeLists.txt
+++ lldb/trunk/unittests/Utility/CMakeLists.txt
@@ -3,6 +3,7 @@
   ArchSpecTest.cpp
   CleanUpTest.cpp
   ConstStringTest.cpp
+  CompletionRequestTest.cpp
   EnvironmentTest.cpp
   FileSpecTest.cpp
   JSONTest.cpp
Index: lldb/trunk/source/Utility/CompletionRequest.cpp
===
--- lldb/trunk/source/Utility/CompletionRequest.cpp
+++ lldb/trunk/source/Utility/CompletionRequest.cpp
@@ -0,0 +1,26 @@
+//===-- CompletionRequest.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/Utility/CompletionRequest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+CompletionRequest::CompletionRequest(llvm::StringRef command,
+ unsigned raw_cursor_pos, Args _line,
+ int cursor_index, int cursor_char_position,
+ int match_start_point,
+ int max_return_elements,
+ bool word_complete, StringList )
+: m_command(command), m_raw_cursor_pos(raw_cursor_pos),

[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-07-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Okay, sounds reasonable.


https://reviews.llvm.org/D48796



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


[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

@jingham Just trying to keep this patch as minimal/NFC as possible because we 
can't revert it once the expr completion patch is merged. I'll open reviews for 
all these other refactorings once this is in.


https://reviews.llvm.org/D48796



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


[Lldb-commits] [PATCH] D48520: [lldb-mi] Re-implement a few MI commands.

2018-07-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Just waiting for Adrian to indicate he is happy with testing stuff. LGTM


https://reviews.llvm.org/D48520



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


[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-07-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This patch looks fine, I agree with Pavel the direction is good.  It seems like 
you would reduce a bunch of boiler-plate if you changed over 
InvokeCommonCompletionCallbacks to take a CompletionRequest.  Was there 
something that blocked you from doing that?


https://reviews.llvm.org/D48796



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


[Lldb-commits] [PATCH] D48520: [lldb-mi] Re-implement a few MI commands.

2018-07-02 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov added a comment.

Update comment. It still needs a review, thanks for your time.


https://reviews.llvm.org/D48520



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


[Lldb-commits] [PATCH] D48782: LLDB Test Suite: Provide an Option to run all tests with Dwarf Package Format (DWP).

2018-07-02 Thread Pavel Labath via Phabricator via lldb-commits
labath added a subscriber: jankratochvil.
labath added a comment.

In https://reviews.llvm.org/D48782#1149051, @plotfi wrote:

> In https://reviews.llvm.org/D48782#1148498, @alexshap wrote:
>
> > @labath
> >
> > > I am not denying that there is value in running the dotest suite in all 
> > > of these modes. In fact, I think that (the fact that we can use the same 
> > > tests to exercise a lot of different scenarios) is one of the strengths 
> > > ?>of our test suite. However, I don't believe all of these modes should 
> > > be inflicted onto everyone running lldb tests or be our first and only 
> > > line of defense against regressions.
> >
> > for what it's worth - not sure how much you care about my opinion, but i 
> > think it's an important point but it doesn't actually contradict or prevent 
> > your second point regarding adding regression tests using lldb-test, 
> > however i think those should be added over time (sadly no tests were added 
> > when the support for .dwp was implemented / introduced) (not in this patch).
> >  I think that the approach of this patch is still useful, this mode can be 
> > off by default, but if smb needs to run all the tests with dwps - it's easy 
> > to do by passing or setting a variable (for example).
>
>
> yes, thats the near term solution.


What's the medium-to-long term solution?

> In https://reviews.llvm.org/D48782#1148929, @JDevlieghere wrote:
> 
>> In https://reviews.llvm.org/D48782#1148376, @labath wrote:
>>
>> > Then, for the integration test part, I propose to come up with a more 
>> > generic way to specify the kind of debug info to generate. I don't have 
>> > this fully thought out yet, but I have been thinking of something that 
>> > could wrap the compiler invocation with some user specified script. Then 
>> > we could use the same mechanism to run DWP and DWZ with any kind of crazy 
>> > compiler flags we think of (which is definitely useful when bringing up 
>> > support for a new kind of debug info format). If someone has a particular 
>> > interest in a specific combo, he can set up a bot which runs tests in this 
>> > mode (details about who would be responsible for fixing failures TBD)
>>
>>
>> I really like that idea. It sounds similar to the EXPENSIVE_CHECKS we have 
>> for LLVM. Personally I'd love to have an overnight job that runs the test 
>> suite with DWARF5 for example.
> 
> 
> Oh, I see. Have some generic option for debug format to make this problem 
> simpler every time it arises.

The thing is, we *already* have multiple needs for that. Maybe you could work 
with @jankratochvil to come up with a solution that would work for both DWP and 
DWZ? It sounds to me like both of these formats (and even dSYM) could be 
described by "there is some tool which runs after we link the main 
executable/library". If we could have a generic way to specify this as an 
argument to test suite, then we could solve both problems together. As the 
tools are unlikely to take the same arguments (and IIRC, for DWZ there are 
multiple commands we need to issue), we can have wrapper scripts (checked into 
the utils folder or somewhere), which hides these differences.

Does that make sense?


https://reviews.llvm.org/D48782



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


[Lldb-commits] [PATCH] D48465: Added initial code completion support for the `expr` command

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor planned changes to this revision.
teemperor added a comment.

Actually, because both @labath and @jingham requested refactoring to get rid of 
the `--` search (even though Phabricator couldn't parse Jim's comment), I'll 
first also refactor this one. Thanks for the feedback!


https://reviews.llvm.org/D48465



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


[Lldb-commits] [PATCH] D48796: Refactoring for for the internal command line completion API (NFC)

2018-07-02 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thank you for working on this. Overall, I like the direction this is going, but 
I'm OOO this week and the next one, so I'll defer to other reviewers on this 
one.


https://reviews.llvm.org/D48796



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


[Lldb-commits] [PATCH] D48465: Added initial code completion support for the `expr` command

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: 
packages/Python/lldbsuite/test/functionalities/expr_completion/TestExprCompletion.py:177-215
+def generate_random_expr(self, run_index):
+"""
+Generates a random expression. run_index seeds the rng, so
+the output of this method is always the same for the same run_index 
value
+"""
+# Some random tokens we built our expression from.
+tokens = [".", ",", "(", ")", "{", "}", "foo", "a", "some_expr",

labath wrote:
> I don't think a test like this has place in the test suite. It tests a 
> different thing every time it's run and it will be impossible to debug if it 
> starts to fail/be flaky on the build bots.
I don't see how a seeded PRNG is flaky, but I think that test is also not 
important enough that I really want to push for merging it in. I just removed 
it.



Comment at: source/Commands/CommandObjectExpression.cpp:419-423
+// We got the index of the arg and the cursor index inside that arg as
+// parameters, but for completing the whole expression we need to revert
+// this back to the absolute offset of the cursor in the whole expression.
+int absolute_pos =
+WordPosToAbsolutePos(arg, cursor_index, cursor_char_position);

labath wrote:
> Will this work correctly if the expression command contains arguments (`expr 
> -i0 -- my_expression`)? What about quoted strings (`expr "string with 
> spaces`)?
> 
> Have you looked at whether it would be possible to refactor the completion 
> api to provide the absolute position (it has to exist at some point), instead 
> of trying to reverse-engineer it here?
> 
> I think the problem here is that the completion api has this built-in 
> assumption that you're only ever going to be completing "parsed" commands, 
> which is why you get the input as an `Args` array and a two-dimensional 
> cursor position. "expr" command takes "raw" input, which means it does not go 
> through the usual word-splitting and getopt parsing. You can see that because 
> CommandObjectExpression::DoExecute takes a `const char *command`, whereas for 
> "parsed" commands (e.g. "frame variable") the DoExecute function takes the 
> argument as `Args `.
> 
> I think it would make sense to start this by refactoring the completion api 
> to behave the same way as the "DoExecute" api. For "raw" commands , the 
> HandleCompletion function would take a raw string + absolute position in that 
> string, and the parsed commands would get the an `Args` array plus the 
> two-dimensional position. Without that, you're going to get subtle 
> differences in how the expression is treated for completion purposes and for 
> actual evaluation.
I added another parent revision that gives us access to the raw command string, 
which removes all the cmd rebuilding code and fixes the cases you pointed out 
(which are now also in the test suite). I have to see how we can get rid of the 
string search for `--` in both the completion/execute, but that's OOS.



Comment at: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:590
+// to completing the current token.
+StringRef to_remove = cmd;
+while (!to_remove.empty() && !IsTokenSeparator(to_remove.back())) {

aprantl wrote:
> Should this perhaps use some form of StringRef::dropWhile or similar?
> (https://llvm.org/doxygen/classllvm_1_1StringRef.html#aed7897c6ee084440516a7bb5e79a2094)
Most of the functions are for working on the start of the string, but I don't 
see anything like dropWhile for the end of the string. There is not even a 
reverse find_if or something like that :(



Comment at: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h:172
+  ///The number of parsing errors.
+  //---
+  unsigned ParseInternal(DiagnosticManager _manager,

aprantl wrote:
> Perhaps return an llvm::Error instead of an unsigned?
Agreed. But I'll do that in a follow up revision because I didn't actually 
write the ParseInternal for this commit. It's just the renamed `Parse` function 
and added the missing documentation and completion parameters.


https://reviews.llvm.org/D48465



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


[Lldb-commits] [PATCH] D48465: Added initial code completion support for the `expr` command

2018-07-02 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 153748.
teemperor marked 13 inline comments as done.
teemperor added a comment.

- Addresses the problems pointed out by Adrian and Pavel (Thanks!)
- Now using the completion API patch to get rid of the code that rebuilds the 
command line string from the args.


https://reviews.llvm.org/D48465

Files:
  include/lldb/Expression/ExpressionParser.h
  include/lldb/Expression/UserExpression.h
  packages/Python/lldbsuite/test/expression_command/completion/.categories
  packages/Python/lldbsuite/test/expression_command/completion/Makefile
  
packages/Python/lldbsuite/test/expression_command/completion/TestExprCompletion.py
  packages/Python/lldbsuite/test/expression_command/completion/main.cpp
  packages/Python/lldbsuite/test/functionalities/completion/TestCompletion.py
  packages/Python/lldbsuite/test/lldbtest.py
  source/Commands/CommandObjectExpression.cpp
  source/Commands/CommandObjectExpression.h
  source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.h

Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -143,6 +143,9 @@
  lldb_private::ExecutionPolicy execution_policy,
  bool keep_result_in_memory, bool generate_debug_info) override;
 
+  bool Complete(ExecutionContext _ctx, StringList ,
+unsigned complete_pos) override;
+
   ExpressionTypeSystemHelper *GetTypeSystemHelper() override {
 return _type_system_helper;
   }
@@ -199,6 +202,10 @@
 lldb::TargetSP m_target_sp;
   };
 
+  /// The absolute character position in the transformed source code where the
+  /// user code (as typed by the user) starts. If the variable is empty, then we
+  /// were not able to calculate this position.
+  llvm::Optional m_user_expression_start_pos;
   ResultDelegate m_result_delegate;
 };
 
Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -403,6 +403,16 @@
"couldn't construct expression body");
   return llvm::Optional();
 }
+
+// Find and store the start position of the original code inside the
+// transformed code. We need this later for the code completion.
+std::size_t original_start;
+std::size_t original_end;
+bool found_bounds = source_code->GetOriginalBodyBounds(
+m_transformed_text, lang_type, original_start, original_end);
+if (found_bounds) {
+  m_user_expression_start_pos = original_start;
+}
   }
   return lang_type;
 }
@@ -592,6 +602,119 @@
   return true;
 }
 
+//--
+/// Converts an absolute position inside a given code string into
+/// a column/line pair.
+///
+/// @param[in] abs_pos
+/// A absolute position in the code string that we want to convert
+/// to a column/line pair.
+///
+/// @param[in] code
+/// A multi-line string usually representing source code.
+///
+/// @param[out] line
+/// The line in the code that contains the given absolute position.
+/// The first line in the string is indexed as 1.
+///
+/// @param[out] column
+/// The column in the line that contains the absolute position.
+/// The first character in a line is indexed as 0.
+//--
+static void AbsPosToLineColumnPos(unsigned abs_pos, llvm::StringRef code,
+  unsigned , unsigned ) {
+  // Reset to code position to beginning of the file.
+  line = 0;
+  column = 0;
+
+  assert(abs_pos <= code.size() && "Absolute position outside code string?");
+
+  // We have to walk up to the position and count lines/columns.
+  for (std::size_t i = 0; i < abs_pos; ++i) {
+// If we hit a line break, we go back to column 0 and enter a new line.
+// We only handle \n because that's what we internally use to make new
+// lines for our temporary code strings.
+if (code[i] == '\n') {
+  ++line;
+  column = 0;
+  continue;
+}
+++column;
+  }
+}
+
+bool ClangUserExpression::Complete(ExecutionContext _ctx,
+   StringList , unsigned complete_pos) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+  // We don't want any visible feedback when completing an expression. Mostly
+  // because the results we get from an 

[Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution

2018-07-02 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a subscriber: kastiglione.
jingham added a comment.

Sure, that also sounds fine.

Jim


https://reviews.llvm.org/D48752



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


Re: [Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution

2018-07-02 Thread Jim Ingham via lldb-commits
Sure, that also sounds fine.

Jim


> On Jun 29, 2018, at 11:55 AM, Dave Lee via Phabricator 
>  wrote:
> 
> kastiglione added a comment.
> 
> Thanks @jingham.
> 
>> if the `IOHandlerDelegate` could say whether it wants to be notified for 
>> `IOHandlerActivated` when non-interactive (like have a 
>> "`ShouldNotifyWhenNonInteractive`" method), and then the `IOHandler` could 
>> dispatch it or not based on the response to that method
> 
> So the "`ShouldNotifyWhenNonInteractive`" would only control whether 
> `IOHandlerActivated` is called, not any of the other `IOHandlerDelegate` 
> methods?
> 
> What do you think about adding a `IOHandlerActivatedInteractively`delegate 
> method? This could be called in addition to 
> `IOHandlerActivatedInteractively`, but only for interactive IO?
> 
> 
> https://reviews.llvm.org/D48752
> 
> 
> 

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


Re: [Lldb-commits] [lldb] r335956 - Fix TestLoadUsingPaths on linux

2018-07-02 Thread Jim Ingham via lldb-commits
Thanks for fixing this.

Jim

> On Jun 29, 2018, at 2:22 AM, Pavel Labath via lldb-commits 
>  wrote:
> 
> Author: labath
> Date: Fri Jun 29 02:22:07 2018
> New Revision: 335956
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=335956=rev
> Log:
> Fix TestLoadUsingPaths on linux
> 
> we need to explicitly link the test program with -ldl for the dlopen
> function to be available.
> 
> Modified:
>
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
> 
> Modified: 
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile?rev=335956=335955=335956=diff
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
>  (original)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_using_paths/Makefile
>  Fri Jun 29 02:22:07 2018
> @@ -1,6 +1,7 @@
> LEVEL := ../../make
> 
> CXX_SOURCES := main.cpp
> +LD_EXTRAS := -ldl
> 
> include $(LEVEL)/Makefile.rules
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [PATCH] D48802: [lldb-mi] Re-implement symbol-list-lines command.

2018-07-02 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.

LGTM with the inline keyword removed.




Comment at: tools/lldb-mi/MICmdCmdSymbol.cpp:24
+namespace {
+inline const CMICmnMIValueTuple
+CreateMITuplePCLine(const uint32_t addr, const uint32_t line_number) {

apolyakov wrote:
> aprantl wrote:
> > Please remove the `inline` keyword. LLVM will inline if it's profitable 
> > anyway.
> > Also: could this be a constructor of CMImnMIValueTuple?
> I think it could not. There are specific strings like "0x", "pc", "line" in 
> this function which don't have any relation to CMICmnMIValueTuple class. 
> Also, passing them as arguments doesn't seem like a good way. But it can be 
> discussed, maybe someone will suggest a good approach for dealing with it.
I see in that case keeping it local to this file seems like the better approach.


https://reviews.llvm.org/D48802



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


[Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution

2018-07-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: source/Commands/CommandObjectCommands.cpp:1012
   void IOHandlerActivated(IOHandler _handler) override {
+if (!io_handler.GetIsInteractive() && !io_handler.GetIsRealTerminal())
+  // Don't print instructions during batch execution, such as .lldbinit.

Why do we need to check for a real terminal here? Isn't checking if it is 
interactive enough?


https://reviews.llvm.org/D48752



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


[Lldb-commits] [PATCH] D48801: Add new API to SBTarget and SBModule classes.

2018-07-02 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

needs a test, but looks good.


https://reviews.llvm.org/D48801



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