[Lldb-commits] [lldb] f446fc5 - [lldb][docs] Resolve the remaining sphinx formatter warnings in the SB API docs

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

Author: Raphael Isemann
Date: 2021-01-18T10:47:19+01:00
New Revision: f446fc5acf88fda676b5df1c04838f7244201d20

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

LOG: [lldb][docs] Resolve the remaining sphinx formatter warnings in the SB API 
docs

With this patch there should no longer be any warnings when generating the
SB API sphinx docs.

Added: 


Modified: 
lldb/bindings/interface/SBAddress.i
lldb/bindings/interface/SBBroadcaster.i
lldb/bindings/interface/SBDebugger.i
lldb/bindings/interface/SBFrame.i
lldb/bindings/interface/SBModule.i
lldb/bindings/interface/SBProcess.i
lldb/bindings/interface/SBTarget.i
lldb/bindings/interface/SBValue.i

Removed: 




diff  --git a/lldb/bindings/interface/SBAddress.i 
b/lldb/bindings/interface/SBAddress.i
index 694a7723e225..8e95d36e580d 100644
--- a/lldb/bindings/interface/SBAddress.i
+++ b/lldb/bindings/interface/SBAddress.i
@@ -109,18 +109,17 @@ public:
 An address might refer to code or data from an existing module, or it
 might refer to something on the stack or heap. The following functions
 will only return valid values if the address has been resolved to a code
