[Lldb-commits] [PATCH] D92187: [lldb] [POSIX-DYLD] Add libraries from initial rendezvous brkpt hit

2020-12-14 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D92187#2451013 , @mgorny wrote:

> In D92187#2450976 , @labath wrote:
>
>> In D92187#2450526 , @mgorny wrote:
>>
>>> Another fix: we should only unload duplicate ld.so if it's actually a 
>>> duplicate, i.e. the path differs. Otherwise, we've ended up unloading the 
>>> only copy.
>>
>> Would comparing the module shared_pointers work? I think that's exactly what 
>> we want here. I think it's possible for `LoadModuleAtAddress` to return the 
>> same module, even with paths which don't match exactly. But if it does that, 
>> then we will still end up unloading the original interpreter module...
>
> How do you suggest we get the shared pointer for comparison? Store in class 
> instance, or search for it somehow?

Store in the class (probably as a weak_ptr), just like you did with the path


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

https://reviews.llvm.org/D92187

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


[Lldb-commits] [PATCH] D92187: [lldb] [POSIX-DYLD] Add libraries from initial rendezvous brkpt hit

2020-12-14 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 311552.
mgorny added a comment.

Compare using weak_ptr to the interpreter module.


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

https://reviews.llvm.org/D92187

Files:
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/test/API/api/multithreaded/TestMultithreaded.py
  
lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
  lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
  lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
  
lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
  lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test

Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -3,7 +3,6 @@
 
 # REQUIRES: target-x86_64
 # UNSUPPORTED: system-windows
-# XFAIL: system-freebsd
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
Index: lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
===
--- lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
+++ lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
@@ -120,7 +120,7 @@
 
 @llgs_test
 @skipUnlessPlatform(["linux", "android", "freebsd", "netbsd"])
-@expectedFailureAll(oslist=["freebsd", "netbsd"])
+@expectedFailureNetBSD
 def test_libraries_svr4_load_addr(self):
 self.setup_test()
 self.libraries_svr4_has_correct_load_addr()
Index: lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
===
--- lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -843,7 +843,6 @@
 self.qMemoryRegionInfo_is_supported()
 
 @llgs_test
-@expectedFailureAll(oslist=["freebsd"])
 def test_qMemoryRegionInfo_is_supported_llgs(self):
 self.init_llgs_test()
 self.build()
@@ -908,7 +907,6 @@
 self.qMemoryRegionInfo_reports_code_address_as_executable()
 
 @skipIfWindows # No pty support to test any inferior output
-@expectedFailureAll(oslist=["freebsd"])
 @llgs_test
 def test_qMemoryRegionInfo_reports_code_address_as_executable_llgs(self):
 self.init_llgs_test()
@@ -975,7 +973,6 @@
 self.qMemoryRegionInfo_reports_stack_address_as_readable_writeable()
 
 @skipIfWindows # No pty support to test any inferior output
-@expectedFailureAll(oslist=["freebsd"])
 @llgs_test
 def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_llgs(
 self):
@@ -1042,7 +1039,6 @@
 self.qMemoryRegionInfo_reports_heap_address_as_readable_writeable()
 
 @skipIfWindows # No pty support to test any inferior output
-@expectedFailureAll(oslist=["freebsd"])
 @llgs_test
 def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_llgs(
 self):
Index: lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
===
--- lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
+++ lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
@@ -23,7 +23,6 @@
 'main.cpp',
 '// Run here before printing memory regions')
 
-@expectedFailureAll(oslist=["freebsd"])
 def test(self):
 self.build()
 
Index: lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
===
--- lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
+++ lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
@@ -15,7 +15,6 @@
 mydir = TestBase.compute_mydir(__file__)
 NO_DEBUG_INFO_TESTCASE = True
 
-@expectedFailureAll(oslist=["freebsd"], bugnumber='llvm.org/pr48373')
 @expectedFailureNetBSD
 def test(self):
 self.build()
Index: lldb/test/API/api/multithreaded/TestMultithreaded.py
===
--- lldb/test/API/api/multithreaded/TestMultithreaded.py
+++ lldb/test/API/api/multithreaded/TestMultithreaded.py
@@ -31,7 +31,6 @@
 @skipIfNoSBHeaders
 # clang-cl does not support throw or catch (llvm.org/pr24538)
 @skipIfWindows
