[Lldb-commits] [lldb] 45db9d4 - [test] Fix unused FileCheck prefixes in lldb

2021-02-01 Thread Fangrui Song via lldb-commits

Author: Fangrui Song
Date: 2021-02-01T21:45:51-08:00
New Revision: 45db9d4594bdbb4a304c16f6ad61b87c60eeb300

URL: 
https://github.com/llvm/llvm-project/commit/45db9d4594bdbb4a304c16f6ad61b87c60eeb300
DIFF: 
https://github.com/llvm/llvm-project/commit/45db9d4594bdbb4a304c16f6ad61b87c60eeb300.diff

LOG: [test] Fix unused FileCheck prefixes in lldb

Added: 


Modified: 
lldb/test/Shell/Reproducer/TestMultipleTargets.test

Removed: 




diff  --git a/lldb/test/Shell/Reproducer/TestMultipleTargets.test 
b/lldb/test/Shell/Reproducer/TestMultipleTargets.test
index 7859480e2d04..cb2f766034fd 100644
--- a/lldb/test/Shell/Reproducer/TestMultipleTargets.test
+++ b/lldb/test/Shell/Reproducer/TestMultipleTargets.test
@@ -21,3 +21,5 @@
 
 # CAPTURE: Reproducer is in capture mode.
 # CAPTURE: Reproducer written
+
+# REPLAY:  Reproducer is in replay mode.



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


[Lldb-commits] [lldb] ecb00a7 - [VFS] Add support to RedirectingFileSystem for mapping a virtual directory to one in the external FS.

2021-02-01 Thread Nathan Hawes via lldb-commits

Author: Nathan Hawes
Date: 2021-02-02T14:56:17+10:00
New Revision: ecb00a77624c94ce38fccf9b4095e026ecf14aed

URL: 
https://github.com/llvm/llvm-project/commit/ecb00a77624c94ce38fccf9b4095e026ecf14aed
DIFF: 
https://github.com/llvm/llvm-project/commit/ecb00a77624c94ce38fccf9b4095e026ecf14aed.diff

LOG: [VFS] Add support to RedirectingFileSystem for mapping a virtual directory 
to one in the external FS.

Previously file entries in the -ivfsoverlay yaml could map to a file in the
external file system, but directories had to list their contents in the form of
other file entries or directories. Allowing directory entries to map to a
directory in the external file system makes it possible to present an external
directory's contents in a different location and (in combination with the
'fallthrough' option) overlay one directory's contents on top of another.

rdar://problem/72485443
Differential Revision: https://reviews.llvm.org/D94844

Added: 
clang/test/VFS/Inputs/vfsoverlay-directory-relative.yaml
clang/test/VFS/Inputs/vfsoverlay-directory.yaml
clang/test/VFS/directory.c

Modified: 
lldb/source/Host/common/FileSystem.cpp
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/VirtualFileSystem.cpp
llvm/unittests/Support/VirtualFileSystemTest.cpp

Removed: 




diff  --git a/clang/test/VFS/Inputs/vfsoverlay-directory-relative.yaml 
b/clang/test/VFS/Inputs/vfsoverlay-directory-relative.yaml
new file mode 100644
index ..635460a4a9b0
--- /dev/null
+++ b/clang/test/VFS/Inputs/vfsoverlay-directory-relative.yaml
@@ -0,0 +1,11 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'overlay-relative': true,
+  'roots': [
+{ 'name': 'OUT_DIR',
+  'type': 'directory-remap',
+  'external-contents': 'INPUT_DIR'
+}
+  ]
+}

diff  --git a/clang/test/VFS/Inputs/vfsoverlay-directory.yaml 
b/clang/test/VFS/Inputs/vfsoverlay-directory.yaml
new file mode 100644
index ..d8a283ee3f19
--- /dev/null
+++ b/clang/test/VFS/Inputs/vfsoverlay-directory.yaml
@@ -0,0 +1,10 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'roots': [
+{ 'name': 'OUT_DIR',
+  'type': 'directory-remap',
+  'external-contents': 'INPUT_DIR'
+}
+  ]
+}

diff  --git a/clang/test/VFS/directory.c b/clang/test/VFS/directory.c
new file mode 100644
index ..b850ace54c93
--- /dev/null
+++ b/clang/test/VFS/directory.c
@@ -0,0 +1,48 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/Underlying
+// RUN: mkdir -p %t/Overlay
+// RUN: mkdir -p %t/Middle
+// RUN: echo '// B.h in Underlying' > %t/Underlying/B.h
+// RUN: echo '#ifdef NESTED' >> %t/Underlying/B.h
+// RUN: echo '#include "C.h"' >> %t/Underlying/B.h
+// RUN: echo '#endif' >> %t/Underlying/B.h
+// RUN: echo '// C.h in Underlying' > %t/Underlying/C.h
+// RUN: echo '// C.h in Middle' > %t/Middle/C.h
+// RUN: echo '// C.h in Overlay' > %t/Overlay/C.h
+
+// 1) Underlying -> Overlay (C.h found, B.h falling back to Underlying)
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}/Overlay@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}/Underlying@g" 
%S/Inputs/vfsoverlay-directory.yaml > %t/vfs.yaml
+// RUN: %clang_cc1 -Werror -I %t/Underlying -ivfsoverlay %t/vfs.yaml 
-fsyntax-only -E -C %s 2>&1 | FileCheck --check-prefix=DIRECT %s
+// RUN: %clang_cc1 -Werror -I %t/Underlying -ivfsoverlay %t/vfs.yaml 
-fsyntax-only -DNESTED -E -C %s 2>&1 | FileCheck --check-prefix=DIRECT %s
+// RUN: sed -e "s@INPUT_DIR@Overlay@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}/Underlying@g" 
%S/Inputs/vfsoverlay-directory-relative.yaml > %t/vfs-relative.yaml
+// RUN: %clang_cc1 -Werror -I %t/Underlying -ivfsoverlay %t/vfs-relative.yaml 
-fsyntax-only -E -C %s 2>&1 | FileCheck --check-prefix=DIRECT %s
+
+// DIRECT: {{^}}// B.h in Underlying
+// DIRECT: {{^}}// C.h in Overlay
+
+// 2) Underlying -> Middle -> Overlay (C.h found, B.h falling back to 
Underlying)
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}/Overlay@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}/Middle@g" 
%S/Inputs/vfsoverlay-directory.yaml > %t/vfs.yaml
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}/Middle@g" -e 
"s@OUT_DIR@%{/t:regex_replacement}/Underlying@g" 
%S/Inputs/vfsoverlay-directory.yaml > %t/vfs2.yaml
+// RUN: %clang_cc1 -Werror -I %t/Underlying -ivfsoverlay %t/vfs.yaml 
-ivfsoverlay %t/vfs2.yaml -fsyntax-only -E -C %s 2>&1 | FileCheck 
--check-prefix=DIRECT %s
+// RUN: %clang_cc1 -Werror -I %t/Underlying -ivfsoverlay %t/vfs.yaml 
-ivfsoverlay %t/vfs2.yaml -DNESTED -fsyntax-only -E -C %s 2>&1 | FileCheck 
--check-prefix=DIRECT %s
+
+// Same as direct above
+
+// 3) Underlying -> Middle -> Overlay (C.h falling back to Middle, B.h falling 
back to Underlying)
+// RUN: rm -f %t/Overlay/C.h
+// RUN: %clang_cc1 -Werror -I %t/Underlying -ivfsoverlay %t/vfs.yaml 
-ivfsoverlay %t/vfs2.yaml -fsyntax-only -E -C %s 2>&1 | FileCheck 
--check-prefix=FALLBACK %s
+
+// FALLBACK: {{^}}// B.h in Underlying
+// 

[Lldb-commits] [PATCH] D94844: [VFS] Add support to RedirectingFileSystem for mapping a virtual directory to one in the external FS.

2021-02-01 Thread Nathan Hawes via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecb00a77624c: [VFS] Add support to RedirectingFileSystem for 
mapping a virtual directory to… (authored by nathawes).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94844/new/

https://reviews.llvm.org/D94844