-or data address using 'void SBAddress::SetLoadAddress(...)' or
-'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'.") GetSymbolContext;
+or data address using :py:class:`SBAddress.SetLoadAddress' or
+:py:class:`SBTarget.ResolveLoadAddress`.") GetSymbolContext;
 lldb::SBSymbolContext
 GetSymbolContext (uint32_t resolve_scope);
 
 %feature("docstring", "
 GetModule() and the following grab individual objects for a given address 
and
 are less efficient if you want more than one symbol related objects.
-Use one of the following when you want multiple debug symbol related
-objects for an address:
-   lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t 
resolve_scope);
-   lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const 
SBAddress &addr, uint32_t resolve_scope);
+Use :py:class:`SBAddress.GetSymbolContext` or
+:py:class:`SBTarget.ResolveSymbolContextForAddress` when you want multiple
+debug symbol related objects for an address.
 One or more bits from the SymbolContextItem enumerations can be logically
 OR'ed together to more efficiently retrieve multiple symbol objects.") 
GetModule;
 lldb::SBModule

diff  --git a/lldb/bindings/interface/SBBroadcaster.i 
b/lldb/bindings/interface/SBBroadcaster.i
index dd6de1feff42..e97d8f964bde 100644
--- a/lldb/bindings/interface/SBBroadcaster.i
+++ b/lldb/bindings/interface/SBBroadcaster.i
@@ -9,7 +9,9 @@
 namespace lldb {
 
 %feature("docstring",
-"Represents an entity which can broadcast events. A default broadcaster is
+"Represents an entity which can broadcast events.
+
+A default broadcaster is
 associated with an SBCommandInterpreter, SBProcess, and SBTarget.  For
 example, use ::
 

diff  --git a/lldb/bindings/interface/SBDebugger.i 
b/lldb/bindings/interface/SBDebugger.i
index 78d737b48c23..cf4411980cc3 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -498,12 +498,12 @@ A tuple with the number of errors encountered by the 
interpreter, a boolean
 indicating whether quitting the interpreter was requested and another boolean
 set to True in case of a crash.
 
-Example:
+Example: ::
 
-# Start an interactive lldb session from a script (with a valid debugger object
-# created beforehand):
-n_errors, quit_requested, has_crashed = debugger.RunCommandInterpreter(True,
-False, lldb.SBCommandInterpreterRunOptions(), 0, False, False)") 
RunCommandInterpreter;
+# Start an interactive lldb session from a script (with a valid debugger 
object
+# created beforehand):
+n_errors, quit_requested, has_crashed = 
debugger.RunCommandInterpreter(True,
+False, lldb.SBCommandInterpreterRunOptions(), 0, False, False)") 
RunCommandInterpreter;
 %apply int& INOUT { int& num_errors };
 %apply bool& INOUT { bool& quit_requested };
 %apply bool& INOUT { bool& stopped_for_crash };

diff  --git a/lldb/bindings/interface/SBFrame.i 
b/lldb/bindings/interface/SBFrame.i
index 8ceb03bb7a18..047b090e8a61 100644
--- a/lldb/bindings/interface/SBFrame.i
+++ b/lldb/bindings/interface/SBFrame.i
@@ -13,30 +13,30 @@ namespace lldb {
 
 SBThread contains SBFrame(s). For example (from test/lldbutil.py), ::
 
-def print_stacktrace(thread, string_buffer = False):
-'''Prints a simple stack trace of this thread.'''
-
-...
-
-for i in range(depth):
-frame = thread.GetFrameAtIndex(i)
-function = frame.GetFunction()
-
-load_addr = addrs[i].GetLoadAddress(target)
-if not function:
-file_addr = addrs[i].Ge

[Lldb-commits] [lldb] 6e75ee6 - [lldb][docs] Use inline literals for code/paths instead of rendering it with the default role

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

Author: Raphael Isemann
Date: 2021-01-18T11:10:19+01:00
New Revision: 6e75ee6b65c1c9924c0c9c10b1cbd57f10fe127b

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

LOG: [lldb][docs] Use inline literals for code/paths instead of rendering it 
with the default role

Right now we're using the 'content' role as default which will just render
these things as cursive (which isn't really useful for code examples). It also
prevents us from assigning a more useful default role in the future.

Added: 


Modified: 
lldb/bindings/interface/SBFile.i
lldb/bindings/interface/SBFrame.i
lldb/bindings/interface/SBValue.i
lldb/docs/design/reproducers.rst
lldb/docs/design/sbapi.rst
lldb/docs/man/lldb.rst
lldb/docs/resources/build.rst
lldb/docs/resources/contributing.rst

Removed: 




diff  --git a/lldb/bindings/interface/SBFile.i 
b/lldb/bindings/interface/SBFile.i
index c86c5f26f147..4a2f58e0e78f 100644
--- a/lldb/bindings/interface/SBFile.i
+++ b/lldb/bindings/interface/SBFile.i
@@ -93,7 +93,7 @@ public:
 
 If there is no underlying python file to unwrap, GetFile will
 use the file descriptor, if available to create a new python
-file object using `open(fd, mode=..., closefd=False)`
+file object using ``open(fd, mode=..., closefd=False)``
 ");
 FileSP GetFile();
 };

diff  --git a/lldb/bindings/interface/SBFrame.i 
b/lldb/bindings/interface/SBFrame.i
index 047b090e8a61..7bbf63c713f3 100644
--- a/lldb/bindings/interface/SBFrame.i
+++ b/lldb/bindings/interface/SBFrame.i
@@ -282,7 +282,7 @@ public:
 Find variables, register sets, registers, or persistent variables using
 the frame as the scope.
 
-The version that doesn't supply a `use_dynamic` value will use the
+The version that doesn't supply a ``use_dynamic`` value will use the
 target's default.") FindValue;
 lldb::SBValue
 FindValue (const char *name, ValueType value_type);

diff  --git a/lldb/bindings/interface/SBValue.i 
b/lldb/bindings/interface/SBValue.i
index 928b6cffe464..dd012e667a20 100644
--- a/lldb/bindings/interface/SBValue.i
+++ b/lldb/bindings/interface/SBValue.i
@@ -379,13 +379,13 @@ public:
 Get an SBData wrapping what this SBValue points to.
 
 This method will dereference the current SBValue, if its
-data type is a `T\*` or `T[]`, and extract `item_count` elements
-of type `T` from it, copying their contents in an :py:class:`SBData`.
+data type is a ``T\*`` or ``T[]``, and extract ``item_count`` elements
+of type ``T`` from it, copying their contents in an :py:class:`SBData`.
 
 :param item_idx: The index of the first item to retrieve. For an array
 this is equivalent to array[item_idx], for a pointer
-to `\*(pointer + item_idx)`. In either case, the measurement
-unit for item_idx is the `sizeof(T)` rather than the byte
+to ``\*(pointer + item_idx)``. In either case, the measurement
+unit for item_idx is the ``sizeof(T)`` rather than the byte
 :param item_count: How many items should be copied into the output. By 
default
 only one item is copied, but more can be asked for.
 :return: The contents of the copied items on success. An empty 
:py:class:`SBData` otherwise.

diff  --git a/lldb/docs/design/reproducers.rst 
b/lldb/docs/design/reproducers.rst
index 1b109c06d907..d8ad3dd7866d 100644
--- a/lldb/docs/design/reproducers.rst
+++ b/lldb/docs/design/reproducers.rst
@@ -105,7 +105,7 @@ Active Replay
 ^
 
 No matter how a reproducer was captured, they can always be replayed with the
-command line driver. When a reproducer is passed with the `--replay` flag, the
+command line driver. When a reproducer is passed with the ``--replay`` flag, 
the
 driver short-circuits and passes off control to the reproducer infrastructure,
 effectively bypassing its normal operation. This works because the driver is
 implemented using the SB API and is therefore nothing more than a sequence of

diff  --git a/lldb/docs/design/sbapi.rst b/lldb/docs/design/sbapi.rst
index 674fd680b907..676509bbd99e 100644
--- a/lldb/docs/design/sbapi.rst
+++ b/lldb/docs/design/sbapi.rst
@@ -76,7 +76,7 @@ will need to run ``clang-format`` over the processed file, as 
the tool
 (intentionally) makes no attempt to get that right.
 
 The ``LLDB_REGISTER`` macros are printed to standard out between curly braces.
-You'll have to copy-paste those into the corresponding `RegsiterMethods`
+You'll have to copy-paste those into the corresponding ``RegisterMethods``
 function in the implementation file. This function is fully specialized in the
 corresponding type.
 

diff  --git a/lldb/docs/man/lldb.rst b/lldb/docs/man/lldb.rst
index 65ac462fed94..6dca15fa35dc 100644
--- a/lldb/docs/man/lldb.rst
+++ b/lldb

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

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

(@labath Sorry for late response, I've been away from keyboard for some time.)

> Have you by any chance learned why are we zero-filling this buffer in the 
> first place? Seems like an odd thing to do... Maybe we should just stop 
> zero-filling completely?

Hmm... not sure why. It was there since the original commit that introduced the 
file (c037383aff81a61ed956858353ec003e970fb2ce). I don't see the point 
actually, and when I removed the `zero_fill_size` and zero filling with 
`memset()`, there was no regression in the lldb test suite. I guess we can 
remove it completely.


Repository:
  rG LLVM Github Monorepo

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] [PATCH] D94917: [lldb] Fix crash in "help memory read"

2021-01-18 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.

When a command option does not have a short version
(e.g. -f for --file), we use an arbitrary value in the
short_option field to mark it as invalid.
(though this value is unqiue to be used later for other
things)

We check that this short option is valid to print using
llvm::isPrint. This implicitly casts our int to char,
meaning we check the last char of any short_option value.

Since the arbitrary value we chose for these options is
some shortened hex version of the name, this returned true
even for invalid values.

Since llvm::isPrint returns true we later call std::islower
and/or std::isupper on the short_option value. (the int)

Calling these functions with something that cannot be validly
converted to unsigned char is undefined. Somehow we got/get
away with this but for me compiling with g++-9 I got a crash
for "help memory read".

The other command that uses this is "target variable" but that
didn't crash for unknown reasons.

Checking that short_option can fit into an unsigned char before
we call llvm::isPrint means we will not attempt to call islower/upper
on these options since we have no reason to print them.

This also fixes bogus short options being shown for "memory read"
and target variable.

For "target variable", before:

  -e  ( --file  )
  -b  ( --shlib  )

After:

  --file 
  --shlib 

(note that the bogus short options are just the bottom byte of our
arbitrary short_option value)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94917

Files:
  lldb/include/lldb/Utility/OptionDefinition.h
  lldb/test/API/commands/help/TestHelp.py


Index: lldb/test/API/commands/help/TestHelp.py
===
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -57,6 +57,11 @@
 self.runCmd("help unsigned-integer")
 
 @no_debug_info_test
+def test_help_memory_read_should_not_crash_lldb(self):
+"""Command 'help memory read' should not crash lldb."""
+self.runCmd("help memory read", check=False)
+
+@no_debug_info_test
 def test_help_should_not_hang_emacsshell(self):
 """Command 'settings set term-width 0' should not hang the help 
command."""
 self.expect(
Index: lldb/include/lldb/Utility/OptionDefinition.h
===
--- lldb/include/lldb/Utility/OptionDefinition.h
+++ lldb/include/lldb/Utility/OptionDefinition.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-types.h"
 #include "llvm/ADT/StringExtras.h"
+#include 
 #include 
 
 namespace lldb_private {
@@ -47,7 +48,9 @@
   /// Whether this has a short option character.
   bool HasShortOption() const {
 // See the short_option documentation for more.
-return llvm::isPrint(short_option);
+// Must not have any bits set outside of unsigned char range
+return !(short_option & ~((1 << CHAR_BIT) - 1)) &&
+   llvm::isPrint(short_option);
   }
 };
 } // namespace lldb_private


Index: lldb/test/API/commands/help/TestHelp.py
===
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -57,6 +57,11 @@
 self.runCmd("help unsigned-integer")
 
 @no_debug_info_test
+def test_help_memory_read_should_not_crash_lldb(self):
+"""Command 'help memory read' should not crash lldb."""
+self.runCmd("help memory read", check=False)
+
+@no_debug_info_test
 def test_help_should_not_hang_emacsshell(self):
 """Command 'settings set term-width 0' should not hang the help command."""
 self.expect(
Index: lldb/include/lldb/Utility/OptionDefinition.h
===
--- lldb/include/lldb/Utility/OptionDefinition.h
+++ lldb/include/lldb/Utility/OptionDefinition.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-types.h"
 #include "llvm/ADT/StringExtras.h"
+#include 
 #include 
 
 namespace lldb_private {
@@ -47,7 +48,9 @@
   /// Whether this has a short option character.
   bool HasShortOption() const {
 // See the short_option documentation for more.
-return llvm::isPrint(short_option);
+// Must not have any bits set outside of unsigned char range
+return !(short_option & ~((1 << CHAR_BIT) - 1)) &&
+   llvm::isPrint(short_option);
   }
 };
 } // namespace lldb_private
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D94917: [lldb] Fix crash in "help memory read"

2021-01-18 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.
Herald added a subscriber: JDevlieghere.

UBSAN might have caught this if we had a test that took this path but I need to 
confirm that. If so I could add some more as a smoke test of sorts, or just 
call help on every command if that's not going to take an age.

See `lldb/source/Interpreter/OptionGroupOutputFile.cpp` and 
`lldb/source/Commands/CommandObjectTarget.cpp` for two uses of these arbitrary 
short_option values. The calls to islower/upper are in 
`lldb/source/Interpreter/Options.cpp` `Options::GenerateOptionUsage`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94917

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


[Lldb-commits] [PATCH] D94890: Makefile.rules: Avoid redundant .d generation and make restart

2021-01-18 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay updated this revision to Diff 317382.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Don't use double-colon. 
https://lists.gnu.org/archive/html/help-make/2021-01/msg00016.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94890

Files:
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -570,13 +570,8 @@
 # Make the archive
 #--
 ifneq "$(ARCHIVE_NAME)" ""
-ifeq "$(OS)" "Darwin"
-$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS)
-   $(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
-   $(RM) $(ARCHIVE_OBJECTS)
-else
-$(ARCHIVE_NAME) : $(foreach 
ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj)))
-endif
+$(ARCHIVE_NAME): $(ARCHIVE_OBJECTS)
+   $(AR) $(ARFLAGS) $@ $^
 endif
 
 #--
@@ -628,12 +623,24 @@
 # Make the precompiled header and compile C++ sources against it
 #--
 
-#ifneq "$(PCH_OUTPUT)" ""
+ifneq "$(PCH_OUTPUT)" ""
 $(PCH_OUTPUT) : $(PCH_CXX_SOURCE)
$(CXX) $(CXXFLAGS) -x c++-header -o $@ $<
-%.o : %.cpp $(PCH_OUTPUT)
-   $(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $<
-#endif
+endif
+
+.SUFFIXES:
+
+%.o: %.c %.d
+   $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
+
+%.o: %.cpp %.d $(PCH_OUTPUT)
+   $(CXX) $(PCHFLAGS) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
+
+%.o: %.m %.d
+   $(CC) $(CFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
+
+%.o: %.mm %.d
+   $(CXX) $(CXXFLAGS) -MT $@ -MD -MP -MF $*.d -c -o $@ $<
 
 #--
 # Automatic variables based on items already entered. Below we create
@@ -641,43 +648,21 @@
 # that end with .c with .o, and we also create a list of prerequisite
 # files by replacing all .c files with .d.
 #--
-PREREQS := $(OBJECTS:.o=.d)
+PREREQS := $(OBJECTS:.o=.d) $(ARCHIVE_OBJECTS:.o=.d)
 DWOS := $(OBJECTS:.o=.dwo) $(ARCHIVE_OBJECTS:.o=.dwo)
 ifneq "$(DYLIB_NAME)" ""
DYLIB_PREREQS := $(DYLIB_OBJECTS:.o=.d)
DYLIB_DWOS := $(DYLIB_OBJECTS:.o=.dwo)
 endif
 
-#--
-# Rule for Generating Prerequisites Automatically using .d files and
-# the compiler -MM option. The -M option will list all system headers,
-# and the -MM option will list all non-system dependencies.
-#--
-%.d: %.c
-   $(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o
-
-%.d: %.cpp
-   @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o
-
-%.d: %.m
-   @$(CC) -M $(CFLAGS) $< -MF $@ -MT $@ -MT $*.o
-
-%.d: %.mm
-   @$(CXX) -M $(CXXFLAGS) $< -MF $@ -MT $@ -MT $*.o
+# Don't error if a .d file is deleted.
+$(PREREQS) $(DYLIB_PREREQS): ;
 
 #--
 # Include all of the makefiles for each source file so we don't have
 # to manually track all of the prerequisites for each source file.
 #--
-sinclude $(PREREQS)
-ifneq "$(DYLIB_NAME)" ""
-   sinclude $(DYLIB_PREREQS)
-endif
-
-# Define a suffix rule for .mm -> .o
-.SUFFIXES: .mm .o
-.mm.o:
-   $(CXX) $(CXXFLAGS) -c $<
+include $(wildcard $(PREREQS) $(DYLIB_PREREQS))
 
 .PHONY: clean
 dsym:  $(DSYM)


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -570,13 +570,8 @@
 # Make the archive
 #--
 ifneq "$(ARCHIVE_NAME)" ""
-ifeq "$(OS)" "Darwin"
-$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS)
-	$(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS)
-	$(RM) $(ARCHIVE_OBJECTS)
-else
-$(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj)))
-endif
+$(ARCHIVE_NAME): $(ARCHIVE_OBJECTS)
+	$(AR) $(ARFLAGS) $@ $^
 endif
 
 #--
@@ -628,12 +623,24 @@
 # Make the precompiled header and compile C++ sources against it
 #--
 
-#ifneq "$(PCH_OUTPUT)" ""
+ifneq "$(PCH_OUTPUT)" ""
 $(PCH_OUTPUT) : $(PCH_CXX_SOURCE)
 	$(CXX) $(CXXFLAGS) -x c++-header -o $@ $<
-%.o : %.cpp $(PCH_OUTPUT)
-	$(CXX) $(PCHFLAGS) $(CXXFLAGS) -c -o $@ $<
-#endif
+endif
+
+.SUFFIXES

[Lldb-commits] [lldb] a58acef - [lldb][docs] Use 'any' as the default role in LLDB's sphinx project

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

Author: Raphael Isemann
Date: 2021-01-18T19:08:19+01:00
New Revision: a58aceffad61ebffb1a860763299b3307041efa6

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

LOG: [lldb][docs] Use 'any' as the default role in LLDB's sphinx project

sphinx processes text in backticks depending on what 'role' it has (e.g.,
`:code:\`blub\`` -> role is `code`). If no role is provided, the default role is
taken which is right now using the default value of `content`. `content` only
really makes the text cursive which isn't really useful for anything right now.