-@expectedFailureAll(oslis

[Lldb-commits] [PATCH] D93225: [lldb] Add helper class for dealing with key:value; GDB responses

2020-12-14 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: mgorny.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The current handling of qHostInfo is a bunch of if-else,
one for each key we think we might find. This works fine,
but we end up repeating parsing calls and extending it
gets tricky.

To improve this I'm adding KeyValueExtractorGDBRemote.
This is a class that takes the packet response and splits it up
into the key-value pairs. Where a pair is ":;".

Then you can do Get() to get an Optional.
This Optional is empty if the key was missing or its value
didn't parse as the T you asked for.

Or you can GetWithDefault(, )
which always gives you a T but if search/parse fails
then you get .

Plus specific methods to get LazyBool and hex encoded
string keys.

This improves the packet handling code by:

- Putting the type, key name and default value on the same line.
- Reducing the number of repeated parsing calls. (fewer "!value.getAsInteger(0, 
...)" means fewer chances to forget a "!")
- Removing the need for num_keys_decoded, which was essentially a boolean but 
was treated as a running total. (replaced with HadValidKey)

We do pay an up front cost in building the map of keys up
front. However these packets are infrequent and the increase
in readability makes up for it.

This change adds the class and applies it to qHostInfo, keeping
the original logic intact. (future patches will apply it to
other packets and refactor post decode logic)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93225

Files:
  lldb/include/lldb/Utility/KeyValueExtractorGDBRemote.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Utility/CMakeLists.txt
  lldb/source/Utility/KeyValueExtractorGDBRemote.cpp
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/KeyValueExtractorGDBRemoteTest.cpp

Index: lldb/unittests/Utility/KeyValueExtractorGDBRemoteTest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/KeyValueExtractorGDBRemoteTest.cpp
@@ -0,0 +1,211 @@
+//===-- KeyValueExtractorGDBRemoteTest.cpp ===//
+//
+// 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
+//
+//===--===//
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "lldb/Utility/KeyValueExtractorGDBRemote.h"
+#include "llvm/Support/VersionTuple.h"
+
+TEST(KeyValueExtractorGDBRemoteTest, ParseNothing) {
+  StringExtractorGDBRemote response("");
+  KeyValueExtractorGDBRemote e(response);
+  ASSERT_FALSE(e.HadValidKey());
+  ASSERT_FALSE(e.Get("test"));
+  ASSERT_FALSE(e.HadValidKey());
+}
+
+TEST(KeyValueExtractorGDBRemoteTest, ParseIncomplete) {
+  // Missing ending ';' so 'a' is not a valid key
+  StringExtractorGDBRemote response("a:abc");
+  KeyValueExtractorGDBRemote e(response);
+  ASSERT_FALSE(e.Get("a"));
+}
+
+TEST(KeyValueExtractorGDBRemoteTest, GetWithDefaultHadValid) {
+  StringExtractorGDBRemote response("a:def;");
+  KeyValueExtractorGDBRemote e(response);
+
+  // HadValid not set if we returned the default value
+  uint32_t missing = e.GetWithDefault("missing", 123);
+  ASSERT_EQ(missing, (uint32_t)123);
+  ASSERT_FALSE(e.HadValidKey());
+
+  // Not set if we found but failed to parse
+  uint32_t a_fails_parse = e.GetWithDefault("a", 456);
+  ASSERT_EQ(a_fails_parse, (uint32_t)456);
+  ASSERT_FALSE(e.HadValidKey());
+
+  // Set if found and parsed, didn't use the default
+  std::string a_parsed = e.GetWithDefault("a", "foo");
+  ASSERT_EQ(a_parsed, "def");
+  ASSERT_TRUE(e.HadValidKey());
+}
+
+TEST(KeyValueExtractorGDBRemoteTest, ParseUint32) {
+  StringExtractorGDBRemote response("valid:123;"
+"invalid:abc;");
+  KeyValueExtractorGDBRemote e(response);
+
+  // Had valid is always false before any Get has been called
+  ASSERT_FALSE(e.HadValidKey());
+
+  ASSERT_FALSE(e.Get("invalid"));
+  // Had valid is not set on parse failure
+  ASSERT_FALSE(e.HadValidKey());
+
+  llvm::Optional valid = e.Get("valid");
+  ASSERT_TRUE(valid);
+  ASSERT_EQ((uint32_t)123, *valid);
+
+  // Had valid now true because valid parsed successfully
+  ASSERT_TRUE(e.HadValidKey());
+
+  uint32_t get_default = e.GetWithDefault("default", 99);
+  ASSERT_EQ((uint32_t)99, get_default);
+}
+
+TEST(KeyValueExtractorGDBRemoteTest, ParsePID) {
+  // This invokes the same path as uint32_t
+  // so this test just checks that we handle a wider
+  // type correctly.
+  StringExtractorGDBRemote response("invalid:???;"
+"valid:0x;");
+  KeyValueExtractorGDBRemote e(response);
+
+  llvm::Optional invalid = e.Get("invalid");
+  ASSERT_FALSE

[Lldb-commits] [PATCH] D93226: [lldb] Apply KeyValueExtractorGDBRemote to qProcessInfo

2020-12-14 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The original logic is retained.

Unlike qHostInfo, qProcessInfo does not check whether
at least one key was parsed correctly. This allowed
me to move a lot of the Get calls next to where the
result is used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93226

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1897,91 +1897,65 @@
 bool GDBRemoteCommunicationClient::DecodeProcessInfoResponse(
 StringExtractorGDBRemote &response, ProcessInstanceInfo &process_info) {
   if (response.IsNormalResponse()) {
-llvm::StringRef name;
-llvm::StringRef value;
-StringExtractor extractor;
-
-uint32_t cpu = LLDB_INVALID_CPUTYPE;
-uint32_t sub = 0;
-std::string vendor;
-std::string os_type;
-
-while (response.GetNameColonValue(name, value)) {
-  if (name.equals("pid")) {
-lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
-value.getAsInteger(0, pid);
-process_info.SetProcessID(pid);
-  } else if (name.equals("ppid")) {
-lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
-value.getAsInteger(0, pid);
-process_info.SetParentProcessID(pid);
-  } else if (name.equals("uid")) {
-uint32_t uid = UINT32_MAX;
-value.getAsInteger(0, uid);
-process_info.SetUserID(uid);
-  } else if (name.equals("euid")) {
-uint32_t uid = UINT32_MAX;
-value.getAsInteger(0, uid);
-process_info.SetEffectiveUserID(uid);
-  } else if (name.equals("gid")) {
-uint32_t gid = UINT32_MAX;
-value.getAsInteger(0, gid);
-process_info.SetGroupID(gid);
-  } else if (name.equals("egid")) {
-uint32_t gid = UINT32_MAX;
-value.getAsInteger(0, gid);
-process_info.SetEffectiveGroupID(gid);
-  } else if (name.equals("triple")) {
-StringExtractor extractor(value);
-std::string triple;
-extractor.GetHexByteString(triple);
-process_info.GetArchitecture().SetTriple(triple.c_str());
-  } else if (name.equals("name")) {
-StringExtractor extractor(value);
-// The process name from ASCII hex bytes since we can't control the
-// characters in a process name
-std::string name;
-extractor.GetHexByteString(name);
-process_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
-  } else if (name.equals("args")) {
-llvm::StringRef encoded_args(value), hex_arg;
-
-bool is_arg0 = true;
-while (!encoded_args.empty()) {
-  std::tie(hex_arg, encoded_args) = encoded_args.split('-');
-  std::string arg;
-  StringExtractor extractor(hex_arg);
-  if (extractor.GetHexByteString(arg) * 2 != hex_arg.size()) {
-// In case of wrong encoding, we discard all the arguments
-process_info.GetArguments().Clear();
-process_info.SetArg0("");
-break;
-  }
-  if (is_arg0)
-process_info.SetArg0(arg);
-  else
-process_info.GetArguments().AppendArgument(arg);
-  is_arg0 = false;
+KeyValueExtractorGDBRemote extractor(response);
+
+process_info.SetProcessID(
+extractor.GetWithDefault("pid", LLDB_INVALID_PROCESS_ID));
+process_info.SetParentProcessID(
+extractor.GetWithDefault("ppid", LLDB_INVALID_PROCESS_ID));
+process_info.SetUserID(
+extractor.GetWithDefault("uid", UINT32_MAX));
+process_info.SetEffectiveUserID(
+extractor.GetWithDefault("euid", UINT32_MAX));
+process_info.SetGroupID(
+extractor.GetWithDefault("gid", UINT32_MAX));
+process_info.SetEffectiveGroupID(
+extractor.GetWithDefault("egid", UINT32_MAX));
+
+if (llvm::Optional triple =
+extractor.GetHexByteString("triple"))
+  process_info.GetArchitecture().SetTriple(triple->c_str());
+
+// The process name from ASCII hex bytes since we can't control the
+// characters in a process name
+if (llvm::Optional name = extractor.GetHexByteString("name"))
+  process_info.GetExecutableFile().SetFile(*name, FileSpec::Style::native);
+
+if (llvm::Optional args = extractor.Get("args")) {
+  llvm::StringRef encoded_args(*args), hex_arg;
+
+  bool is_arg0 = true;
+  while (encoded_args.size()) {
+std::tie(hex_arg, encoded_args) = encoded_args.split('-');
+std::string arg;
+StringExtractor extractor(hex_arg);
+if (extractor.GetHexByteString(arg) * 2 != hex_arg.size()) 

[Lldb-commits] [PATCH] D93225: [lldb] Add helper class for dealing with key:value; GDB responses

2020-12-14 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added reviewers: labath, jasonmolenda.
DavidSpickett added a comment.

I realise it's a lot to review but if you have any initial comments on the 
usability that'd be great. My main point here was to make the if-else chain a 
bit "safer" and more easily extended. The parsing logic itself I did not 
change, to keep things clear (though I would like to improve it later).

I've also put up https://reviews.llvm.org/D93226 where you can see how it 
changes qProcessInfo parsing.

There are a few more packets that could benefit to varying degrees. (some are 
just 1/2 keys)

- qGDBServerVersion
- qMemoryRegionInfo
- qWatchpointSupportInfo
- qProcessInfo again (in GetCurrentProcessInfo)
- qLaunchGDBServer
- qModuleInfo

A quick look over them doesn't show anything that would prevent 
KeyValueExtractorGDBRemote from applying there too if it proves useful here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93225

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


[Lldb-commits] [lldb] d636b88 - Adapt lldb to a40db5502b2515a6f2f1676b5d7a655ae0f41179

2020-12-14 Thread Duncan P. N. Exon Smith via lldb-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-14T14:41:15-08:00
New Revision: d636b881bb9214938973098a012fad453082c444

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

LOG: Adapt lldb to a40db5502b2515a6f2f1676b5d7a655ae0f41179

The bots just told me about a place in LLDB I missed in
a40db5502b2515a6f2f1676b5d7a655ae0f41179 when changing
`HeaderSearch::LoadedModuleMaps`, but I think this will fix it.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index c014ad504d378..89cb9d52356ab 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -278,10 +278,10 @@ bool ClangModulesDeclVendorImpl::AddModule(const 
SourceModule &module,
   HS.getFileMgr().getDirectory(module.search_path.GetStringRef());
   if (!dir)
 return error();
-  auto *file = HS.lookupModuleMapFile(*dir, is_framework);
+  auto file = HS.lookupModuleMapFile(*dir, is_framework);
   if (!file)
 return error();
-  if (!HS.loadModuleMapFile(file, is_system))
+  if (!HS.loadModuleMapFile(*file, is_system))
 return error();
 }
   }



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


[Lldb-commits] [PATCH] D93266: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, jingham.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch exposes the `Target::CreateBreakpoint` overload with the
boolean argument to move to the neareast code to the SBAPI.

This is useful when creating column breakpoints to restrict lldb's
resolution to the pointed source location, preventing it to go to the next
line.

rdar://72196842

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93266

Files:
  lldb/bindings/interface/SBTarget.i
  lldb/include/lldb/API/SBTarget.h
  lldb/source/API/SBTarget.cpp
  
lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
@@ -42,3 +42,30 @@
 self.assertEqual(b_loc.GetLine(), 11)
 in_condition |= b_loc.GetColumn() < 30
 self.assertTrue(in_condition)
+
+## Skip gcc version less 7.1 since it doesn't support -gcolumn-info
+@skipIf(compiler="gcc", compiler_version=['<', '7.1'])
+def testBreakpointByLineAndColumnNearestCode(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+main_c = lldb.SBFileSpec("main.c")
+line = line_number("main.c", "// Line 20.")
+column = len("// Line 20") # should stop at the period.
+indent = 2
+module_list = lldb.SBFileSpecList()
+
+# Create a target from the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+valid_bpt = target.BreakpointCreateByLocation(main_c, line, column,
+  indent, module_list, True)
+self.assertTrue(valid_bpt, VALID_BREAKPOINT)
+self.assertEqual(valid_bpt.GetNumLocations(), 1)
+
+invalid_bpt = target.BreakpointCreateByLocation(main_c, line, column,
+  indent, module_list, False)
+self.assertTrue(invalid_bpt, VALID_BREAKPOINT)
+self.assertEqual(invalid_bpt.GetNumLocations(), 0)
+
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -787,6 +787,38 @@
   return LLDB_RECORD_RESULT(sb_bp);
 }
 
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list,
+bool move_to_nearest_code) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &, bool),
+ sb_file_spec, line, column, offset, sb_module_list,
+ move_to_nearest_code);
+
+  SBBreakpoint sb_bp;
+  TargetSP target_sp(GetSP());
+  if (target_sp && line != 0) {
+std::lock_guard guard(target_sp->GetAPIMutex());
+
+const LazyBool check_inlines = eLazyBoolCalculate;
+const LazyBool skip_prologue = eLazyBoolCalculate;
+const bool internal = false;
+const bool hardware = false;
+const FileSpecList *module_list = nullptr;
+if (sb_module_list.GetSize() > 0) {
+  module_list = sb_module_list.get();
+}
+sb_bp = target_sp->CreateBreakpoint(
+module_list, *sb_file_spec, line, column, offset, check_inlines,
+skip_prologue, internal, hardware,
+move_to_nearest_code ? eLazyBoolYes : eLazyBoolNo);
+  }
+
+  return LLDB_RECORD_RESULT(sb_bp);
+}
+
 SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
   const char *module_name) {
   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
@@ -2489,6 +2521,9 @@
BreakpointCreateByLocation,
(const lldb::SBFileSpec &, uint32_t, uint32_t,
 lldb::addr_t, lldb::SBFileSpecList &));
+  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+   (const lldb::SBFileSpec &, uint32_t, uint32_t,
+lldb::addr_t, lldb::SBFileSpecList &, bool));
   LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
(const char *, const char *));
   LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