Files:
  clang/test/VFS/Inputs/vfsoverlay-directory-relative.yaml
  clang/test/VFS/Inputs/vfsoverlay-directory.yaml
  clang/test/VFS/directory.c
  lldb/source/Host/common/FileSystem.cpp
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1328,6 +1328,7 @@
 
 TEST_F(VFSFromYAMLTest, MappedFiles) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
   Lower->addRegularFile("//root/foo/bar/a");
   IntrusiveRefCntPtr FS = getFromYAMLString(
   "{ 'roots': [\n"
@@ -1343,6 +1344,17 @@
   "  'type': 'file',\n"
   "  'name': 'file2',\n"
   "  'external-contents': '//root/foo/b'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory-remap',\n"
+  "  'name': 'mappeddir',\n"
+  "  'external-contents': '//root/foo/bar'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory-remap',\n"
+  "  'name': 'mappeddir2',\n"
+  "  'use-external-name': false,\n"
+  "  'external-contents': '//root/foo/bar'\n"
   "}\n"
   "  ]\n"
   "}\n"
@@ -1380,12 +1392,221 @@
   EXPECT_TRUE(S->isDirectory());
   EXPECT_TRUE(S->equivalent(*O->status("//root/"))); // non-volatile UniqueID
 
+  // remapped directory
+  S = O->status("//root/mappeddir");
+  ASSERT_FALSE(S.getError());
+  EXPECT_TRUE(S->isDirectory());
+  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->equivalent(*O->status("//root/foo/bar")));
+
+  SLower = O->status("//root/foo/bar");
+  EXPECT_EQ("//root/foo/bar", SLower->getName());
+  EXPECT_TRUE(S->equivalent(*SLower));
+  EXPECT_FALSE(SLower->IsVFSMapped);
+
+  // file in remapped directory
+  S = O->status("//root/mappeddir/a");
+  ASSERT_FALSE(S.getError());
+  ASSERT_FALSE(S->isDirectory());
+  ASSERT_TRUE(S->IsVFSMapped);
+  ASSERT_EQ("//root/foo/bar/a", S->getName());
+
+  // file in remapped directory, with use-external-name=false
+  S = O->status("//root/mappeddir2/a");
+  ASSERT_FALSE(S.getError());
+  ASSERT_FALSE(S->isDirectory());
+  ASSERT_TRUE(S->IsVFSMapped);
+  ASSERT_EQ("//root/mappeddir2/a", S->getName());
+
+  // file contents in remapped directory
+  OpenedF = O->openFileForRead("//root/mappeddir/a");
+  ASSERT_FALSE(OpenedF.getError());
+  OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  // file contents in remapped directory, with use-external-name=false
+  OpenedF = O->openFileForRead("//root/mappeddir2/a");
+  ASSERT_FALSE(OpenedF.getError());
+  OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("//root/mappeddir2/a", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
   // broken mapping
   EXPECT_EQ(O->status("//root/file2").getError(),
 llvm::errc::no_such_file_or_directory);
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, MappedRoot) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
+  Lower->addRegularFile("//root/foo/bar/a");
+  IntrusiveRefCntPtr FS =
+  getFromYAMLString("{ 'roots': [\n"
+"{\n"
+"  'type': 'directory-remap',\n"
+"  'name': '//mappedroot/',\n"
+"  'external-contents': '//root/foo/bar'\n"
+"}\n"
+"]\n"
+"}",
+Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(FS);
+
+  // file
+  ErrorOr S = O->status("//mappedroot/a");
+  ASSERT_FALSE(S.getError());
+  EXPECT_EQ("//root/foo/bar/a", S->getName());
+  EXPECT_TRUE(S->IsVFSMapped);
+
+  ErrorOr SLower = O->status("//root/foo/bar/a");
+  EXPECT_EQ("//root/foo/bar/a", SLower->getName());
+  EXPECT_TRUE(S->equivalent(*SLower));
+  EXPECT_FALSE(SLower->IsVFSMapped);
+
+  // file after opening
+  auto OpenedF = O->openFileForRead("//mappedroot/a");
+  

[Lldb-commits] [PATCH] D95710: [lldb/Commands] Add command options for ScriptedProcess to ProcessLaunch

2021-02-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I'm not quite sure why we need the extra m_scripted_process boolean.  Seems 
like you could key off whether we had a non-empty class_name.  Is there any 
case where you would want to boolean set w/o having a class name yet?




Comment at: lldb/include/lldb/Host/ProcessLaunchInfo.h:188
+  bool m_scripted_process;
+  llvm::StringRef m_scripted_process_class_name;
+  StructuredData::DictionarySP m_scripted_process_dictionary_sp;

vsk wrote:
> Might be best to use a std::string here, to avoid tying the lifetime of 
> m_scripted_process_class_name to the lifetime of the string stored in 
> m_class_options.
Agreed.  You seldom want to use a StringRef as an ivar, since it doesn't manage 
lifetimes at all.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95710/new/

https://reviews.llvm.org/D95710

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


[Lldb-commits] [PATCH] D94844: [VFS] Add support to RedirectingFileSystem for mapping a virtual directory to one in the external FS.

2021-02-01 Thread Nathan Hawes via Phabricator via lldb-commits
nathawes updated this revision to Diff 320646.
nathawes added a comment.

Made the following changes as a speculative fix for the windows test failures 
in the pre-merge checks:

- When appending the remaining path components to the external redirect path of 
a directory-remap entry, use the separator type of the redirect path rather 
than the host system.
- For a directory-remap entry, when changing the paths returned in the external 
file system's directory iterator to appear to be in the virtual file system's 
directory, use the separator type from the virtual directory's path rather than 
the host system's.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94844/new/

https://reviews.llvm.org/D94844

Files:
  clang/test/VFS/Inputs/vfsoverlay-directory-relative.yaml
  clang/test/VFS/Inputs/vfsoverlay-directory.yaml
  clang/test/VFS/directory.c
  lldb/source/Host/common/FileSystem.cpp
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1328,6 +1328,7 @@
 
 TEST_F(VFSFromYAMLTest, MappedFiles) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
   Lower->addRegularFile("//root/foo/bar/a");
   IntrusiveRefCntPtr FS = getFromYAMLString(
   "{ 'roots': [\n"
@@ -1343,6 +1344,17 @@
   "  'type': 'file',\n"
   "  'name': 'file2',\n"
   "  'external-contents': '//root/foo/b'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory-remap',\n"
+  "  'name': 'mappeddir',\n"
+  "  'external-contents': '//root/foo/bar'\n"
+  "},\n"
+  "{\n"
+  "  'type': 'directory-remap',\n"
+  "  'name': 'mappeddir2',\n"
+  "  'use-external-name': false,\n"
+  "  'external-contents': '//root/foo/bar'\n"
   "}\n"
   "  ]\n"
   "}\n"
@@ -1380,12 +1392,221 @@
   EXPECT_TRUE(S->isDirectory());
   EXPECT_TRUE(S->equivalent(*O->status("//root/"))); // non-volatile UniqueID
 
+  // remapped directory
+  S = O->status("//root/mappeddir");
+  ASSERT_FALSE(S.getError());
+  EXPECT_TRUE(S->isDirectory());
+  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->equivalent(*O->status("//root/foo/bar")));
+
+  SLower = O->status("//root/foo/bar");
+  EXPECT_EQ("//root/foo/bar", SLower->getName());
+  EXPECT_TRUE(S->equivalent(*SLower));
+  EXPECT_FALSE(SLower->IsVFSMapped);
+
+  // file in remapped directory
+  S = O->status("//root/mappeddir/a");
+  ASSERT_FALSE(S.getError());
+  ASSERT_FALSE(S->isDirectory());
+  ASSERT_TRUE(S->IsVFSMapped);
+  ASSERT_EQ("//root/foo/bar/a", S->getName());
+
+  // file in remapped directory, with use-external-name=false
+  S = O->status("//root/mappeddir2/a");
+  ASSERT_FALSE(S.getError());
+  ASSERT_FALSE(S->isDirectory());
+  ASSERT_TRUE(S->IsVFSMapped);
+  ASSERT_EQ("//root/mappeddir2/a", S->getName());
+
+  // file contents in remapped directory
+  OpenedF = O->openFileForRead("//root/mappeddir/a");
+  ASSERT_FALSE(OpenedF.getError());
+  OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  // file contents in remapped directory, with use-external-name=false
+  OpenedF = O->openFileForRead("//root/mappeddir2/a");
+  ASSERT_FALSE(OpenedF.getError());
+  OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("//root/mappeddir2/a", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
   // broken mapping
   EXPECT_EQ(O->status("//root/file2").getError(),
 llvm::errc::no_such_file_or_directory);
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, MappedRoot) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
+  Lower->addRegularFile("//root/foo/bar/a");
+  IntrusiveRefCntPtr FS =
+  getFromYAMLString("{ 'roots': [\n"
+"{\n"
+"  'type': 'directory-remap',\n"
+"  'name': '//mappedroot/',\n"
+"  'external-contents': '//root/foo/bar'\n"
+"}\n"
+"]\n"
+"}",
+Lower);
+  ASSERT_TRUE(FS.get() != nullptr);
+
+  IntrusiveRefCntPtr O(
+  new vfs::OverlayFileSystem(Lower));
+  O->pushOverlay(FS);
+
+  // file
+  ErrorOr S = O->status("//mappedroot/a");
+  ASSERT_FALSE(S.getError());
+  

[Lldb-commits] [lldb] fbd5507 - [lldb] Use the host architecture in TestAppleSimulatorOSType.py

2021-02-01 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-02-01T16:18:31-08:00
New Revision: fbd55071788a3e57d2fdf8cad5c79ee45a273019

URL: 
https://github.com/llvm/llvm-project/commit/fbd55071788a3e57d2fdf8cad5c79ee45a273019
DIFF: 
https://github.com/llvm/llvm-project/commit/fbd55071788a3e57d2fdf8cad5c79ee45a273019.diff

LOG: [lldb] Use the host architecture in TestAppleSimulatorOSType.py

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 67ff19f49448..609c6b520d31 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -1,5 +1,3 @@
-
-
 import gdbremote_testcase
 import lldbgdbserverutils
 from lldbsuite.test.decorators import *
@@ -7,6 +5,7 @@
 from lldbsuite.test import lldbutil
 
 import json
+import platform
 
 @skipIfReproducer
 class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
@@ -16,7 +15,7 @@ class 
TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
 # Number of stderr lines to read from the simctl output.
 READ_LINES = 10
 
-def check_simulator_ostype(self, sdk, platform, arch='x86_64'):
+def check_simulator_ostype(self, sdk, platform_name):
 cmd = ['xcrun', 'simctl', 'list', '-j', 'devices']
 self.trace(' '.join(cmd))
 sim_devices_str = subprocess.check_output(cmd).decode("utf-8")
@@ -31,7 +30,7 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 else:
 runtime = simulator
 devices = sim_devices[simulator]
-if not platform in runtime.lower():
+if not platform_name in runtime.lower():
 continue
 for device in devices:
 if 'availability' in device and device['availability'] != 
'(available)':
@@ -47,10 +46,10 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 
 # Launch the process using simctl
 self.assertIsNotNone(deviceUDID)
-exe_name = 'test_simulator_platform_{}'.format(platform)
+exe_name = 'test_simulator_platform_{}'.format(platform_name)
 sdkroot = lldbutil.get_xcode_sdk_root(sdk)
 self.build(dictionary={ 'EXE': exe_name, 'SDKROOT': sdkroot.strip(),
-'ARCH': arch })
+'ARCH': platform.machine() })
 exe_path = self.getBuildArtifact(exe_name)
 cmd = [
 'xcrun', 'simctl', 'spawn', '-s', deviceUDID, exe_path,
@@ -96,7 +95,7 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 self.assertIsNotNone(process_info)
 
 # Check that ostype is correct
-self.assertEquals(process_info['ostype'], platform + 'simulator')
+self.assertEquals(process_info['ostype'], platform_name + 'simulator')
 
 # Now for dylibs
 dylib_info_raw = context.get("dylib_info_raw")
@@ -111,7 +110,7 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 break
 
 self.assertIsNotNone(image_info)
-self.assertEquals(image['min_version_os_name'], platform + 'simulator')
+self.assertEquals(image['min_version_os_name'], platform_name + 
'simulator')
 
 
 @apple_simulator_test('iphone')
@@ -119,18 +118,18 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 @skipIfRemote
 def test_simulator_ostype_ios(self):
 self.check_simulator_ostype(sdk='iphonesimulator',
-platform='ios')
+platform_name='ios')
 
 @apple_simulator_test('appletv')
 @debugserver_test
 @skipIfRemote
 def test_simulator_ostype_tvos(self):
 self.check_simulator_ostype(sdk='appletvsimulator',
-platform='tvos')
+platform_name='tvos')
 
 @apple_simulator_test('watch')
 @debugserver_test
 @skipIfRemote
 def test_simulator_ostype_watchos(self):
 self.check_simulator_ostype(sdk='watchsimulator',
-platform='watchos', arch='i386')
+platform_name='watchos')



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