Sphinx recommends using the `any` role by default [1] as that turns text in
backticks without an explicit roles into some kind of smart reference. If we did
this in LLDB, then we could just reference SB API classes by doing `\`SBValue\``
instead of typing out the rather verbose `:py:class:`/`:py:func:`/... role
before each reference. This would be especially nice when writing the SB API
docs itself as we constantly have to reference other classes.

[1] 
https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-any

Reviewed By: JDevlieghere

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

Added: 


Modified: 
lldb/docs/conf.py
lldb/docs/use/python.rst
lldb/docs/use/variable.rst

Removed: 




diff  --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index b5b594538239..2c7cd5d94c1f 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -98,8 +98,9 @@
 # directories to ignore when looking for source files.
 exclude_patterns = ['_build', 'analyzer']
 
-# The reST default role (used for this markup: `text`) to use for all 
documents.
-#default_role = None
+# Use the recommended 'any' rule so that referencing SB API classes is possible
+# by just writing `SBData`.
+default_role = 'any'
 
 # If true, '()' will be appended to :func: etc. cross-reference text.
 #add_function_parentheses = True

diff  --git a/lldb/docs/use/python.rst b/lldb/docs/use/python.rst
index 6b2125705086..efbe0d732c12 100644
--- a/lldb/docs/use/python.rst
+++ b/lldb/docs/use/python.rst
@@ -110,10 +110,10 @@ kind of Python variable will it be? The answers are to 
use the LLDB API
 functions, provided as part of the LLDB Python module. Running Python
 from inside LLDB, LLDB will automatically give us our current frame
 object as a Python variable, "lldb.frame". This variable has the type