Index: lldb/include/lldb/API/SBTarget.h
==

[Lldb-commits] [PATCH] D93266: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/API/SBTarget.h:564
+  lldb::SBBreakpoint
+  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
+ uint32_t column, lldb::addr_t offset,

It's unfortunate that we have so many overloads, if we had to do it again I 
would've argued for something like `SBBreakpointLocationOptions` or something, 
but I'm not sure if that adds a lot, and dealing with defaults (such as the 
move_to_nearest_code) is hard because we have no SB counterpart for it. So I 
guess this is fine. 



Comment at: lldb/source/API/SBTarget.cpp:805-817
+const LazyBool check_inlines = eLazyBoolCalculate;
+const LazyBool skip_prologue = eLazyBoolCalculate;
+const bool internal = false;
+const bool hardware = false;
+const FileSpecList *module_list = nullptr;
+if (sb_module_list.GetSize() > 0) {
+  module_list = sb_module_list.get();

There's a lot of code duplication with the method just before it. Can we 
extract the common code into a private method that both call into? The 
reproducer instrumentation would remain in the public method. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93266

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


[Lldb-commits] [lldb] 7799ef7 - Revert "Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef"

2020-12-14 Thread Nico Weber via lldb-commits

Author: Nico Weber
Date: 2020-12-14T22:05:08-05:00
New Revision: 7799ef7121aa7d59f4bd95cdf70035de724ead6f

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

LOG: Revert "Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef"

This reverts commit a40db5502b2515a6f2f1676b5d7a655ae0f41179.
and follow-up d636b881bb9214938973098a012fad453082c444

Somewhat speculative, likely broke check-clang on Windows:
https://reviews.llvm.org/D92975#2453482

Added: 


Modified: 
clang-tools-extra/modularize/ModularizeUtilities.cpp
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp 
b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 7470c324bbdb..200370c135df 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -258,22 +258,22 @@ std::error_code 
ModularizeUtilities::loadProblemHeaderList(
 std::error_code ModularizeUtilities::loadModuleMap(
 llvm::StringRef InputPath) {
   // Get file entry for module.modulemap file.
-  auto ExpectedModuleMapEntry =
-SourceMgr->getFileManager().getFileRef(InputPath);
+  auto ModuleMapEntryOrErr =
+SourceMgr->getFileManager().getFile(InputPath);
 
   // return error if not found.
-  if (!ExpectedModuleMapEntry) {
+  if (!ModuleMapEntryOrErr) {
 llvm::errs() << "error: File \"" << InputPath << "\" not found.\n";
-return errorToErrorCode(ExpectedModuleMapEntry.takeError());
+return ModuleMapEntryOrErr.getError();
   }
-  FileEntryRef ModuleMapEntry = *ExpectedModuleMapEntry;
+  const FileEntry *ModuleMapEntry = *ModuleMapEntryOrErr;
 
   // Because the module map parser uses a ForwardingDiagnosticConsumer,
   // which doesn't forward the BeginSourceFile call, we do it explicitly here.
   DC.BeginSourceFile(*LangOpts, nullptr);
 
   // Figure out the home directory for the module map file.
-  const DirectoryEntry *Dir = ModuleMapEntry.getDir();
+  const DirectoryEntry *Dir = ModuleMapEntry->getDir();
   StringRef DirName(Dir->getName());
   if (llvm::sys::path::filename(DirName) == "Modules") {
 DirName = llvm::sys::path::parent_path(DirName);

diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 8ea81226cf77..93d6ea72270a 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -239,7 +239,7 @@ class HeaderSearch {
 
   /// Set of module map files we've already loaded, and a flag indicating
   /// whether they were valid or not.
-  llvm::DenseMap LoadedModuleMaps;
+  llvm::DenseMap LoadedModuleMaps;
 
   /// Uniqued set of framework names, which is used to track which
   /// headers were included as framework headers.
@@ -560,8 +560,8 @@ class HeaderSearch {
 
   /// Try to find a module map file in the given directory, returning
   /// \c nullptr if none is found.
-  Optional lookupModuleMapFile(const DirectoryEntry *Dir,
- bool IsFramework);
+  const FileEntry *lookupModuleMapFile(const DirectoryEntry *Dir,
+   bool IsFramework);
 
   /// Determine whether there is a module map that may map the header
   /// with the given file name to a (sub)module.
@@ -603,8 +603,8 @@ class HeaderSearch {
   ///used to resolve paths within the module (this is required when
   ///building the module from preprocessed source).
   /// \returns true if an error occurred, false otherwise.
-  bool loadModuleMapFile(FileEntryRef File, bool IsSystem, FileID ID = 
FileID(),
- unsigned *Offset = nullptr,
+  bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
+ FileID ID = FileID(), unsigned *Offset = nullptr,
  StringRef OriginalModuleMapFile = StringRef());
 
   /// Collect the set of all known, top-level modules.
@@ -794,7 +794,8 @@ class HeaderSearch {
 LMM_InvalidModuleMap
   };
 
-  LoadModuleMapResult loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
+  LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
+bool IsSystem,
 const DirectoryEntry *Dir,
 FileID ID = FileID(),
 unsigned *Offset = nullptr);

diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 1d7ce5fc2320..6827408f10

[Lldb-commits] [PATCH] D93266: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 311771.
mib added a comment.

Address @JDevlieghere comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93266

Files:
  lldb/bindings/interface/SBTarget.i
  lldb/include/lldb/API/SBTarget.h
  lldb/source/API/SBTarget.cpp
  
lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
@@ -42,3 +42,30 @@
 self.assertEqual(b_loc.GetLine(), 11)
 in_condition |= b_loc.GetColumn() < 30
 self.assertTrue(in_condition)
+
+## Skip gcc version less 7.1 since it doesn't support -gcolumn-info
+@skipIf(compiler="gcc", compiler_version=['<', '7.1'])
+def testBreakpointByLineAndColumnNearestCode(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+main_c = lldb.SBFileSpec("main.c")
+line = line_number("main.c", "// Line 20.")
+column = len("// Line 20") # should stop at the period.
+indent = 2
+module_list = lldb.SBFileSpecList()
+
+# Create a target from the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+valid_bpt = target.BreakpointCreateByLocation(main_c, line, column,
+  indent, module_list, True)
+self.assertTrue(valid_bpt, VALID_BREAKPOINT)
+self.assertEqual(valid_bpt.GetNumLocations(), 1)
+
+invalid_bpt = target.BreakpointCreateByLocation(main_c, line, column,
+  indent, module_list, False)
+self.assertTrue(invalid_bpt, VALID_BREAKPOINT)
+self.assertEqual(invalid_bpt.GetNumLocations(), 0)
+
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -757,14 +757,10 @@
offset, sb_module_list));
 }
 
-SBBreakpoint SBTarget::BreakpointCreateByLocation(
-const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList &sb_module_list) {
-  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
- (const lldb::SBFileSpec &, uint32_t, uint32_t,
-  lldb::addr_t, lldb::SBFileSpecList &),
- sb_file_spec, line, column, offset, sb_module_list);
-
+SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
+const lldb::SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list,
+const LazyBool move_to_nearest_code) {
   SBBreakpoint sb_bp;
   TargetSP target_sp(GetSP());
   if (target_sp && line != 0) {
@@ -774,7 +770,6 @@
 const LazyBool skip_prologue = eLazyBoolCalculate;
 const bool internal = false;
 const bool hardware = false;
-const LazyBool move_to_nearest_code = eLazyBoolCalculate;
 const FileSpecList *module_list = nullptr;
 if (sb_module_list.GetSize() > 0) {
   module_list = sb_module_list.get();
@@ -784,7 +779,34 @@
 skip_prologue, internal, hardware, move_to_nearest_code);
   }
 
-  return LLDB_RECORD_RESULT(sb_bp);
+  return sb_bp;
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &),
+ sb_file_spec, line, column, offset, sb_module_list);
+
+  return LLDB_RECORD_RESULT(BreakpointCreateByLocationImpl(
+  sb_file_spec, line, column, offset, sb_module_list, eLazyBoolCalculate));
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list,
+bool move_to_nearest_code) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &, bool),
+ sb_file_spec, line, column, offset, sb_module_list,
+ move_to_nearest_code);
+
+  return LLDB_RECORD_RESULT(BreakpointCreateByLocationImpl(
+  sb_file_

[Lldb-commits] [PATCH] D93266: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 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.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93266

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


[Lldb-commits] [lldb] 0470169 - [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-12-15T04:24:44+01:00
New Revision: 04701698ebaff8d0c108e590a7e55c3c5bcd4d9e

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

LOG: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) 
overload

This patch exposes the Target::CreateBreakpoint overload with the
boolean argument to move to the neareast code to the SBAPI.

This is useful when creating column breakpoints to restrict lldb's
resolution to the pointed source location, preventing it to go to the next
line.

rdar://72196842

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

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/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Removed: 




diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 57b5ccea6399..41b9be2bf1fb 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -579,6 +579,12 @@ public:
 uint32_t column, lldb::addr_t offset,
 SBFileSpecList &module_list);
 
+lldb::SBBreakpoint
+BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t 
line,
+uint32_t column, lldb::addr_t offset,
+SBFileSpecList &module_list,
+bool move_to_nearest_code);
+
 lldb::SBBreakpoint
 BreakpointCreateByName (const char *symbol_name, const char *module_name = 
NULL);
 

diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index fad842c9cb1c..bf423726f080 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -9,6 +9,8 @@
 #ifndef LLDB_API_SBTARGET_H
 #define LLDB_API_SBTARGET_H
 
+#include "lldb/lldb-private-enumerations.h"
+
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBreakpoint.h"
@@ -560,6 +562,12 @@ class LLDB_API SBTarget {
  uint32_t column, lldb::addr_t offset,
  SBFileSpecList &module_list);
 
+  lldb::SBBreakpoint
+  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
+ uint32_t column, lldb::addr_t offset,
+ SBFileSpecList &module_list,
+ bool move_to_nearest_code);
+
   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
 const char *module_name = nullptr);
 
@@ -858,6 +866,11 @@ class LLDB_API SBTarget {
   void SetSP(const lldb::TargetSP &target_sp);
 
 private:
+  lldb::SBBreakpoint BreakpointCreateByLocationImpl(
+  const lldb::SBFileSpec &file_spec, uint32_t line, uint32_t column,
+  lldb::addr_t offset, SBFileSpecList &module_list,
+  const lldb_private::LazyBool move_to_nearest_code);
+
   lldb::TargetSP m_opaque_sp;
 };
 

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 2a305159bbb5..d0761d69c667 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -757,14 +757,10 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec 
&sb_file_spec,
offset, 
sb_module_list));
 }
 