[Lldb-commits] [PATCH] D95813: [lldb] Convert assertTrue(a == b) to assertEqual(a, b)

2021-02-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/test/API/python_api/frame/TestFrames.py:97
 sp_value, "We should have a valid Stack Pointer.")
-self.assertTrue(int(sp_value.GetValue(), 0) == frame.GetSP(
+self.assertEqual(int(sp_value.GetValue(), 0), frame.GetSP(
 ), "SP gotten as a value should equal frame's GetSP")

JDevlieghere wrote:
> Very odd/confusing formatting. 
I noticed this too in the diff, I'll fix it up.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95813/new/

https://reviews.llvm.org/D95813

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


[Lldb-commits] [PATCH] D95813: [lldb] Convert assertTrue(a == b) to assertEqual(a, b)

2021-02-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Cool, I was under the impression @teemperor had already done something similar, 
but I must be misremembering.




Comment at: lldb/test/API/python_api/frame/TestFrames.py:97
 sp_value, "We should have a valid Stack Pointer.")
-self.assertTrue(int(sp_value.GetValue(), 0) == frame.GetSP(
+self.assertEqual(int(sp_value.GetValue(), 0), frame.GetSP(
 ), "SP gotten as a value should equal frame's GetSP")

Very odd/confusing formatting. 



Comment at: lldb/test/API/python_api/lldbutil/iter/TestLLDBIterator.py:53
 
-self.assertTrue(len(yours) == len(mine))
+self.assertEqual(len(yours), len(mine))
 for i in range(len(yours)):




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95813/new/

https://reviews.llvm.org/D95813

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


[Lldb-commits] [PATCH] D95710: [lldb/Commands] Add command options for ScriptedProcess to ProcessLaunch

2021-02-01 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added inline comments.



Comment at: lldb/include/lldb/Host/ProcessLaunchInfo.h:188
+  bool m_scripted_process;
+  llvm::StringRef m_scripted_process_class_name;
+  StructuredData::DictionarySP m_scripted_process_dictionary_sp;

Might be best to use a std::string here, to avoid tying the lifetime of 
m_scripted_process_class_name to the lifetime of the string stored in 
m_class_options.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95710/new/

https://reviews.llvm.org/D95710

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


[Lldb-commits] [PATCH] D95813: [lldb] Convert assertTrue(a == b) to assertEqual(a, b)

2021-02-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

I haven't run tests yet.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95813/new/

https://reviews.llvm.org/D95813

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


[Lldb-commits] [PATCH] D95813: [lldb] Convert assertTrue(a == b) to assertEqual(a, b)

2021-02-01 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: JDevlieghere, teemperor.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Convert `assertTrue(a == b)` to `assertEqual(a, b)` to produce better failure 
messages.

These were mostly done via regex search & replace, with some manual fixes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95813

Files:
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
  
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
  lldb/test/API/functionalities/conditional_break/TestConditionalBreak.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
  lldb/test/API/functionalities/exec/TestExec.py
  lldb/test/API/functionalities/return-value/TestReturnValue.py
  lldb/test/API/functionalities/tty/TestTerminal.py
  lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
  lldb/test/API/lang/c/bitfields/TestBitfields.py
  lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
  lldb/test/API/lang/cpp/class_static/TestStaticVariables.py
  lldb/test/API/lang/cpp/class_types/TestClassTypes.py
  lldb/test/API/lang/cpp/dynamic-value/TestCppValueCast.py
  lldb/test/API/lang/cpp/template/TestTemplateArgs.py
  lldb/test/API/lang/objc/blocks/TestObjCIvarsInBlocks.py
  lldb/test/API/lang/objc/foundation/TestObjCMethods.py
  lldb/test/API/lang/objc/foundation/TestObjectDescriptionAPI.py
  lldb/test/API/lang/objc/foundation/TestSymbolTable.py
  lldb/test/API/lang/objc/objc-checker/TestObjCCheckers.py
  lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py
  lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
  lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
  lldb/test/API/python_api/event/TestEvents.py
  lldb/test/API/python_api/frame/TestFrames.py
  lldb/test/API/python_api/frame/inlines/TestInlinedFrame.py
  lldb/test/API/python_api/function_symbol/TestDisasmAPI.py
  lldb/test/API/python_api/function_symbol/TestSymbolAPI.py
  lldb/test/API/python_api/lldbutil/frame/TestFrameUtils.py
  lldb/test/API/python_api/lldbutil/iter/TestLLDBIterator.py
  lldb/test/API/python_api/process/io/TestProcessIO.py
  lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py
  lldb/test/API/python_api/sbdata/TestSBData.py
  lldb/test/API/python_api/symbol-context/TestSymbolContext.py
  lldb/test/API/python_api/target/TestTargetAPI.py
  lldb/test/API/python_api/thread/TestThreadAPI.py
  lldb/test/API/python_api/type/TestTypeList.py
  lldb/test/API/python_api/value/TestValueAPI.py
  lldb/test/API/python_api/value/linked_list/TestValueAPILinkedList.py
  lldb/test/API/python_api/watchpoint/TestSetWatchpoint.py
  lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
  lldb/test/API/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  lldb/test/API/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
  lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
  lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
  
lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
  
lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py
  lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py

Index: lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
===
--- lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -29,7 +29,7 @@
 for key in verify:
 verify_value = verify[key]
 actual_value = actual[key]
-self.assertTrue(verify_value == actual_value,
+self.assertEqual(verify_value, actual_value,
 '"%s" keys don\'t match (%s != %s)' % (
 key, actual_value, verify_value))
 if 'startswith' in verify_dict:
@@ -87,7 +87,7 @@
 lines = [breakpoint1_line]
 # Set breakpoint in the thread function so we can step the threads
 breakpoint_ids = self.set_source_breakpoints(source, lines)
-

[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2021-02-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 320560.
tatyana-krasnukha added a comment.

Removed test since the same case was added by D95761 
.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92164/new/

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3349,7 +3349,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), _ctx,
+  debugger.GetCommandInterpreter().HandleCommands(GetCommands(), exc_ctx,
   options, result);
   debugger.SetAsyncExecution(old_async);
   lldb::ReturnStatus status = result.GetStatus();
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -76,6 +76,7 @@
 #include "lldb/Target/UnixSignals.h"
 
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/Path.h"
@@ -1631,12 +1632,18 @@
 
 bool CommandInterpreter::HandleCommand(const char *command_line,
LazyBool lazy_add_to_history,
-   CommandReturnObject ,
-   ExecutionContext *override_context,
-   bool repeat_on_empty_command,
-   bool no_context_switching)
+   const ExecutionContext _context,
+   CommandReturnObject ) {
+
+  OverrideExecutionContext(override_context);
+  bool status = HandleCommand(command_line, lazy_add_to_history, result);
+  RestoreExecutionContext();
+  return status;
+}
 
-{
+bool CommandInterpreter::HandleCommand(const char *command_line,
+   LazyBool lazy_add_to_history,
+   CommandReturnObject ) {
 
   std::string command_string(command_line);
   std::string original_command_string(command_line);
@@ -1648,9 +1655,6 @@
   LLDB_LOGF(log, "Processing command: %s", command_line);
   LLDB_SCOPED_TIMERF("Processing command: %s.", command_line);
 
-  if (!no_context_switching)
-UpdateExecutionContext(override_context);
-
   if (WasInterrupted()) {
 result.AppendError("interrupted");
 result.SetStatus(eReturnStatusFailed);
@@ -1696,26 +1700,22 @@
   }
 
   if (empty_command) {
-if (repeat_on_empty_command) {
-  if (m_command_history.IsEmpty()) {
-result.AppendError("empty command");
-result.SetStatus(eReturnStatusFailed);
-return false;
-  } else {
-command_line = m_repeat_command.c_str();
-command_string = command_line;
-original_command_string = command_line;
-if (m_repeat_command.empty()) {
-  result.AppendError("No auto repeat.");
-  result.SetStatus(eReturnStatusFailed);
-  return false;
-}
-  }
-  add_to_history = false;
-} else {
-  result.SetStatus(eReturnStatusSuccessFinishNoResult);
-  return true;
+if (m_command_history.IsEmpty()) {
+  result.AppendError("empty command");
+  result.SetStatus(eReturnStatusFailed);
+  return false;
+}
+
+command_line = m_repeat_command.c_str();
+command_string = command_line;
+original_command_string = command_line;
+if (m_repeat_command.empty()) {
+  result.AppendError("No auto repeat.");
+  result.SetStatus(eReturnStatusFailed);
+  return false;
 }
+
+add_to_history = false;
   } else if (comment_command) {
 result.SetStatus(eReturnStatusSuccessFinishNoResult);
 return true;
@@ -1852,8 +1852,6 @@
 
 void CommandInterpreter::HandleCompletion(CompletionRequest ) {
 
-  UpdateExecutionContext(nullptr);
-
   // Don't complete comments, and if the line we are completing is just the
   // history repeat character, substitute the appropriate history line.
   llvm::StringRef first_arg = 

[Lldb-commits] [PATCH] D92164: Make CommandInterpreter's execution context the same as debugger's one.

2021-02-01 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 320548.
tatyana-krasnukha edited the summary of this revision.
tatyana-krasnukha added a comment.

It turns out that the Debugger recalculated the selected stack frame without 
taking the Process's run lock. I replaced the whole context evaluation with 
creating ExecutionContextRef which does these things right.

@labath, I would appreciate it if you check that the latest version works for 
you too (I ran TestGuiBasicDebug.py 100 times on Linux and it succeeded all the 
time).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92164/new/

https://reviews.llvm.org/D92164

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Breakpoint/BreakpointOptions.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectRegexCommand.cpp
  lldb/source/Commands/CommandObjectSettings.cpp
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/python_api/debugger/Makefile
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py
  lldb/test/API/python_api/debugger/main.cpp

Index: lldb/test/API/python_api/debugger/main.cpp
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/main.cpp
@@ -0,0 +1,9 @@
+// This simple program is to test the lldb Python API SBDebugger.
+
+int func(int val) {
+return val - 1;
+}
+
+int main (int argc, char const *argv[]) {
+return func(argc);
+}
Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,54 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+def test_debugger_internal_variable(self):
+"""Ensure that SBDebugger reachs the same instance of properties
+   regardless CommandInterpreter's context initialization"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+# Create a target by the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+property_name = "target.process.memory-cache-line-size"
+
+def get_cache_line_size():
+value_list = lldb.SBStringList()
+value_list = self.dbg.GetInternalVariableValue(property_name,
+   self.dbg.GetInstanceName())
+
+self.assertEqual(value_list.GetSize(), 1)
+try:
+return int(value_list.GetStringAtIndex(0))
+except ValueError as error:
+self.fail("Value is not a number: " + error)
+
+# Get global property value while there are no processes.
+global_cache_line_size = get_cache_line_size()
+
+# Run a process via SB interface. CommandInterpreter's execution context
+# remains empty.
+error = lldb.SBError()
+launch_info = lldb.SBLaunchInfo(None)
+launch_info.SetLaunchFlags(lldb.eLaunchFlagStopAtEntry)
+process = target.Launch(launch_info, error)
+self.assertTrue(process, PROCESS_IS_VALID)
+
+# This should change the value of a process's local property.
+new_cache_line_size = global_cache_line_size + 512
+error = self.dbg.SetInternalVariable(property_name,
+ str(new_cache_line_size),
+ self.dbg.GetInstanceName())
+self.assertTrue(error.Success(),
+property_name + " value was changed successfully")
+
+# Check that it was set actually.
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+# Run any command to initialize CommandInterpreter's execution context.
+self.runCmd("target list")
+
+# Test the local property again, is it set to new_cache_line_size?
+self.assertEqual(get_cache_line_size(), new_cache_line_size)
Index: lldb/test/API/python_api/debugger/Makefile
===
--- /dev/null
+++ lldb/test/API/python_api/debugger/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3351,7 +3351,7 @@
   // Force Async:
   bool old_async = debugger.GetAsyncExecution();
   debugger.SetAsyncExecution(true);
-  

[Lldb-commits] [PATCH] D95802: [lldb] [Process/FreeBSDRemote] Introduce mips64 support

2021-02-01 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 320524.
mgorny added a comment.

Remove `#if 0`s.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95802/new/

https://reviews.llvm.org/D95802

Files:
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp

Index: lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
===
--- lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
+++ lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
@@ -17,13 +17,15 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
 #include "Plugins/Process/Utility/lldb-arm-register-enums.h"
 #include "Plugins/Process/Utility/lldb-arm64-register-enums.h"
+#include "Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h"
+#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -398,3 +400,61 @@
 }
 
 #endif // defined(__aarch64__)
+
+#if defined(__mips64__)
+
+#define EXPECT_GPR_MIPS64(lldb_reg, fbsd_regno)\
+  EXPECT_THAT(GetRegParams(reg_ctx, gpr_##lldb_reg##_mips64),  \
+  ::testing::Pair(offsetof(reg, r_regs[fbsd_regno]),   \
+  sizeof(reg::r_regs[fbsd_regno])))
+
+TEST(RegisterContextFreeBSDTest, mips64) {
+  ArchSpec arch{"mips64-unknown-freebsd"};
+  RegisterContextFreeBSD_mips64 reg_ctx{arch};
+
+  // we can not use aliases from  because macros defined
+  // there are not namespaced and collide a lot, e.g. 'A1'
+
+  EXPECT_GPR_MIPS64(zero, 0);
+  EXPECT_GPR_MIPS64(r1, 1);
+  EXPECT_GPR_MIPS64(r2, 2);
+  EXPECT_GPR_MIPS64(r3, 3);
+  EXPECT_GPR_MIPS64(r4, 4);
+  EXPECT_GPR_MIPS64(r5, 5);
+  EXPECT_GPR_MIPS64(r6, 6);
+  EXPECT_GPR_MIPS64(r7, 7);
+  EXPECT_GPR_MIPS64(r8, 8);
+  EXPECT_GPR_MIPS64(r9, 9);
+  EXPECT_GPR_MIPS64(r10, 10);
+  EXPECT_GPR_MIPS64(r11, 11);
+  EXPECT_GPR_MIPS64(r12, 12);
+  EXPECT_GPR_MIPS64(r13, 13);
+  EXPECT_GPR_MIPS64(r14, 14);
+  EXPECT_GPR_MIPS64(r15, 15);
+  EXPECT_GPR_MIPS64(r16, 16);
+  EXPECT_GPR_MIPS64(r17, 17);
+  EXPECT_GPR_MIPS64(r18, 18);
+  EXPECT_GPR_MIPS64(r19, 19);
+  EXPECT_GPR_MIPS64(r20, 20);
+  EXPECT_GPR_MIPS64(r21, 21);
+  EXPECT_GPR_MIPS64(r22, 22);
+  EXPECT_GPR_MIPS64(r23, 23);
+  EXPECT_GPR_MIPS64(r24, 24);
+  EXPECT_GPR_MIPS64(r25, 25);
+  EXPECT_GPR_MIPS64(r26, 26);
+  EXPECT_GPR_MIPS64(r27, 27);
+  EXPECT_GPR_MIPS64(gp, 28);
+  EXPECT_GPR_MIPS64(sp, 29);
+  EXPECT_GPR_MIPS64(r30, 30);
+  EXPECT_GPR_MIPS64(ra, 31);
+  EXPECT_GPR_MIPS64(sr, 32);
+  EXPECT_GPR_MIPS64(mullo, 33);
+  EXPECT_GPR_MIPS64(mulhi, 34);
+  EXPECT_GPR_MIPS64(badvaddr, 35);
+  EXPECT_GPR_MIPS64(cause, 36);
+  EXPECT_GPR_MIPS64(pc, 37);
+  EXPECT_GPR_MIPS64(ic, 38);
+  EXPECT_GPR_MIPS64(dummy, 39);
+}
+
+#endif // defined(__mips64__)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -46,6 +46,11 @@
   if (!ret.Success())
 return ret;
   ret = NativeProcessFreeBSD::PtraceWrapper(PT_CLEARSTEP, GetID());
+  // we can get EINVAL if the architecture in question does not support
+  // hardware single-stepping -- that's fine, we have nothing to clear
+  // then
+  if (ret.GetError() == EINVAL)
+ret.Clear();
   if (ret.Success())
 SetRunning();
   return ret;
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.h
===
--- /dev/null
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.h
@@ -0,0 +1,70 @@
+//===-- NativeRegisterContextFreeBSD_mips64.h ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[Lldb-commits] [PATCH] D95802: [lldb] [Process/FreeBSDRemote] Introduce mips64 support

2021-02-01 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, emaste, labath.
Herald added subscribers: atanasyan, arichardson, sdardis.
mgorny requested review of this revision.

Introduce mips64 support to match the legacy FreeBSD plugin.  This
includes support for software single stepping that's in most part copied
from Linux.  The code explicitly ignores EINVAL from PT_CLEARSTEP
since this is easier to implement than checking whether hardware
single-stepping were used.

Similarly to the legacy plugin, the code does not support FPU registers
at the moment.  The support for them will be submitted separately
as it requires changes to the register context shared by both plugins.


https://reviews.llvm.org/D95802

Files:
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/CMakeLists.txt
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_mips64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp

Index: lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
===
--- lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
+++ lldb/unittests/Process/Utility/RegisterContextFreeBSDTest.cpp
@@ -17,13 +17,15 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
+#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
 #include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
 #include "Plugins/Process/Utility/lldb-arm-register-enums.h"
 #include "Plugins/Process/Utility/lldb-arm64-register-enums.h"
+#include "Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h"
+#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -398,3 +400,61 @@
 }
 
 #endif // defined(__aarch64__)
+
+#if defined(__mips64__)
+
+#define EXPECT_GPR_MIPS64(lldb_reg, fbsd_regno)\
+  EXPECT_THAT(GetRegParams(reg_ctx, gpr_##lldb_reg##_mips64),  \
+  ::testing::Pair(offsetof(reg, r_regs[fbsd_regno]),   \
+  sizeof(reg::r_regs[fbsd_regno])))
+
+TEST(RegisterContextFreeBSDTest, mips64) {
+  ArchSpec arch{"mips64-unknown-freebsd"};
+  RegisterContextFreeBSD_mips64 reg_ctx{arch};
+
+  // we can not use aliases from  because macros defined
+  // there are not namespaced and collide a lot, e.g. 'A1'
+
+  EXPECT_GPR_MIPS64(zero, 0);
+  EXPECT_GPR_MIPS64(r1, 1);
+  EXPECT_GPR_MIPS64(r2, 2);
+  EXPECT_GPR_MIPS64(r3, 3);
+  EXPECT_GPR_MIPS64(r4, 4);
+  EXPECT_GPR_MIPS64(r5, 5);
+  EXPECT_GPR_MIPS64(r6, 6);
+  EXPECT_GPR_MIPS64(r7, 7);
+  EXPECT_GPR_MIPS64(r8, 8);
+  EXPECT_GPR_MIPS64(r9, 9);
+  EXPECT_GPR_MIPS64(r10, 10);
+  EXPECT_GPR_MIPS64(r11, 11);
+  EXPECT_GPR_MIPS64(r12, 12);
+  EXPECT_GPR_MIPS64(r13, 13);
+  EXPECT_GPR_MIPS64(r14, 14);
+  EXPECT_GPR_MIPS64(r15, 15);
+  EXPECT_GPR_MIPS64(r16, 16);
+  EXPECT_GPR_MIPS64(r17, 17);
+  EXPECT_GPR_MIPS64(r18, 18);
+  EXPECT_GPR_MIPS64(r19, 19);
+  EXPECT_GPR_MIPS64(r20, 20);
+  EXPECT_GPR_MIPS64(r21, 21);
+  EXPECT_GPR_MIPS64(r22, 22);
+  EXPECT_GPR_MIPS64(r23, 23);
+  EXPECT_GPR_MIPS64(r24, 24);
+  EXPECT_GPR_MIPS64(r25, 25);
+  EXPECT_GPR_MIPS64(r26, 26);
+  EXPECT_GPR_MIPS64(r27, 27);
+  EXPECT_GPR_MIPS64(gp, 28);
+  EXPECT_GPR_MIPS64(sp, 29);
+  EXPECT_GPR_MIPS64(r30, 30);
+  EXPECT_GPR_MIPS64(ra, 31);
+  EXPECT_GPR_MIPS64(sr, 32);
+  EXPECT_GPR_MIPS64(mullo, 33);
+  EXPECT_GPR_MIPS64(mulhi, 34);
+  EXPECT_GPR_MIPS64(badvaddr, 35);
+  EXPECT_GPR_MIPS64(cause, 36);
+  EXPECT_GPR_MIPS64(pc, 37);
+  EXPECT_GPR_MIPS64(ic, 38);
+  EXPECT_GPR_MIPS64(dummy, 39);
+}
+
+#endif // defined(__mips64__)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
@@ -46,6 +46,11 @@
   if (!ret.Success())
 return ret;
   ret = NativeProcessFreeBSD::PtraceWrapper(PT_CLEARSTEP, GetID());
+  // we can get EINVAL if the architecture in question does not support
+  // hardware single-stepping -- that's fine, we have nothing to clear
+  // then
+  if (ret.GetError() == EINVAL)
+ret.Clear();
   if (ret.Success())
 SetRunning();
   return ret;
Index: 

[Lldb-commits] [PATCH] D95761: [lldb] Use current execution context in SBDebugger

2021-02-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I think it's fine to fall back to the "currently selected target" if the 
command interpreter doesn't have a current execution context, that should not 
be your first choice.

For instance, if you are running this command in a Python breakpoint callback, 
then the current Interpreter context will be set to the target/process/thread 
that the interpreter is running that command for, whereas the selected context 
will be whatever the user last selected, and may be for a totally different 
target/process/thread.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95761/new/

https://reviews.llvm.org/D95761

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


[Lldb-commits] [PATCH] D95712: [lldb/bindings] Add Python ScriptedProcess base class to lldb module

2021-02-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Can you add a test for this too? I assume I would look very similar to the 
example. Maybe have one that checks the base class and one that overrides it 
with some known values.




Comment at: lldb/bindings/python/python-scripted-process.swig:1
+%pythoncode %{
+from abc import ABC, abstractmethod

Does this have to be a SWIG file? I guess there's nothing really special about 
this file except that it should end up in the `lldb` module? 



Comment at: lldb/bindings/python/python-scripted-process.swig:22
+
+### Main funcitonnalities
+@abstractmethod

I don't think this adds much. I think it would be more valuable to have pydoc 
style comments on the methods. 



Comment at: lldb/bindings/python/python-scripted-process.swig:28
+@abstractmethod
+def get_memory_region_at_index(self, idx: int) -> lldb.SBMemoryRegionInfo:
+pass

Type annotations are Python 3 only. We've agreed to keep the bindings Python 2 
compatible until at least after the 13 release is cut. 
(https://lists.llvm.org/pipermail/lldb-dev/2020-August/016388.html)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95712/new/

https://reviews.llvm.org/D95712

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


[Lldb-commits] [PATCH] D95711: [lldb/Interpreter] Add ScriptInterpreter Wrapper for ScriptedProcess

2021-02-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/API/SBData.h:129
 
+  lldb::DataExtractorSP GetOpaque() const;
+

You cannot expose non-SB classes in public methods because that would make them 
part of the API. 



Comment at: lldb/include/lldb/Interpreter/ScriptInterpreter.h:531
 
+#pragma mark ScriptedProcessInterface
+

Please use Doxygen groups for this so everyone can benefit from it and not just 
a single IDE. 

```
/// ScriptedProcessInterface
/// @{
...
/// @}
```



Comment at: lldb/include/lldb/Interpreter/ScriptInterpreter.h:534
+  virtual StructuredData::GenericSP
+  ScriptedProcess_CreatePluginObject(const char *class_name,
+ lldb::TargetSP target_sp,

It doesn't seem like these methods belong in ScriptInterpreter. Can they go 
into their own class of which the ScriptInterpreter holds a single instance? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95711/new/

https://reviews.llvm.org/D95711

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


[Lldb-commits] [PATCH] D93939: [elf-core] Improve reading memory from core file

2021-02-01 Thread Djordje Todorovic via Phabricator via lldb-commits
djtodoro updated this revision to Diff 320483.
djtodoro added a comment.

- Test update


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93939/new/

https://reviews.llvm.org/D93939

Files:
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py


Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
===
--- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -155,6 +155,24 @@
 self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions,
  "a.out")
 
+
+@skipIf(triple='^mips')
+@skipIfLLVMTargetMissing("X86")
+@skipIfWindows
+@skipIfReproducer
+def test_read_memory(self):
+"""Test that we are able to read as many bytes as available"""
+target = self.dbg.CreateTarget("linux-x86_64.out")
+process = target.LoadCore("linux-x86_64.core")
+self.assertTrue(process, PROCESS_IS_VALID)
+
+error = lldb.SBError()
+bytesread = process.ReadMemory(0x400ff0, 20, error)
+
+# read only 16 bytes without zero bytes filling
+self.assertEqual(len(bytesread), 16)
+self.dbg.DeleteTarget(target)
+
 @skipIf(triple='^mips')
 @skipIfLLVMTargetMissing("X86")
 def test_FPR_SSE(self):
Index: lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -353,7 +353,6 @@
   const lldb::addr_t file_end = address_range->data.GetRangeEnd();
   size_t bytes_to_read = size; // Number of bytes to read from the core file
   size_t bytes_copied = 0;   // Number of bytes actually read from the core 
file
-  size_t zero_fill_size = 0; // Padding
   lldb::addr_t bytes_left =
   0; // Number of bytes available in the core file from the given address
 
@@ -367,24 +366,15 @@
   if (file_end > file_start + offset)
 bytes_left = file_end - (file_start + offset);
 
-  // Figure out how many bytes we need to zero-fill if we are reading more
-  // bytes than available in the on-disk segment
-  if (bytes_to_read > bytes_left) {
-zero_fill_size = bytes_to_read - bytes_left;
+  if (bytes_to_read > bytes_left)
 bytes_to_read = bytes_left;
-  }
 
   // If there is data available on the core file read it
   if (bytes_to_read)
 bytes_copied =
 core_objfile->CopyData(offset + file_start, bytes_to_read, buf);
 
-  assert(zero_fill_size <= size);
-  // Pad remaining bytes
-  if (zero_fill_size)
-memset(((char *)buf) + bytes_copied, 0, zero_fill_size);
-
-  return bytes_copied + zero_fill_size;
+  return bytes_copied;
 }
 
 void ProcessElfCore::Clear() {


Index: lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
===
--- lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -155,6 +155,24 @@
 self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions,
  "a.out")
 
+
+@skipIf(triple='^mips')
+@skipIfLLVMTargetMissing("X86")
+@skipIfWindows
+@skipIfReproducer
+def test_read_memory(self):
+"""Test that we are able to read as many bytes as available"""
+target = self.dbg.CreateTarget("linux-x86_64.out")
+process = target.LoadCore("linux-x86_64.core")
+self.assertTrue(process, PROCESS_IS_VALID)
+
+error = lldb.SBError()
+bytesread = process.ReadMemory(0x400ff0, 20, error)
+
+# read only 16 bytes without zero bytes filling
+self.assertEqual(len(bytesread), 16)
+self.dbg.DeleteTarget(target)
+
 @skipIf(triple='^mips')
 @skipIfLLVMTargetMissing("X86")
 def test_FPR_SSE(self):
Index: lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -353,7 +353,6 @@
   const lldb::addr_t file_end = address_range->data.GetRangeEnd();
   size_t bytes_to_read = size; // Number of bytes to read from the core file
   size_t bytes_copied = 0;   // Number of bytes actually read from the core file
-  size_t zero_fill_size = 0; // Padding
   lldb::addr_t bytes_left =
   0; // Number of bytes available in the core file from the given address
 
@@ -367,24 +366,15 @@
   if (file_end > file_start + offset)
 bytes_left = file_end - (file_start + offset);
 
-  // Figure out how many bytes we need to zero-fill if we are reading more
-  // bytes than available in the on-disk segment
-  if 

[Lldb-commits] [PATCH] D93939: [elf-core] Improve reading memory from core file

2021-02-01 Thread Djordje Todorovic via Phabricator via lldb-commits
djtodoro added a comment.

> Another option would be to ditch disassembling, and check this via memory 
> reads, as that is what you are actually fixing

+1, nice! thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93939/new/

https://reviews.llvm.org/D93939

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


[Lldb-commits] [lldb] ee562e2 - [lldb/test] Skip `SBTarget::IsLoaded` test on windows (NFC)

2021-02-01 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-02-01T14:09:50+01:00
New Revision: ee562e2315cfe339fdcb0cb9b2122284bbeda29b

URL: 
https://github.com/llvm/llvm-project/commit/ee562e2315cfe339fdcb0cb9b2122284bbeda29b
DIFF: 
https://github.com/llvm/llvm-project/commit/ee562e2315cfe339fdcb0cb9b2122284bbeda29b.diff

LOG: [lldb/test] Skip `SBTarget::IsLoaded` test on windows (NFC)

This patch skips the test for the SBTarget::IsLoaded method on windows
since the logic is different.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/test/API/python_api/target/TestTargetAPI.py

Removed: 




diff  --git a/lldb/test/API/python_api/target/TestTargetAPI.py 
b/lldb/test/API/python_api/target/TestTargetAPI.py
index c444b44f04eb..ae9ff126b7b4 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -491,6 +491,7 @@ def test_default_arch(self):
 
 
 @add_test_categories(['pyapi'])
+@skipIfWindows
 def test_is_loaded(self):
 """Exercise SBTarget.IsLoaded(SBModule&) API."""
 d = {'EXE': 'b.out'}



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


[Lldb-commits] [PATCH] D95761: [lldb] Use current execution context in SBDebugger

2021-02-01 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG754ab803b8dc: [lldb] Use current execution context in 
SBDebugger (authored by werat, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95761/new/

https://reviews.llvm.org/D95761

Files:
  lldb/source/API/SBDebugger.cpp
  lldb/test/API/python_api/debugger/TestDebuggerAPI.py


Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,35 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+@add_test_categories(['pyapi'])
+def test_debugger_internal_variables(self):
+debugger_name = self.dbg.GetInstanceName()
+
+# Set a variable and check it was written successfully.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'no-dynamic-values', debugger_name)
+self.assertTrue(error.Success())
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-dynamic-values')
+
+# Set a variable with a different value.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'no-run-target', debugger_name)
+self.assertTrue(error.Success())
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target')
+
+# Try setting invalid value, check for error.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'dummy-value', debugger_name)
+self.assertTrue(error.Fail())
+# Check that the value didn't change.
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target')
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -1278,8 +1278,7 @@
   ConstString(debugger_instance_name)));
   Status error;
   if (debugger_sp) {
-ExecutionContext exe_ctx(
-debugger_sp->GetCommandInterpreter().GetExecutionContext());
+ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext());
 error = debugger_sp->SetPropertyValue(_ctx, eVarSetOperationAssign,
   var_name, value);
   } else {
@@ -1303,8 +1302,7 @@
   ConstString(debugger_instance_name)));
   Status error;
   if (debugger_sp) {
-ExecutionContext exe_ctx(
-debugger_sp->GetCommandInterpreter().GetExecutionContext());
+ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext());
 lldb::OptionValueSP value_sp(
 debugger_sp->GetPropertyValue(_ctx, var_name, false, error));
 if (value_sp) {


Index: lldb/test/API/python_api/debugger/TestDebuggerAPI.py
===
--- lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,35 @@
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+@add_test_categories(['pyapi'])
+def test_debugger_internal_variables(self):
+debugger_name = self.dbg.GetInstanceName()
+
+# Set a variable and check it was written successfully.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'no-dynamic-values', debugger_name)
+self.assertTrue(error.Success())
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-dynamic-values')
+
+# Set a variable with a different value.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'no-run-target', debugger_name)
+self.assertTrue(error.Success())
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target')
+
+# Try setting invalid value, check for error.
+error = 

[Lldb-commits] [lldb] 754ab80 - [lldb] Use current execution context in SBDebugger

2021-02-01 Thread Raphael Isemann via lldb-commits

Author: Andy Yankovsky
Date: 2021-02-01T13:12:42+01:00
New Revision: 754ab803b8dc659e3645d369d1b5d6d2f97be29e

URL: 
https://github.com/llvm/llvm-project/commit/754ab803b8dc659e3645d369d1b5d6d2f97be29e
DIFF: 
https://github.com/llvm/llvm-project/commit/754ab803b8dc659e3645d369d1b5d6d2f97be29e.diff

LOG: [lldb] Use current execution context in SBDebugger

Use `GetSelectedExecutionContext()` instead of
`GetCommandInterpreter().GetExecutionContext()` in
`SBDebugger::GetInternalVariableValue/SBDebugger::SetInternalVariable`. The
execution context in the command interpreter might be empty, if no commands has
been executed yet (it is updated only when handling commands or completions --
e.g.
https://github.com/llvm/llvm-project/blob/main/lldb/source/Interpreter/CommandInterpreter.cpp#L1855).

Reviewed By: teemperor

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

Added: 


Modified: 
lldb/source/API/SBDebugger.cpp
lldb/test/API/python_api/debugger/TestDebuggerAPI.py

Removed: 




diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 6245b3a83565..e3d2e4728a87 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1278,8 +1278,7 @@ SBError SBDebugger::SetInternalVariable(const char 
*var_name, const char *value,
   ConstString(debugger_instance_name)));
   Status error;
   if (debugger_sp) {
-ExecutionContext exe_ctx(
-debugger_sp->GetCommandInterpreter().GetExecutionContext());
+ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext());
 error = debugger_sp->SetPropertyValue(_ctx, eVarSetOperationAssign,
   var_name, value);
   } else {
@@ -1303,8 +1302,7 @@ SBDebugger::GetInternalVariableValue(const char *var_name,
   ConstString(debugger_instance_name)));
   Status error;
   if (debugger_sp) {
-ExecutionContext exe_ctx(
-debugger_sp->GetCommandInterpreter().GetExecutionContext());
+ExecutionContext exe_ctx(debugger_sp->GetSelectedExecutionContext());
 lldb::OptionValueSP value_sp(
 debugger_sp->GetPropertyValue(_ctx, var_name, false, error));
 if (value_sp) {

diff  --git a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py 
b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
index 32202acbe072..5d0311eb1b0c 100644
--- a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -43,3 +43,35 @@ def test_debugger_delete_invalid_target(self):
 target = lldb.SBTarget()
 self.assertFalse(target.IsValid())
 self.dbg.DeleteTarget(target)
+
+@add_test_categories(['pyapi'])
+def test_debugger_internal_variables(self):
+debugger_name = self.dbg.GetInstanceName()
+
+# Set a variable and check it was written successfully.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'no-dynamic-values', debugger_name)
+self.assertTrue(error.Success())
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-dynamic-values')
+
+# Set a variable with a 
diff erent value.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'no-run-target', debugger_name)
+self.assertTrue(error.Success())
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target')
+
+# Try setting invalid value, check for error.
+error = lldb.SBDebugger.SetInternalVariable(
+'target.prefer-dynamic-value', 'dummy-value', debugger_name)
+self.assertTrue(error.Fail())
+# Check that the value didn't change.
+ret = lldb.SBDebugger.GetInternalVariableValue(
+'target.prefer-dynamic-value', debugger_name)
+self.assertEqual(ret.GetSize(), 1)
+self.assertEqual(ret.GetStringAtIndex(0), 'no-run-target')



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


[Lldb-commits] [lldb] 11e74e5 - [lldb] Remove a stray semicolon, fixing GCC warnings. NFC.

2021-02-01 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2021-02-01T13:45:07+02:00
New Revision: 11e74e512d64ae2a2531156b6f0dde211b1ae19d

URL: 
https://github.com/llvm/llvm-project/commit/11e74e512d64ae2a2531156b6f0dde211b1ae19d
DIFF: 
https://github.com/llvm/llvm-project/commit/11e74e512d64ae2a2531156b6f0dde211b1ae19d.diff

LOG: [lldb] Remove a stray semicolon, fixing GCC warnings. NFC.

Added: 


Modified: 
lldb/tools/lldb-vscode/FifoFiles.cpp

Removed: 




diff  --git a/lldb/tools/lldb-vscode/FifoFiles.cpp 
b/lldb/tools/lldb-vscode/FifoFiles.cpp
index 0a36c87d4a94..d56f88085abd 100644
--- a/lldb/tools/lldb-vscode/FifoFiles.cpp
+++ b/lldb/tools/lldb-vscode/FifoFiles.cpp
@@ -33,7 +33,7 @@ FifoFile::~FifoFile() {
 #if LLVM_ON_UNIX
   unlink(m_path.c_str());
 #endif
-};
+}
 
 Expected> CreateFifoFile(StringRef path) {
 #if !LLVM_ON_UNIX



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


[Lldb-commits] [PATCH] D95761: [lldb] Use current execution context in SBDebugger

2021-02-01 Thread Andy Yankovsky via Phabricator via lldb-commits
werat added a comment.

Thanks for the review! Can you submit it for me, since I don't have commit 
access?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95761/new/

https://reviews.llvm.org/D95761

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


[Lldb-commits] [PATCH] D95686: [lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

2021-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib closed this revision.
mib marked 3 inline comments as done.
mib added a comment.

Landed in b8923c002207da449ec462ade468e27a651b1f91 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95686/new/

https://reviews.llvm.org/D95686

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


[Lldb-commits] [lldb] b8923c0 - [lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

2021-02-01 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-02-01T12:16:33+01:00
New Revision: b8923c002207da449ec462ade468e27a651b1f91

URL: 
https://github.com/llvm/llvm-project/commit/b8923c002207da449ec462ade468e27a651b1f91
DIFF: 
https://github.com/llvm/llvm-project/commit/b8923c002207da449ec462ade468e27a651b1f91.diff

LOG: [lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

This patch adds an `SBTarget::IsLoaded(const SBModule&) const` endpoint
to lldb's Scripting Bridge API. As the name suggests, it will allow the
user to know if the module is loaded in a specific target.

rdar://37957625

Differential Review: https://reviews.llvm.org/D95686

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/bindings/interface/SBTarget.i
lldb/include/lldb/API/SBTarget.h
lldb/source/API/SBTarget.cpp
lldb/test/API/python_api/target/TestTargetAPI.py

Removed: 




diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index f874726b42d8..772ee1a2eb73 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -938,6 +938,16 @@ public:
 lldb::addr_t
 GetStackRedZoneSize();
 
+%feature("docstring", "
+Returns true if the module has been loaded in this `SBTarget`.
+A module can be loaded either by the dynamic loader or by being manually
+added to the target (see `SBTarget.AddModule` and the `target module add` 
command).
+
+:rtype: bool
+") IsLoaded;
+bool
+IsLoaded (const lldb::SBModule ) const;
+
 lldb::SBLaunchInfo
 GetLaunchInfo () const;
 

diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index 30f4005dfc0f..f427404ac1ff 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -834,6 +834,8 @@ class LLDB_API SBTarget {
 
   lldb::addr_t GetStackRedZoneSize();
 
+  bool IsLoaded(const lldb::SBModule ) const;
+
   lldb::SBLaunchInfo GetLaunchInfo() const;
 
   void SetLaunchInfo(const lldb::SBLaunchInfo _info);

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 6128c04de32b..72702b9b6a7b 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -2410,6 +2410,21 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() {
   return 0;
 }
 
+bool SBTarget::IsLoaded(const SBModule ) const {
+  LLDB_RECORD_METHOD_CONST(bool, SBTarget, IsLoaded, (const lldb::SBModule &),
+   module);
+
+  TargetSP target_sp(GetSP());
+  if (!target_sp)
+return LLDB_RECORD_RESULT(false);
+
+  ModuleSP module_sp(module.GetSP());
+  if (!module_sp)
+return LLDB_RECORD_RESULT(false);
+
+  return LLDB_RECORD_RESULT(module_sp->IsLoadedInTarget(target_sp.get()));
+}
+
 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, 
GetLaunchInfo);
 
@@ -2682,6 +2697,8 @@ void RegisterMethods(Registry ) {
   LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
(const char *, const lldb::SBExpressionOptions &));
   LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
+  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded,
+ (const lldb::SBModule &));
   LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
   LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
(const lldb::SBLaunchInfo &));

diff  --git a/lldb/test/API/python_api/target/TestTargetAPI.py 
b/lldb/test/API/python_api/target/TestTargetAPI.py
index 12c9d9d59aed..c444b44f04eb 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -489,3 +489,27 @@ def test_default_arch(self):
 target3 = self.dbg.CreateTargetWithFileAndTargetTriple(exe, 
target.GetTriple())
 self.assertTrue(target3.IsValid())
 
+
+@add_test_categories(['pyapi'])
+def test_is_loaded(self):
+"""Exercise SBTarget.IsLoaded(SBModule&) API."""
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+
+self.assertFalse(target.IsLoaded(lldb.SBModule()))
+
+num_modules = target.GetNumModules()
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertFalse(target.IsLoaded(module), "Target that isn't "
+ "running shouldn't have any module loaded.")
+
+process = target.LaunchSimple(None, None,
+  self.get_process_working_directory())
+
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertTrue(target.IsLoaded(module), "Running the target 
should "
+"have loaded its modules.")


  

[Lldb-commits] [PATCH] D95761: [lldb] Use current execution context in SBDebugger

2021-02-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95761/new/

https://reviews.llvm.org/D95761

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


[Lldb-commits] [lldb] 94fac81 - [Branch-Rename] Fix some links

2021-02-01 Thread via lldb-commits

Author: xgupta
Date: 2021-02-01T16:43:21+05:30
New Revision: 94fac81fccfef9917e94bed398781744fb82e159

URL: 
https://github.com/llvm/llvm-project/commit/94fac81fccfef9917e94bed398781744fb82e159
DIFF: 
https://github.com/llvm/llvm-project/commit/94fac81fccfef9917e94bed398781744fb82e159.diff

LOG: [Branch-Rename] Fix some links

According to the [[ https://foundation.llvm.org/docs/branch-rename/ | status of 
branch rename ]], the master branch of the LLVM repository is removed on 28 Jan 
2021.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
clang-tools-extra/clangd/README.md
clang-tools-extra/docs/clang-rename.rst
clang-tools-extra/docs/clang-tidy/Contributing.rst
clang-tools-extra/docs/clang-tidy/Integrations.rst
clang/docs/ClangPlugins.rst
clang/docs/ClangTools.rst
clang/docs/ControlFlowIntegrityDesign.rst
clang/docs/InternalsManual.rst
clang/docs/LibTooling.rst
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/www/analyzer/checker_dev_manual.html
clang/www/analyzer/open_projects.html
clang/www/hacking.html
clang/www/menu.html.incl
compiler-rt/include/sanitizer/tsan_interface_atomic.h
compiler-rt/lib/tsan/rtl/tsan_interface.h
compiler-rt/www/menu.html.incl
flang/README.md
flang/docs/_templates/indexsidebar.html
flang/docs/flang-c-style.el
libcxx/docs/index.rst
libcxx/www/atomic_design.html
libcxx/www/atomic_design_a.html
libcxx/www/atomic_design_b.html
libcxx/www/atomic_design_c.html
libcxx/www/index.html
libcxx/www/ts1z_status.html
libcxx/www/type_traits_design.html
libcxx/www/upcoming_meeting.html
libcxxabi/www/index.html
libunwind/docs/index.rst
lldb/docs/resources/build.rst
lldb/docs/resources/test.rst
lldb/docs/use/python-reference.rst
llvm/docs/Vectorizers.rst
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
llvm/utils/lit/setup.py
mlir/docs/DeclarativeRewrites.md
mlir/docs/Dialects/SPIR-V.md
mlir/docs/Dialects/Vector.md
mlir/docs/OpDefinitions.md
mlir/docs/PatternRewriter.md
mlir/docs/Rationale/RationaleGenericDAGRewriter.md
mlir/docs/SPIRVToLLVMDialectConversion.md
mlir/docs/ShapeInference.md
mlir/docs/Tutorials/UnderstandingTheIRStructure.md
openmp/www/index.html
polly/www/menu.html.incl

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h 
b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
index a9989ee51bcf..eb2b2bfcc6aa 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@ namespace google {
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// 
https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/google-readability-avoid-underscore-in-googletest-name.html

diff  --git a/clang-tools-extra/clangd/README.md 
b/clang-tools-extra/clangd/README.md
index 3ef9174c9529..c5ed07195060 100644
--- a/clang-tools-extra/clangd/README.md
+++ b/clang-tools-extra/clangd/README.md
@@ -5,7 +5,7 @@ This is not its documentation.
 
 - the **website** is https://clangd.llvm.org/.
 - the **bug tracker** is https://github.com/clangd/clangd/issues
-- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clangd.
+- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clangd.
 - the **website source code** is at https://github.com/llvm/clangd-www/
 
 ### Communication channels

diff  --git a/clang-tools-extra/docs/clang-rename.rst 
b/clang-tools-extra/docs/clang-rename.rst
index b45ba01c06a2..e797c9bafe8a 100644
--- a/clang-tools-extra/docs/clang-rename.rst
+++ b/clang-tools-extra/docs/clang-rename.rst
@@ -142,7 +142,7 @@ Vim Integration
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
 `clang/tools/clang-rename/clang-rename.py
-`_.
+`_.
 
 Please note that **you have to save all buffers, in which the replacement will
 

[Lldb-commits] [PATCH] D95686: [lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

2021-02-01 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

some minor things in the comments, otherwise LGTM




Comment at: lldb/bindings/interface/SBTarget.i:946
+
+:param module: `SBModule` that should be loaded in this `SBTarget`.
+:rtype: bool

That sounds like the function loads the module. I think we can just leave this 
out as this function has only one parameter and the description makes it clear 
what this parameter is.



Comment at: lldb/test/API/python_api/target/TestTargetAPI.py:514
+module = target.GetModuleAtIndex(i)
+self.assertTrue(target.IsLoaded(module), "Module should be loaded "
+"in target.")

"Running the target should have loaded its modules"



Comment at: lldb/test/API/python_api/target/TestTargetAPI.py:506
+module = target.GetModuleAtIndex(i)
+self.assertFalse(target.IsLoaded(module), "Module should not be "
+ "loaded in target.")

I think the assert message could describe why this is being checked (target 
that hasn't been launched doesn't have anything loaded)

`selft.assertFalse(..., "Target that isn't running shouldn't have any modules 
loaded"``


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95686/new/

https://reviews.llvm.org/D95686

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


[Lldb-commits] [PATCH] D95686: [lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

2021-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 320425.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95686/new/

https://reviews.llvm.org/D95686

Files:
  lldb/bindings/interface/SBTarget.i
  lldb/include/lldb/API/SBTarget.h
  lldb/source/API/SBTarget.cpp
  lldb/test/API/python_api/target/TestTargetAPI.py

Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -489,3 +489,27 @@
 target3 = self.dbg.CreateTargetWithFileAndTargetTriple(exe, target.GetTriple())
 self.assertTrue(target3.IsValid())
 
+
+@add_test_categories(['pyapi'])
+def test_is_loaded(self):
+"""Exercise SBTarget.IsLoaded(SBModule&) API."""
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+
+self.assertFalse(target.IsLoaded(lldb.SBModule()))
+
+num_modules = target.GetNumModules()
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertFalse(target.IsLoaded(module), "Target that isn't "
+ "running shouldn't have loaded modules.")
+
+process = target.LaunchSimple(None, None,
+  self.get_process_working_directory())
+
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertTrue(target.IsLoaded(module), "Module should be loaded "
+"in target.")
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -2410,6 +2410,21 @@
   return 0;
 }
 
+bool SBTarget::IsLoaded(const SBModule ) const {
+  LLDB_RECORD_METHOD_CONST(bool, SBTarget, IsLoaded, (const lldb::SBModule &),
+   module);
+
+  TargetSP target_sp(GetSP());
+  if (!target_sp)
+return LLDB_RECORD_RESULT(false);
+
+  ModuleSP module_sp(module.GetSP());
+  if (!module_sp)
+return LLDB_RECORD_RESULT(false);
+
+  return LLDB_RECORD_RESULT(module_sp->IsLoadedInTarget(target_sp.get()));
+}
+
 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
 
@@ -2682,6 +2697,8 @@
   LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
(const char *, const lldb::SBExpressionOptions &));
   LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
+  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded,
+ (const lldb::SBModule &));
   LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
   LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
(const lldb::SBLaunchInfo &));
Index: lldb/include/lldb/API/SBTarget.h
===
--- lldb/include/lldb/API/SBTarget.h
+++ lldb/include/lldb/API/SBTarget.h
@@ -834,6 +834,8 @@
 
   lldb::addr_t GetStackRedZoneSize();
 
+  bool IsLoaded(const lldb::SBModule ) const;
+
   lldb::SBLaunchInfo GetLaunchInfo() const;
 
   void SetLaunchInfo(const lldb::SBLaunchInfo _info);
Index: lldb/bindings/interface/SBTarget.i
===
--- lldb/bindings/interface/SBTarget.i
+++ lldb/bindings/interface/SBTarget.i
@@ -938,6 +938,17 @@
 lldb::addr_t
 GetStackRedZoneSize();
 
+%feature("docstring", "
+Returns true if the module has been loaded in this `SBTarget`.
+A module can be loaded either by the dynamic loader or by being manually
+added to the target (see `SBTarget.AddModule` and the `target module add` command).
+
+:param module: `SBModule` that should be loaded in this `SBTarget`.
+:rtype: bool
+") IsLoaded;
+bool
+IsLoaded (const lldb::SBModule ) const;
+
 lldb::SBLaunchInfo
 GetLaunchInfo () const;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D95686: [lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

2021-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 320424.
mib added a comment.

Add positive test case and update assert message to be more descriptive.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95686/new/

https://reviews.llvm.org/D95686

Files:
  lldb/bindings/interface/SBTarget.i
  lldb/include/lldb/API/SBTarget.h
  lldb/source/API/SBTarget.cpp
  lldb/test/API/python_api/target/TestTargetAPI.py

Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -489,3 +489,27 @@
 target3 = self.dbg.CreateTargetWithFileAndTargetTriple(exe, target.GetTriple())
 self.assertTrue(target3.IsValid())
 
+
+@add_test_categories(['pyapi'])
+def test_is_loaded(self):
+"""Exercise SBTarget.IsLoaded(SBModule&) API."""
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+
+self.assertFalse(target.IsLoaded(lldb.SBModule()))
+
+num_modules = target.GetNumModules()
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertFalse(target.IsLoaded(module), "Target that isn't
+ "running shouldn't have loaded modules.")
+
+process = target.LaunchSimple(None, None,
+  self.get_process_working_directory())
+
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertTrue(target.IsLoaded(module), "Module should be loaded "
+"in target.")
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -2410,6 +2410,21 @@
   return 0;
 }
 
+bool SBTarget::IsLoaded(const SBModule ) const {
+  LLDB_RECORD_METHOD_CONST(bool, SBTarget, IsLoaded, (const lldb::SBModule &),
+   module);
+
+  TargetSP target_sp(GetSP());
+  if (!target_sp)
+return LLDB_RECORD_RESULT(false);
+
+  ModuleSP module_sp(module.GetSP());
+  if (!module_sp)
+return LLDB_RECORD_RESULT(false);
+
+  return LLDB_RECORD_RESULT(module_sp->IsLoadedInTarget(target_sp.get()));
+}
+
 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
 
@@ -2682,6 +2697,8 @@
   LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
(const char *, const lldb::SBExpressionOptions &));
   LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
+  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded,
+ (const lldb::SBModule &));
   LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
   LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
(const lldb::SBLaunchInfo &));
Index: lldb/include/lldb/API/SBTarget.h
===
--- lldb/include/lldb/API/SBTarget.h
+++ lldb/include/lldb/API/SBTarget.h
@@ -834,6 +834,8 @@
 
   lldb::addr_t GetStackRedZoneSize();
 
+  bool IsLoaded(const lldb::SBModule ) const;
+
   lldb::SBLaunchInfo GetLaunchInfo() const;
 
   void SetLaunchInfo(const lldb::SBLaunchInfo _info);
Index: lldb/bindings/interface/SBTarget.i
===
--- lldb/bindings/interface/SBTarget.i
+++ lldb/bindings/interface/SBTarget.i
@@ -938,6 +938,17 @@
 lldb::addr_t
 GetStackRedZoneSize();
 
+%feature("docstring", "
+Returns true if the module has been loaded in this `SBTarget`.
+A module can be loaded either by the dynamic loader or by being manually
+added to the target (see `SBTarget.AddModule` and the `target module add` command).
+
+:param module: `SBModule` that should be loaded in this `SBTarget`.
+:rtype: bool
+") IsLoaded;
+bool
+IsLoaded (const lldb::SBModule ) const;
+
 lldb::SBLaunchInfo
 GetLaunchInfo () const;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D95686: [lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

2021-02-01 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 320420.
mib edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95686/new/

https://reviews.llvm.org/D95686

Files:
  lldb/bindings/interface/SBTarget.i
  lldb/include/lldb/API/SBTarget.h
  lldb/source/API/SBTarget.cpp
  lldb/test/API/python_api/target/TestTargetAPI.py

Index: lldb/test/API/python_api/target/TestTargetAPI.py
===
--- lldb/test/API/python_api/target/TestTargetAPI.py
+++ lldb/test/API/python_api/target/TestTargetAPI.py
@@ -489,3 +489,27 @@
 target3 = self.dbg.CreateTargetWithFileAndTargetTriple(exe, target.GetTriple())
 self.assertTrue(target3.IsValid())
 
+
+@add_test_categories(['pyapi'])
+def test_is_loaded(self):
+"""Exercise SBTarget.IsLoaded(SBModule&) API."""
+d = {'EXE': 'b.out'}
+self.build(dictionary=d)
+self.setTearDownCleanup(dictionary=d)
+target = self.create_simple_target('b.out')
+
+self.assertFalse(target.IsLoaded(lldb.SBModule()))
+
+num_modules = target.GetNumModules()
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertFalse(target.IsLoaded(module), "Module should not be "
+ "loaded in target.")
+
+process = target.LaunchSimple(None, None,
+  self.get_process_working_directory())
+
+for i in range(num_modules):
+module = target.GetModuleAtIndex(i)
+self.assertTrue(target.IsLoaded(module), "Module should not be "
+ "loaded in target.")
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -2410,6 +2410,21 @@
   return 0;
 }
 
+bool SBTarget::IsLoaded(const SBModule ) const {
+  LLDB_RECORD_METHOD_CONST(bool, SBTarget, IsLoaded, (const lldb::SBModule &),
+   module);
+
+  TargetSP target_sp(GetSP());
+  if (!target_sp)
+return LLDB_RECORD_RESULT(false);
+
+  ModuleSP module_sp(module.GetSP());
+  if (!module_sp)
+return LLDB_RECORD_RESULT(false);
+
+  return LLDB_RECORD_RESULT(module_sp->IsLoadedInTarget(target_sp.get()));
+}
+
 lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
 
@@ -2682,6 +2697,8 @@
   LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
(const char *, const lldb::SBExpressionOptions &));
   LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
+  LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded,
+ (const lldb::SBModule &));
   LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
   LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
(const lldb::SBLaunchInfo &));
Index: lldb/include/lldb/API/SBTarget.h
===
--- lldb/include/lldb/API/SBTarget.h
+++ lldb/include/lldb/API/SBTarget.h
@@ -834,6 +834,8 @@
 
   lldb::addr_t GetStackRedZoneSize();
 
+  bool IsLoaded(const lldb::SBModule ) const;
+
   lldb::SBLaunchInfo GetLaunchInfo() const;
 
   void SetLaunchInfo(const lldb::SBLaunchInfo _info);
Index: lldb/bindings/interface/SBTarget.i
===
--- lldb/bindings/interface/SBTarget.i
+++ lldb/bindings/interface/SBTarget.i
@@ -938,6 +938,17 @@
 lldb::addr_t
 GetStackRedZoneSize();
 
+%feature("docstring", "
+Returns true if the module has been loaded in this `SBTarget`.
+A module can be loaded either by the dynamic loader or by being manually
+added to the target (see `SBTarget.AddModule` and the `target module add` command).
+
+:param module: `SBModule` that should be loaded in this `SBTarget`.
+:rtype: bool
+") IsLoaded;
+bool
+IsLoaded (const lldb::SBModule ) const;
+
 lldb::SBLaunchInfo
 GetLaunchInfo () const;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2939d2e - [lldb][docs] Attempt to disable the generated GitHub button on the LLDB website

2021-02-01 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-02-01T09:47:39+01:00
New Revision: 2939d2e1b46c05432864db333ca3d5cb7ab83533

URL: 
https://github.com/llvm/llvm-project/commit/2939d2e1b46c05432864db333ca3d5cb7ab83533
DIFF: 
https://github.com/llvm/llvm-project/commit/2939d2e1b46c05432864db333ca3d5cb7ab83533.diff

LOG: [lldb][docs] Attempt to disable the generated GitHub button on the LLDB 
website

For unknown reasons the alabaster theme on the docs server is always generating
a GitHub link in the side bar. Beside the privacy problems of having an iframe
to some third-party service, we never configured any GitHub integration so
this button just links to the GitHub main site.

The button generation should be disabled by default, but as that's apparently
not true in the alabaster theme on the server, this patch tries working around
the issue by just explicitly turning off the GitHub integration.

Added: 


Modified: 
lldb/docs/conf.py

Removed: 




diff  --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index b9b94672cbde..d55aad2bcff7 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -130,7 +130,9 @@
 # further.  For a list of options available for each theme, see the
 # documentation.
 html_theme_options = {
-'font_size': '11pt'
+'font_size': '11pt',
+# Don't generate any links to GitHub.
+'github_button' : 'false',
 }
 
 # Add any paths that contain custom themes here, relative to this directory.



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