-"SBFrame" (see the LLDB API for more information about SBFrame
+`SBFrame` (see the LLDB API for more information about `SBFrame`
 objects). One of the things we can do with a frame object, is to ask it
 to find and return its local variable. We will call the API function
-"FindVariable" on the lldb.frame object to give us our dictionary
+`SBFrame.FindVariable` on the lldb.frame object to give us our dictionary
 variable as a Python variable:
 
 ::
@@ -125,11 +125,11 @@ current frame to find the variable named "dictionary" and 
return it. We then
 store the returned value in the Python variable named "root". This answers the
 question of HOW to get the variable, but it still doesn't explain WHAT actually
 gets put into "root". If you examine the LLDB API, you will find that the
-SBFrame method "FindVariable" returns an object of type SBValue. SBValue
+`SBFrame` method "FindVariable" returns an object of type `SBValue`. `SBValue`
 objects are used, among other things, to wrap up program variables and values.
-There are many useful methods defined in the SBValue class to allow you to get
+There are many useful methods defined in the `SBValue` class to allow you to 
get
 information or children values out of SBValues. For complete information, see
-the header file SBValue.h. The SBValue methods that we use in our DFS function
+the header file SBValue.h. The `SBValue` methods that we use in our DFS 
function
 are ``GetChildMemberWithName()``, ``GetSummary()``, and ``GetValue()``.
 
 

diff  --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index ae6dbf2f4e5e..b9bcdf57cdde 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -677,7 +677,7 @@ passed two parameters: ``valobj`` and ``internal_dict``.
 not touch it.
 
 ``valobj`` is the object encapsulating the actual variable being displayed, and
-its type is SBValue. Out of the many possible operations on an SBValue, the
+its type is `SBValue`. Out of the many possible operations on an `SBValue`, the
 basic one is retrieve the children objects it contains (essentially, the fields
 of the object wrapped by it), by calling ``GetChildMemberWithName()``, passing
 it the child's name as a string.
@@ -685,15 +685,15 @@ it the child's name as a string.
 If the variable has a value, you can ask for it, and return it as a string
 using ``GetValue()``, or as a signed/unsigned number using
 `

[Lldb-commits] [PATCH] D94899: [lldb][docs] Use 'any' as the default role in LLDB's sphinx project

2021-01-18 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa58aceffad61: [lldb][docs] Use 'any' as the 
default role in LLDB's sphinx project (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94899

Files:
  lldb/docs/conf.py
  lldb/docs/use/python.rst
  lldb/docs/use/variable.rst

Index: lldb/docs/use/variable.rst
===
--- lldb/docs/use/variable.rst
+++ lldb/docs/use/variable.rst
@@ -677,7 +677,7 @@
 not touch it.
 
 ``valobj`` is the object encapsulating the actual variable being displayed, and
-its type is SBValue. Out of the many possible operations on an SBValue, the
+its type is `SBValue`. Out of the many possible operations on an `SBValue`, the
 basic one is retrieve the children objects it contains (essentially, the fields
 of the object wrapped by it), by calling ``GetChildMemberWithName()``, passing
 it the child's name as a string.
@@ -685,15 +685,15 @@
 If the variable has a value, you can ask for it, and return it as a string
 using ``GetValue()``, or as a signed/unsigned number using
 ``GetValueAsSigned()``, ``GetValueAsUnsigned()``. It is also possible to
-retrieve an SBData object by calling ``GetData()`` and then read the object's
-contents out of the SBData.
+retrieve an `SBData` object by calling ``GetData()`` and then read the object's
+contents out of the `SBData`.
 
 If you need to delve into several levels of hierarchy, as you can do with
 summary strings, you can use the method ``GetValueForExpressionPath()``,
 passing it an expression path just like those you could use for summary strings
 (one of the differences is that dereferencing a pointer does not occur by
 prefixing the path with a ``*```, but by calling the ``Dereference()`` method
-on the returned SBValue). If you need to access array slices, you cannot do
+on the returned `SBValue`). If you need to access array slices, you cannot do
 that (yet) via this method call, and you must use ``GetChildAtIndex()``
 querying it for the array items one by one. Also, handling custom formats is
 something you have to deal with on your own.