-SBBreakpoint SBTarget::BreakpointCreateByLocation(
-const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList &sb_module_list) {
-  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
- (const lldb::SBFileSpec &, uint32_t, uint32_t,
-  lldb::addr_t, lldb::SBFileSpecList &),
- sb_file_spec, line, column, offset, sb_module_list);
-
+SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
+const lldb::SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list,
+const LazyBool move_to_nearest_code) {
   SBBreakpoint sb_bp;
   TargetSP target_sp(GetSP());
   if (target_sp && line != 0) {
@@ -774,7 +770,6 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
 const LazyBool skip_prologue = eLazyBoolCalculate;
 const bool internal = false;
 const bool hardware = false;
-const LazyBool move_to_nearest_code = eLazyBoolCalculate;
 const FileSpecList *module_list = nullptr;
 if (sb_module_list.GetSize() > 0) {
   module_list = sb_module_list.get();
@@ -784,7 +779,34 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
 skip_prologue, internal,

[Lldb-commits] [PATCH] D93266: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Med Ismail Bennani 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 rG04701698ebaf: [lldb/API] Expose 
Target::CreateBreakpoint(..., move_to_nearest_code) overload (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93266

Files:
  lldb/bindings/interface/SBTarget.i
  lldb/include/lldb/API/SBTarget.h
  lldb/source/API/SBTarget.cpp
  
lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Index: lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
===
--- lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
+++ lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
@@ -42,3 +42,30 @@
 self.assertEqual(b_loc.GetLine(), 11)
 in_condition |= b_loc.GetColumn() < 30
 self.assertTrue(in_condition)
+
+## Skip gcc version less 7.1 since it doesn't support -gcolumn-info
+@skipIf(compiler="gcc", compiler_version=['<', '7.1'])
+def testBreakpointByLineAndColumnNearestCode(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+main_c = lldb.SBFileSpec("main.c")
+line = line_number("main.c", "// Line 20.")
+column = len("// Line 20") # should stop at the period.
+indent = 2
+module_list = lldb.SBFileSpecList()
+
+# Create a target from the debugger.
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+valid_bpt = target.BreakpointCreateByLocation(main_c, line, column,
+  indent, module_list, True)
+self.assertTrue(valid_bpt, VALID_BREAKPOINT)
+self.assertEqual(valid_bpt.GetNumLocations(), 1)
+
+invalid_bpt = target.BreakpointCreateByLocation(main_c, line, column,
+  indent, module_list, False)
+self.assertTrue(invalid_bpt, VALID_BREAKPOINT)
+self.assertEqual(invalid_bpt.GetNumLocations(), 0)
+
Index: lldb/source/API/SBTarget.cpp
===
--- lldb/source/API/SBTarget.cpp
+++ lldb/source/API/SBTarget.cpp
@@ -757,14 +757,10 @@
offset, sb_module_list));
 }
 
-SBBreakpoint SBTarget::BreakpointCreateByLocation(
-const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList &sb_module_list) {
-  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
- (const lldb::SBFileSpec &, uint32_t, uint32_t,
-  lldb::addr_t, lldb::SBFileSpecList &),
- sb_file_spec, line, column, offset, sb_module_list);
-
+SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
+const lldb::SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list,
+const LazyBool move_to_nearest_code) {
   SBBreakpoint sb_bp;
   TargetSP target_sp(GetSP());
   if (target_sp && line != 0) {
@@ -774,7 +770,6 @@
 const LazyBool skip_prologue = eLazyBoolCalculate;
 const bool internal = false;
 const bool hardware = false;
-const LazyBool move_to_nearest_code = eLazyBoolCalculate;
 const FileSpecList *module_list = nullptr;
 if (sb_module_list.GetSize() > 0) {
   module_list = sb_module_list.get();
@@ -784,7 +779,34 @@
 skip_prologue, internal, hardware, move_to_nearest_code);
   }
 
-  return LLDB_RECORD_RESULT(sb_bp);
+  return sb_bp;
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &),
+ sb_file_spec, line, column, offset, sb_module_list);
+
+  return LLDB_RECORD_RESULT(BreakpointCreateByLocationImpl(
+  sb_file_spec, line, column, offset, sb_module_list, eLazyBoolCalculate));
+}
+
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list,
+bool move_to_nearest_code) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &, bool),
+ sb_file_sp

[Lldb-commits] [lldb] 1d3f1eb - Revert "[lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload"

2020-12-14 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-12-15T06:18:04+01:00
New Revision: 1d3f1eb855fcfb03b6ddb92543c02694115b5739

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

LOG: Revert "[lldb/API] Expose Target::CreateBreakpoint(..., 
move_to_nearest_code) overload"

This reverts commit 04696ff002e7d311887b7b7e6e171340a0623dd9.

Exposing the LazyBool private type in SBTarget.h breaks some tests.

Added: 


Modified: 
lldb/bindings/interface/SBTarget.i
lldb/include/lldb/API/SBTarget.h
lldb/source/API/SBTarget.cpp

lldb/test/API/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Removed: 




diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 41b9be2bf1fb..57b5ccea6399 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -579,12 +579,6 @@ public:
 uint32_t column, lldb::addr_t offset,
 SBFileSpecList &module_list);
 
-lldb::SBBreakpoint
-BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t 
line,
-uint32_t column, lldb::addr_t offset,
-SBFileSpecList &module_list,
-bool move_to_nearest_code);
-
 lldb::SBBreakpoint
 BreakpointCreateByName (const char *symbol_name, const char *module_name = 
NULL);
 

diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index bf423726f080..fad842c9cb1c 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -9,8 +9,6 @@
 #ifndef LLDB_API_SBTARGET_H
 #define LLDB_API_SBTARGET_H
 