@@ -874,9 +874,9 @@
 implementing it in terms of num_children is acceptable, implementors are
 encouraged to look for optimized coding alternatives whenever reasonable.
 
-[3] This method is optional (starting with SVN revision 219330). The SBValue
+[3] This method is optional (starting with SVN revision 219330). The `SBValue`
 you return here will most likely be a numeric type (int, float, ...) as its
-value bytes will be used as-if they were the value of the root SBValue proper.
+value bytes will be used as-if they were the value of the root `SBValue` proper.
 As a shortcut for this, you can inherit from lldb.SBSyntheticValueProvider, and
 just define get_value as other methods are defaulted in the superclass as
 returning default no-children responses.
@@ -913,7 +913,7 @@
 feature, as it is a very easy and well commented example.
 
 The design pattern consistently used in synthetic providers shipping with LLDB
-is to use the __init__ to store the SBValue instance as a part of self. The
+is to use the __init__ to store the `SBValue` instance as a part of self. The
 update function is then used to perform the actual initialization. Once a
 synthetic children provider is written, one must load it into LLDB before it
 can be used. Currently, one can use the LLDB script command to type Python code
Index: lldb/docs/use/python.rst
===
--- lldb/docs/use/python.rst
+++ lldb/docs/use/python.rst
@@ -110,10 +110,10 @@
 functions, provided as part of the LLDB Python module. Running Python
 from inside LLDB, LLDB will automatically give us our current frame
 object as a Python variable, "lldb.frame". This variable has the type
-"SBFrame" (see the LLDB API for more information about SBFrame
+`SBFrame` (see the LLDB API for more information about `SBFrame`
 objects). One of the things we can do with a frame object, is to ask it
 to find and return its local variable. We will call the API function
-"FindVariable" on the lldb.frame object to give us our dictionary
+`SBFrame.FindVariable` on the lldb.frame object to give us our dictionary
 variable as a Python variable:
 
 ::
@@ -125,11 +125,11 @@
 store the returned value in the Python variable named "root". This answers the
 question of HOW to get the variable, but it still doesn't explain WHAT actually
 gets put into "root". If you examine the LLDB API, you will find that the
-SBFrame method "FindVariable" returns an object of type SBValue. SBValue
+`SBFrame` method "FindVariable" returns an object of type `SBValue`. `SBValue`
 objects are used, among other things, to wrap up program variables and values.
-There are many useful me

[Lldb-commits] [PATCH] D93649: [lldb/Lua] add support for Lua function breakpoint

2021-01-18 Thread Pedro Tammela via Phabricator via lldb-commits
tammela updated this revision to Diff 317395.
tammela added a comment.

Addressing comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93649

Files:
  lldb/bindings/lua/lua-swigsafecast.swig
  lldb/bindings/lua/lua-wrapper.swig
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test
  lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp

Index: lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
===
--- lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
+++ lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
@@ -24,10 +24,9 @@
 #pragma warning (disable : 4190)
 #endif
 
-extern "C" llvm::Expected
-LLDBSwigLuaBreakpointCallbackFunction(lua_State *L,
-  lldb::StackFrameSP stop_frame_sp,
-  lldb::BreakpointLocationSP bp_loc_sp) {
+extern "C" llvm::Expected LLDBSwigLuaBreakpointCallbackFunction(
+lua_State *L, lldb::StackFrameSP stop_frame_sp,
+lldb::BreakpointLocationSP bp_loc_sp, StructuredDataImpl *extra_args_impl) {
   return false;
 }
 
Index: lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test
@@ -0,0 +1,21 @@
+# REQUIRES: lua
+# RUN: echo "int main() { return 0; }" | %clang_host -x c - -o %t
+# RUN: %lldb -s %s --script-language lua %t 2>&1 | FileCheck %s
+b main
+script
+function abc(a, b, c, ...)
+print(c)
+end
+quit
+breakpoint command add -s lua -F abc
+r
+# CHECK: nil
+breakpoint command add -s lua -F abc -k foo -v 123
+r
+# CHECK: 
+breakpoint command add -s lua -o "abc(frame, bp_loc, ...)"
+r
+# CHECK: nil
+breakpoint command add -s lua -F typo
+r
+# CHECK: attempt to call a nil value
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_ScriptInterpreterLua_h_
 #define liblldb_ScriptInterpreterLua_h_
 
+#include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/lldb-enumerations.h"
@@ -22,6 +23,11 @@
 CommandDataLua() : BreakpointOptions::CommandData() {
   interpreter = lldb::eScriptLanguageLua;
 }
+CommandDataLua(StructuredData::ObjectSP extra_args_sp)
+: BreakpointOptions::CommandData(), m_extra_args_sp(extra_args_sp) {
+  interpreter = lldb::eScriptLanguageLua;
+}
+StructuredData::ObjectSP m_extra_args_sp;
   };
 
   ScriptInterpreterLua(Debugger &debugger);
@@ -72,9 +78,17 @@
   Status SetBreakpointCommandCallback(BreakpointOptions *bp_options,
   const char *command_body_text) override;
 
+  Status SetBreakpointCommandCallbackFunction(
+  BreakpointOptions *bp_options, const char *function_name,
+  StructuredData::ObjectSP extra_args_sp) override;
+
 private:
   std::unique_ptr m_lua;
   bool m_session_is_active = false;
+
+  Status RegisterBreakpointCallback(BreakpointOptions *bp_options,
+const char *command_body_text,
+StructuredData::ObjectSP extra_args_sp);
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -264,8 +264,9 @@
   debugger.GetScriptInterpreter(true, eScriptLanguageLua));
   Lua &lua = lua_interpreter->GetLua();
 
-  llvm::Expected BoolOrErr =
-  lua.CallBreakpointCallback(baton, stop_frame_sp, bp_loc_sp);
+  CommandDataLua *bp_option_data = static_cast(baton);
+  llvm::Expected BoolOrErr = lua.CallBreakpointCallback(
+  baton, stop_frame_sp, bp_loc_sp, bp_option_data->m_extra_args_sp);
   if (llvm::Error E = BoolOrErr.takeError()) {
 debugger.GetErrorStream() << toString(std::move(E));
 return true;
@@ -283,10 +284,25 @@
   m_debugger.RunIOHandlerAsync(io_handler_sp);
 }
 