-#include "lldb/lldb-private-enumerations.h"
-
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBAttachInfo.h"
 #include "lldb/API/SBBreakpoint.h"
@@ -562,12 +560,6 @@ class LLDB_API SBTarget {
  uint32_t column, lldb::addr_t offset,
  SBFileSpecList &module_list);
 
-  lldb::SBBreakpoint
-  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
- uint32_t column, lldb::addr_t offset,
- SBFileSpecList &module_list,
- bool move_to_nearest_code);
-
   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
 const char *module_name = nullptr);
 
@@ -866,11 +858,6 @@ class LLDB_API SBTarget {
   void SetSP(const lldb::TargetSP &target_sp);
 
 private:
-  lldb::SBBreakpoint BreakpointCreateByLocationImpl(
-  const lldb::SBFileSpec &file_spec, uint32_t line, uint32_t column,
-  lldb::addr_t offset, SBFileSpecList &module_list,
-  const lldb_private::LazyBool move_to_nearest_code);
-
   lldb::TargetSP m_opaque_sp;
 };
 

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index d0761d69c667..2a305159bbb5 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -757,10 +757,14 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec 
&sb_file_spec,
offset, 
sb_module_list));
 }
 
-SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
-const lldb::SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList &sb_module_list,
-const LazyBool move_to_nearest_code) {
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &),
+ sb_file_spec, line, column, offset, sb_module_list);
+
   SBBreakpoint sb_bp;
   TargetSP target_sp(GetSP());
   if (target_sp && line != 0) {
@@ -770,6 +774,7 @@ SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
 const LazyBool skip_prologue = eLazyBoolCalculate;
 const bool internal = false;
 const bool hardware = false;
+const LazyBool move_to_nearest_code = eLazyBoolCalculate;
 const FileSpecList *module_list = nullptr;
 if (sb_module_list.GetSize() > 0) {
   module_list = sb_module_list.get();
@@ -779,34 +784,7 @@ SBBreakpoint SBTarget::BreakpointCreateByLocationImpl(
 skip_prologue, internal, hardware, move_to_nearest_code);
   }
 
-  return sb_bp;
-}
-
-SBBreakpoint SBTarget::BreakpointCreateByLocation(
-const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
-lldb::addr_t offset, SBFileSpecList &sb_module_

[Lldb-commits] [lldb] dc82890 - [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) overload

2020-12-14 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-12-15T06:18:04+01:00
New Revision: dc82890a77fe894e90103f4465bb4c838617feff

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

LOG: [lldb/API] Expose Target::CreateBreakpoint(..., move_to_nearest_code) 
overload

This patch exposes the Target::CreateBreakpoint overload with the
boolean argument to move to the neareast code to the SBAPI.

This is useful when creating column breakpoints to restrict lldb's
resolution to the pointed source location, preventing it to go to the next
line.

rdar://72196842

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

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/functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py

Removed: 




diff  --git a/lldb/bindings/interface/SBTarget.i 
b/lldb/bindings/interface/SBTarget.i
index 57b5ccea6399..41b9be2bf1fb 100644
--- a/lldb/bindings/interface/SBTarget.i
+++ b/lldb/bindings/interface/SBTarget.i
@@ -579,6 +579,12 @@ public:
 uint32_t column, lldb::addr_t offset,
 SBFileSpecList &module_list);
 
+lldb::SBBreakpoint
+BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t 
line,
+uint32_t column, lldb::addr_t offset,
+SBFileSpecList &module_list,
+bool move_to_nearest_code);
+
 lldb::SBBreakpoint
 BreakpointCreateByName (const char *symbol_name, const char *module_name = 
NULL);
 

diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index fad842c9cb1c..30f4005dfc0f 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -560,6 +560,12 @@ class LLDB_API SBTarget {
  uint32_t column, lldb::addr_t offset,
  SBFileSpecList &module_list);
 
+  lldb::SBBreakpoint
+  BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line,
+ uint32_t column, lldb::addr_t offset,
+ SBFileSpecList &module_list,
+ bool move_to_nearest_code);
+
   lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name,
 const char *module_name = nullptr);
 

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 2a305159bbb5..6128c04de32b 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -787,6 +787,38 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
   return LLDB_RECORD_RESULT(sb_bp);
 }
 
+SBBreakpoint SBTarget::BreakpointCreateByLocation(
+const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
+lldb::addr_t offset, SBFileSpecList &sb_module_list,
+bool move_to_nearest_code) {
+  LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+  lldb::addr_t, lldb::SBFileSpecList &, bool),
+ sb_file_spec, line, column, offset, sb_module_list,
+ move_to_nearest_code);
+
+  SBBreakpoint sb_bp;
+  TargetSP target_sp(GetSP());
+  if (target_sp && line != 0) {
+std::lock_guard guard(target_sp->GetAPIMutex());
+
+const LazyBool check_inlines = eLazyBoolCalculate;
+const LazyBool skip_prologue = eLazyBoolCalculate;
+const bool internal = false;
+const bool hardware = false;
+const FileSpecList *module_list = nullptr;
+if (sb_module_list.GetSize() > 0) {
+  module_list = sb_module_list.get();
+}
+sb_bp = target_sp->CreateBreakpoint(
+module_list, *sb_file_spec, line, column, offset, check_inlines,
+skip_prologue, internal, hardware,
+move_to_nearest_code ? eLazyBoolYes : eLazyBoolNo);
+  }
+
+  return LLDB_RECORD_RESULT(sb_bp);
+}
+
 SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
   const char *module_name) {
   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
@@ -2489,6 +2521,9 @@ void RegisterMethods(Registry &R) {
BreakpointCreateByLocation,
(const lldb::SBFileSpec &, uint32_t, uint32_t,
 lldb::addr_t, lldb::SBFileSpecList &));
+  LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, 
BreakpointCreateByLocation,
+   (const lldb::SBFileSpec &, uint32_t, uint32_t,
+lldb::addr_t, lldb::SBFileSpecList &,