+Status ScriptInterpreterLua::SetBreakpointCommandCallbackFunction(
+BreakpointOptions *bp_options, const char *function_name,
+StructuredData::ObjectSP extra_args_sp) {
+  const char *fmt_str = "return {0}(frame, bp_loc, ...)";
+  std::string oneliner = llvm::formatv(fmt_str, funct

[Lldb-commits] [PATCH] D93649: [lldb/Lua] add support for Lua function breakpoint

2021-01-18 Thread Pedro Tammela via Phabricator via lldb-commits
tammela added inline comments.



Comment at: lldb/bindings/lua/lua-wrapper.swig:25-29
+   auto extra_args = [&]() -> llvm::Optional {
+  if (extra_args_impl == nullptr)
+ return {};
+  return lldb::SBStructuredData(extra_args_impl);
+   } ();

JDevlieghere wrote:
> I don't think you need the lambda. I used `unique_ptr` but `llvm:Optional` 
> would work as well. 
`{}` is not valid on the ternary operator, but I think the version suits your 
suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93649

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


[Lldb-commits] [PATCH] D94937: [lldb] change SBStructuredData GetStringValue signature

2021-01-18 Thread Pedro Tammela via Phabricator via lldb-commits
tammela created this revision.
tammela requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch changes the GetStringValue method on the SBStructuredData
class to return a `const char *`.

This change allows the use of the method on the Lua interpreter.
The auto-generated Lua binding can't handle `char *` arguments
properly. That's because it forces the method call with a `char *` like
Lua object.

This means that to retrieve the string value an operation would need to write 
to an
internal Lua string, instead of using the Lua C API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94937

Files:
  lldb/bindings/interface/SBStructuredData.i
  lldb/examples/python/in_call_stack.py
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Core/StructuredDataImpl.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/source/API/SBStructuredData.cpp
  lldb/test/API/commands/platform/basic/TestPlatformPython.py
  lldb/test/API/commands/target/stop-hooks/stop_hook.py
  lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py
  lldb/test/API/functionalities/breakpoint/scripted_bkpt/resolver.py
  
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
  lldb/test/API/functionalities/step_scripted/Steps.py
  lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
  lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test

Index: lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test
===
--- lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test
+++ lldb/test/Shell/ScriptInterpreter/Lua/breakpoint_function_callback.test
@@ -5,6 +5,7 @@
 script
 function abc(a, b, c, ...)
 print(c)
+if c then print(c:GetValueForKey("foo"):GetStringValue()) end
 end
 quit
 breakpoint command add -s lua -F abc
Index: lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
===
--- lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
+++ lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
@@ -100,7 +100,7 @@
 self.fail("Wrong type returned: " + str(string_struct.GetType()))
 
 # Check API returning 'string' value
-output = string_struct.GetStringValue(25)
+output = string_struct.GetStringValue()
 if not "STRING" in output:
 self.fail("wrong output: " + output)
 
@@ -131,7 +131,7 @@
 
 # Calling wrong API on a SBStructuredData
 # (e.g. getting a string value from an integer type structure)
-output = int_struct.GetStringValue(25)
+output = int_struct.GetStringValue()
 if output:
 self.fail(
 "Valid string " +
@@ -192,7 +192,7 @@
 self.fail("A valid object should have been returned")
 if not string_struct.GetType() == lldb.eStructuredDataTypeString:
 self.fail("Wrong type returned: " + str(string_struct.GetType()))
-output = string_struct.GetStringValue(5)
+output = string_struct.GetStringValue()
 if not output == "23":
 self.fail("wrong output: " + str(output))
 
@@ -201,6 +201,6 @@
 self.fail("A valid object should have been returned")
 if not string_struct.GetType() == lldb.eStructuredDataTypeString:
 self.fail("Wrong type returned: " + str(string_struct.GetType()))
-output = string_struct.GetStringValue(5)
+output = string_struct.GetStringValue()
 if not output == "arr":
 self.fail("wrong output: " + str(output))
Index: lldb/test/API/functionalities/step_scripted/Steps.py
===
--- lldb/test/API/functionalities/step_scripted/Steps.py
+++ lldb/test/API/functionalities/step_scripted/Steps.py
@@ -45,7 +45,7 @@
 
 if not func_entry.IsValid():
 print("Did not get a valid entry for variable_name")
-func_name = func_entry.GetStringValue(100)
+func_name = func_entry.GetStringValue()
 
 self.value = self.frame.FindVariable(func_name)
 if self.value.GetError().Fail():
@@ -88,7 +88,7 @@
 
 def __init__(self, thread_plan, args_data, dict):
 self.thread_plan = thread_plan
-self.key = args_data.GetValueForKey("token").GetStringValue(1000)
+self.key = args_data.GetValueForKey("token").GetStringValue()
 
 def should_stop(self, event):
 self.thread_plan.SetPlanComplete(True)
Index: lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
===
--- lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ lldb/test/API/functionalities/breakpoint/serialize/TestBrea

[Lldb-commits] [PATCH] D94937: [lldb] change SBStructuredData GetStringValue signature

2021-01-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere requested changes to this revision.
JDevlieghere added a comment.
This revision now requires changes to proceed.

We guarantee that the SB API is ABI stable so you cannot change the signature 
of existing functions. Would an overload do the trick?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94937

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


[Lldb-commits] [PATCH] D94937: [lldb] change SBStructuredData GetStringValue signature

2021-01-18 Thread Pedro Tammela via Phabricator via lldb-commits
tammela updated this revision to Diff 317439.
tammela added a comment.

Removing spurious line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94937

Files:
  lldb/bindings/interface/SBStructuredData.i
  lldb/examples/python/in_call_stack.py
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Core/StructuredDataImpl.h
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/source/API/SBStructuredData.cpp
  lldb/test/API/commands/platform/basic/TestPlatformPython.py
  lldb/test/API/commands/target/stop-hooks/stop_hook.py
  lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py
  lldb/test/API/functionalities/breakpoint/scripted_bkpt/resolver.py
  
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
  lldb/test/API/functionalities/step_scripted/Steps.py
  lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py

Index: lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
===
--- lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
+++ lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
@@ -100,7 +100,7 @@
 self.fail("Wrong type returned: " + str(string_struct.GetType()))
 
 # Check API returning 'string' value
-output = string_struct.GetStringValue(25)
+output = string_struct.GetStringValue()
 if not "STRING" in output:
 self.fail("wrong output: " + output)
 
@@ -131,7 +131,7 @@
 
 # Calling wrong API on a SBStructuredData
 # (e.g. getting a string value from an integer type structure)
-output = int_struct.GetStringValue(25)
+output = int_struct.GetStringValue()
 if output:
 self.fail(
 "Valid string " +
@@ -192,7 +192,7 @@
 self.fail("A valid object should have been returned")
 if not string_struct.GetType() == lldb.eStructuredDataTypeString:
 self.fail("Wrong type returned: " + str(string_struct.GetType()))
-output = string_struct.GetStringValue(5)
+output = string_struct.GetStringValue()
 if not output == "23":
 self.fail("wrong output: " + str(output))
 
@@ -201,6 +201,6 @@
 self.fail("A valid object should have been returned")
 if not string_struct.GetType() == lldb.eStructuredDataTypeString:
 self.fail("Wrong type returned: " + str(string_struct.GetType()))
-output = string_struct.GetStringValue(5)
+output = string_struct.GetStringValue()
 if not output == "arr":
 self.fail("wrong output: " + str(output))
Index: lldb/test/API/functionalities/step_scripted/Steps.py
===
--- lldb/test/API/functionalities/step_scripted/Steps.py
+++ lldb/test/API/functionalities/step_scripted/Steps.py
@@ -45,7 +45,7 @@
 
 if not func_entry.IsValid():
 print("Did not get a valid entry for variable_name")
-func_name = func_entry.GetStringValue(100)
+func_name = func_entry.GetStringValue()
 
 self.value = self.frame.FindVariable(func_name)
 if self.value.GetError().Fail():
@@ -88,7 +88,7 @@
 
 def __init__(self, thread_plan, args_data, dict):
 self.thread_plan = thread_plan
-self.key = args_data.GetValueForKey("token").GetStringValue(1000)
+self.key = args_data.GetValueForKey("token").GetStringValue()
 
 def should_stop(self, event):
 self.thread_plan.SetPlanComplete(True)
Index: lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
===
--- lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -407,7 +407,7 @@
 
 for idx in range(0, orig_keys.GetSize()):
 key = orig_keys.GetStringAtIndex(idx)
-copy_value = copy_extra_args.GetValueForKey(key).GetStringValue(100)
+copy_value = copy_extra_args.GetValueForKey(key).GetStringValue()
 
 if key == "first_arg":
 self.assertEqual(copy_value, "first_value")
Index: lldb/test/API/functionalities/breakpoint/scripted_bkpt/resolver.py
===
--- lldb/test/API/functionalities/breakpoint/scripted_bkpt/resolver.py
+++ lldb/test/API/functionalities/breakpoint/scripted_bkpt/resolver.py
@@ -15,7 +15,7 @@
   sym_name = "not_a_real_function_name"
   sym_item = self.extra_args.GetValueForKey("symbol")
   if sym_item.IsValid():
-  sym_name = sym_item.GetStringValue(1000)
+  sym_name = sym_item.GetStringValue()
   else:
   print("Didn't have a

[Lldb-commits] [PATCH] D94937: [lldb] change SBStructuredData GetStringValue signature

2021-01-18 Thread Pedro Tammela via Phabricator via lldb-commits
tammela added a comment.

In D94937#2505676 , @JDevlieghere 
wrote:

> We guarantee that the SB API is ABI stable so you cannot change the signature 
> of existing functions. Would an overload do the trick?

Hmmm, that's tricky. I will see if I can come up with something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94937

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


[Lldb-commits] [PATCH] D94888: [lldb] Add -Wl, -rpath to make tests run with fresh built libc++

2021-01-18 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

(Works for me, FWIW - takes my local run down from 42 failures in 
check-lldb-api to 1 (a timeout))

Out of curiousity did you find a way to get lldb-test to print out the 
stdout/stderr of the underlying lldb process to see what error messages it was 
producing that demonstrated this failure? I was trying to figure out how to do 
that, and it seems like a good thing to be able to do for this issue or others 
down the way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94888

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


Re: [Lldb-commits] [PATCH] D94063: lldb: Add support for DW_AT_ranges on DW_TAG_subprograms

2021-01-18 Thread David Blaikie via lldb-commits
On Thu, Jan 14, 2021 at 2:56 PM Jim Ingham  wrote:
>
> How were you setting the breakpoint in the case where it was failing from the 
> command line?  The breakpoint you are examining in the test in your patches 
> is a "source regular expression" breakpoint.  That would be "break set -p".  
> If you were also doing that in the command line and got a different result 
> that would be very odd, since neither interface (CLI or SB) does much work 
> before handing the request off to the common routine.  If (as I suspect) you 
> were doing "b main.c:40" in the command line, then you should make a 
> breakpoint with SBTarget.BreakpointCreateByLocation and see if that shows the 
> same problem.  That should do the same job as "break set --file --line".

Ah, thanks for the explanation (didn't realize lldb natively supported
setting a breakpoint by regex - figured that was just in the test
helpers and mapped down to setting a breakpoint by line).

I tried setting the breakpoint by regex to more closely match the API
test & still can't seem to reproduce the behavior inside the API test
outside of it:

$ 
LD_LIBRARY_PATH=/usr/local/google/home/blaikie/dev/llvm/build/default/lib:/usr/local/google/home/blaikie/install/lib:/usr/local/google/home/blaikie/install/lib64
./bin/lldb 
./lldb-test-build.noindex/lang/c/stepping/TestStepAndBreakpoints.test_and_python_api/a.out


 (lldb) target create
"./lldb-test-build.noindex/lang/c/stepping/TestStepAndBreakpoints.test_and_python_api/a.out"
Current executable set to
'/usr/local/google/home/blaikie/dev/llvm/build/default/lldb-test-build.noindex/lang/c/stepping/TestStepAndBreakpoints.test_and_python_api/a.out'
(x86_64).
(lldb) break set -p "// frame select 2, thread step-out while stopped at .c.1.."
Breakpoint 1: where = a.out`main + 22, address = 0x004011c6

(still missing the file/line information, despite the (see patch
attached to the previous for the test changes) test seeming to test
the same behavior & appears to print the file/line correctly:

   
self.assertEqual(get_description(break_1_in_main.locations[0].GetAddress().line_entry),
"narf")
AssertionError:
'/usr/local/google/home/blaikie/dev/llvm/src/lldb/test/API/lang/c/stepping/main.c:40:14'
!= 'narf'
- 
/usr/local/google/home/blaikie/dev/llvm/src/lldb/test/API/lang/c/stepping/main.c:40:14+
narf
)

I'm wondering if maybe something is picking up some other artifact in
my environment - the same issue with me needing to set the
LD_LIBRARY_PATH - hmm, maybe not (I uninstalled all other lldb things
I can think of, so it's not picking up some system/user installed copy
and running different code, so far as I can think)

> Note, you can also run the command line breakpoint command in API tests.  
> That's sometimes required, particularly if there's something about a 
> combination of command flags that you want to test.  Just use the 
> lldbutil.run_break_set_by_file_and_line utility.  That centralizes running 
> and checking the basic results of the break set command, so if we do change 
> the break command we only have to fix one place...  In your case the checks 
> that run_break_set_by_file_and_line do should suffice, but the command 
> returns the created breakpoint number, so if you want to poke at it further, 
> you can use  target.FindBreakpointByID to get the SBBreakpoint you just made. 
>  There are also wrappers for the other lldb breakpoint types you can make 
> from the command line, BTW.
>
> Jim
>
>
>
> > On Jan 14, 2021, at 1:38 PM, David Blaikie  wrote:
> >
> > Thanks for the pointers!
> >
> > So I tried writing an API-type test for this line table/breakpoint
> > behavior (it doesn't seem like it's entirely/just the line table (for
> > one thing, the DWARF change is purely in the subprogram DIE, not in
> > the line table)) and I can't seem to figure it out.
> >
> > The attached patch modifies lldb to undo this patch (to show the
> > breakage) and modifies an existing API test to build with the clang
> > flag to enable ranges on subprograms - I've confirmed the DWARF built
> > by this test does have subprogram ranges.
> >
> > But my best attempt at setting the breakpoint and examining it in the
> > API test seems to produce the desired filename and line number (ie:
> > does not exhibit the bug), where interacting with lldb on the command
> > line does not render the file/line (ie: the bug).
> >
> > Jim, Pavel, anyone: Ideas on how I can/should test this behavior?
> >
> > $ ./bin/llvm-lit -v
> > tools/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
> > -- Testing: 1 tests, 1 workers --
> > FAIL: lldb-api :: lang/c/stepping/TestStepAndBreakpoints.py (1 of 1)
> >  TEST 'lldb-api ::
> > lang/c/stepping/TestStepAndBreakpoints.py' FAILED 
> > Script:
> > --
> > /usr/bin/python3.8
> > /usr/local/google/home/blaikie/dev/llvm/src/lldb/test/API/dotest.py -u
> > CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/bin/ar --env
> > OBJCOPY=/usr/bin/objcopy --en

[Lldb-commits] [lldb] 4b57400 - [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2021-01-18 Thread Richard Smith via lldb-commits

Author: Richard Smith
Date: 2021-01-18T21:05:01-08:00
New Revision: 4b574008aef5a7235c1f894ab065fe300d26e786

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

LOG: [c++20] P1907R1: Support for generalized non-type template arguments of 
scalar type.

Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
reverted because a dependency commit was reverted. This incorporates the
following follow-on commits that were also reverted:

7e84aa1b81e72d44bcc58ffe1731bfc7abb73ce0 by Simon Pilgrim
ed13d8c66781b50ff007cb089c5905f9bb9e8af2 by me
95c7b6cadbc9a3d4376ef44edbeb3c8bb5b8d7fc by Sam McCall
430d5d8429473c2b10b109991d7577a3cea41140 by Dave Zarzycki

Added: 
clang/test/CodeGenCXX/template-arguments.cpp

Modified: 
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/index/remote/Client.cpp
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TemplateArgumentVisitor.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CodeGenCXX/mangle-ms-templates.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx17.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 588bcfcf2424..bf7675e7d949 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -143,6 +143,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_ARGUMENT_KIND(Declaration);
   TEMPLATE_ARGUMENT_KIND(Template);
   TEMPLATE_ARGUMENT_KIND(TemplateExpansion);
+  TEMPLATE_ARGUMENT_KIND(UncommonValue);
 #undef TEMPLATE_ARGUMENT_KIND
 }
 llvm_unreachable("Unhandled ArgKind enum");

diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 84316659daad..98ef8b3b6d76 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -1079,6 +1079,7 @@ class ExplicitReferenceCollector
 case TemplateArgument::Pack:
 case TemplateArgument::Type:
 case TemplateArgument::Expression:
+case TemplateArgument::UncommonValue:
   break; // Handled by VisitType and VisitExpression.
 };
 return RecursiveASTVisitor::TraverseTemplateArgumentLoc(A);

diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index b09dbf915e46..a153a8812baf 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -152,7 +152,8 @@ class IndexClient : public clangd::SymbolIndex {
   });
   }
 
-  llvm::unique_function indexedFiles() const {
+  llvm::unique_function
+  indexedFiles() const override {
 // FIXME: For now we always return "false" regardless of whether the file
 //was indexed or not. A possible implementation could be based on
 //the idea that we do not want to send a request at every

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 0c5d82b3e9aa..a9bfdb4d5fa5 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2818,8 +2818,8 @@ class ASTContext : public RefCountedBase {
   /// for destruction.
   template  void addDestruction(T *Ptr) const {
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr =

[Lldb-commits] [PATCH] D82863: [LLDB] Add support to resize SVE registers at run-time

2021-01-18 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Looks good, thanks.


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

https://reviews.llvm.org/D82863

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


[Lldb-commits] [PATCH] D94917: [lldb] Fix crash in "help memory read"

2021-01-18 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/include/lldb/Utility/OptionDefinition.h:52
+// Must not have any bits set outside of unsigned char range
+return !(short_option & ~((1 << CHAR_BIT) - 1)) &&
+   llvm::isPrint(short_option);

Something like `llvm::is(U)Int(short_option)` would better convey the 
intention.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94917

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


[Lldb-commits] [PATCH] D94890: Makefile.rules: Avoid redundant .d generation and make restart

2021-01-18 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looks like a nice cleanup. The only part I am not sure of is the part about 
removing `$(RM) $(ARCHIVE_OBJECTS)`. Is that necessary?
I'm not sure why is that line there, but if I had to guess, I would say it's to 
ensure that lldb (on macos) reads debug info from the archive file instead of 
the original .o files. If it's not required, it may be better to leave it in. 
Otherwise, someone from Apple should say whether that is ok (testing archives 
is only really interesting on fruity platforms).

BTW, have you measured any speedups from these improvements?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94890

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