[Lldb-commits] [lldb] b74ae43 - Makefile.rules: Make HOST_OS/OS simply expanded variable to avoid excess uname -s invocations

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

Author: Fangrui Song
Date: 2021-01-17T17:19:29-08:00
New Revision: b74ae43c44b1c954508149409d3cfe6477be4079

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

LOG: Makefile.rules: Make HOST_OS/OS simply expanded variable to avoid excess 
uname -s invocations

This decreases the number of runs from 18 to 1.

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index a7efa15e09df..d715f1ca24e4 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -56,12 +56,12 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
-HOST_OS = $(shell uname -s)
+HOST_OS := $(shell uname -s)
 ifneq (,$(findstring windows32,$(HOST_OS)))
-   HOST_OS = Windows_NT
+   HOST_OS := Windows_NT
 endif
 ifeq "$(OS)" ""
-   OS = $(HOST_OS)
+   OS := $(HOST_OS)
 endif
 
 #--



___
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-17 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay created this revision.
MaskRay added reviewers: friss, JDevlieghere, labath, rupprecht.
MaskRay requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Take an example when `CXX_SOURCES` is main.cpp.

main.d is a included file. make will rebuild main.d, re-executes itself [1] to 
read
in the new main.d file, then rebuild main.o, finally link main.o into a.out.
main.cpp is parsed twice in this process.

This patch merges .d generation into .o generation [2], writes explicit rules
for .c/.m and deletes suffix rules for %.m and %.o. Since a target can be
satisfied by either of .c/.cpp/.m/.mm, we use double-colon rules [3].

Since suffix rules are disabled, the implicit rule for archive member targets is
no long available [4]. Rewrite and simplify the archive rule.

[1]: https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html
[2]: http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
[3]: https://www.gnu.org/software/make/manual/html_node/Double_002dColon.html
[4]: https://www.gnu.org/software/make/manual/html_node/Archive-Update.html

ObjC/ObjCXX tests only run on macOS. I don't have testing environment.  Hope
someone can do it for me.


Repository:
  rG LLVM Github Monorepo

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-commits] [PATCH] D94888: [lldb] Add -Wl, -rpath to make tests run with fresh built libc++

2021-01-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

You seem to be removing more than adding there.


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


[Lldb-commits] [lldb] 95d1461 - Makefile.rules: Delete GCC 4.6 workaround

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

Author: Fangrui Song
Date: 2021-01-17T13:16:38-08:00
New Revision: 95d146182fdf2315e74943b93fb3bb0cbafc5d89

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

LOG: Makefile.rules: Delete GCC 4.6 workaround

5.1 is the minimum supported version.

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 5f6218db4d6d..a7efa15e09df 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -513,20 +513,6 @@ ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" ""
endif
 endif
 
-#--
-# Check if we are compiling with gcc 4.6
-#--
-ifneq "$(strip $(CXX_SOURCES) $(OBJCXX_SOURCES))" ""
-ifneq "$(filter g++,$(CXX))" ""
-   CXXVERSION = $(shell $(CXX) -dumpversion | cut -b 1-3)
-   ifeq "$(CXXVERSION)" "4.6"
-   # GCC 4.6 cannot handle -std=c++11, so replace it with 
-std=c++0x
-   # instead. FIXME: remove once GCC version is upgraded.
-   override CXXFLAGS := $(subst -std=c++11,-std=c++0x,$(CXXFLAGS))
-   endif
-endif
-endif
-
 ifeq ($(findstring clang, $(CXX)), clang)
CXXFLAGS += --driver-mode=g++
 endif



___
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-17 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay created this revision.
MaskRay added reviewers: dblaikie, labath, mgorny, rupprecht.
Herald added a subscriber: krytarowski.
MaskRay requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

On my Debian machine, system libc++/libc++abi is not installed (`libc++1-9 
libc++abi-9`),
21 check-lldb-api tests fail because -stdlib=libc++ linked executables cannot
find runtime libc++.so.1 at runtime.

Use the `-Wl,-rpath,$(LLVM_LIBS_DIR)` mechanism in
`packages/Python/lldbsuite/test/make/Makefile.rules` (D58630 
 for NetBSD) to
allow such tests compile/link with fresh libc++ built beside lldb.
(A system libc++.so.1 is not guaranteed to match fresh libc++ header files.)

Some tweaks to the existing NetBSD rule when generalizing:

- Drop `-L$(LLVM_LIBS_DIR)` since Clang driver adds it correctly.
- Add `-stdlib=libc++` only for `USE_LIBCPP`.

Also, drop `-isystem /usr/include/c++/v1` introduced in D9426 
. It is not needed
by Clang driver. GCC using libc++ requires more setup.

I don't find any test needing `-Wl,-rpath` in 
`test/Shell/helper/{build,toolchain}.py` (D58630 
 for NetBSD added them).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94888

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
@@ -281,11 +281,6 @@
 LD = $(CC)
 LDFLAGS ?= $(CFLAGS)
 LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
-ifneq (,$(LLVM_LIBS_DIR))
-   ifeq ($(OS),NetBSD)
-   LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LLVM_LIBS_DIR)
-   endif
-endif
 ifeq (,$(filter $(OS), Windows_NT Android Darwin))
ifneq (,$(filter YES,$(ENABLE_THREADS)))
LDFLAGS += -pthread
@@ -395,21 +390,18 @@
 
 ifeq (1,$(USE_LIBCPP))
CXXFLAGS += -DLLDB_USING_LIBCPP
-   ifeq "$(OS)" "Linux"
-   ifneq (,$(findstring clang,$(CC)))
-   CXXFLAGS += -stdlib=libc++
-   LDFLAGS += -stdlib=libc++
-   else
-   CXXFLAGS += -isystem /usr/include/c++/v1
-   LDFLAGS += -lc++
-   endif
-   else ifeq "$(OS)" "Android"
+   ifeq "$(OS)" "Android"
# Nothing to do, this is already handled in
# Android.rules.
else
CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
endif
+   ifneq (,$(filter $(OS), FreeBSD Linux NetBSD))
+   ifneq (,$(LLVM_LIBS_DIR))
+   LDFLAGS += -Wl,-rpath,$(LLVM_LIBS_DIR)
+   endif
+   endif
 endif
 
 #--


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
@@ -281,11 +281,6 @@
 LD = $(CC)
 LDFLAGS ?= $(CFLAGS)
 LDFLAGS += $(LD_EXTRAS) $(ARCH_LDFLAGS)
-ifneq (,$(LLVM_LIBS_DIR))
-	ifeq ($(OS),NetBSD)
-		LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LLVM_LIBS_DIR)
-	endif
-endif
 ifeq (,$(filter $(OS), Windows_NT Android Darwin))
 	ifneq (,$(filter YES,$(ENABLE_THREADS)))
 		LDFLAGS += -pthread
@@ -395,21 +390,18 @@
 
 ifeq (1,$(USE_LIBCPP))
 	CXXFLAGS += -DLLDB_USING_LIBCPP
-	ifeq "$(OS)" "Linux"
-		ifneq (,$(findstring clang,$(CC)))
-			CXXFLAGS += -stdlib=libc++
-			LDFLAGS += -stdlib=libc++
-		else
-			CXXFLAGS += -isystem /usr/include/c++/v1
-			LDFLAGS += -lc++
-		endif
-	else ifeq "$(OS)" "Android"
+	ifeq "$(OS)" "Android"
 		# Nothing to do, this is already handled in
 		# Android.rules.
 	else
 		CXXFLAGS += -stdlib=libc++
 		LDFLAGS += -stdlib=libc++
 	endif
+	ifneq (,$(filter $(OS), FreeBSD Linux NetBSD))
+		ifneq (,$(LLVM_LIBS_DIR))
+			LDFLAGS += -Wl,-rpath,$(LLVM_LIBS_DIR)
+		endif
+	endif
 endif
 
 #--
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a89242d - [lldb] Skip TestPlatformProcessConnect on windows and darwin

2021-01-17 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-01-17T20:18:55+01:00
New Revision: a89242d874df72cddeafbebc75ac377371e72796

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

LOG: [lldb] Skip TestPlatformProcessConnect on windows and darwin

The test fails (for different reasons) on these platforms. Skip for now.

Added: 


Modified: 

lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
 
b/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
index 95a210059b6d..8ddab260b494 100644
--- 
a/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ 
b/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -10,6 +10,8 @@ class 
TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 @skipIfRemote
 @expectedFailureAll(hostoslist=["windows"], triple='.*-android')
+@skipIfWindows # lldb-server does not terminate correctly
+@skipIfDarwin # lldb-server not found correctly
 def test_platform_process_connect(self):
 self.build()
 



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


Re: [Lldb-commits] [PATCH] D94846: Allow breakpoints to be set on C++11 inline initializers

2021-01-17 Thread David Blaikie via lldb-commits
On Fri, Jan 15, 2021 at 6:22 PM Jim Ingham  wrote:
>
> If you set a breakpoint on source lines with no line table entries, lldb 
> slides the actual match forward to the nearest line table entry to the given 
> line number.  That's necessary for instance because if you lay out your 
> function definitions over multiple lines they won't all get line table 
> entries, but we don't want people to have to guess which of them was...  Same 
> is true of more complicated compound statements.

Ah, sure - gdb seems to do that too, totally makes sense - as you say,
it'd be pretty hard to know exactly which tokens end up with
corresponding entries in the line table and which don't (especially
under optimizations and complex compound statements).

> So people like that, but they really hate it when they have:
>
>
> #ifdef SOMETHING_NOT_DEFINED
>
> int foo() {
>
> }
>
> #else
> int bar() {
>
> }
> #end
>
> but with lots more junk so you can't see the ifdef's and then they set a 
> breakpoint in the "int foo" part and the breakpoint gets moved to bar instead 
> and then doesn't get hit.

Ah, indeed - that is a curious case that could be surprising to a
user. Thanks for explaining it - though it seems gdb doesn't special
case this & does produce the not-quite-what-the-user-intended
behavior.

>  You might try to argue that they should have checked where the breakpoint 
> actually landed before coming into your office to yell at you, but it's 
> likely to leave you with fewer friends...

FWIW: I don't have coworkers or friends come into my office to yell at
me about anything like this, and I don't really think anyone should -
that's not appropriate behavior for a workplace.

Having a nuanced discussion about the tradeoff of features - sure.

> So I was trying to detect this case and not move the breakpoint if sliding it 
> crossed over the function start boundary.  That way you'd see that the 
> breakpoint didn't work, and go figure out why.

Neat idea!

> The thinko in the original version was that we were still doing this when we 
> DIDN'T have to slide the breakpoint, when we got an exact match in the line 
> table.  In that case, we shouldn't try to second guess the line table at all. 
>  That's the patch in this fix.

Might this still leave some confusing behavior. Now it'll slide
forward into a function, but it won't slide forward into an
initializer? (so now the user has to know exactly which lines of the
initializer are attributed to the line table, making that somewhat
difficult to use?)

Testing some things out:

$ cat break.cpp
__attribute__((optnone)) int f1() { return 1; }
struct t1 {
  int // 3
  i   // 4
  =   // 5
  f1  // 6
  ();
  t1() {
  }
};

t1 v1;
int main() {
}

The line table:

AddressLine   Column File   ISA Discriminator Flags
-- -- -- -- --- - -
0x00401140  1  0  1   0 0  is_stmt
0x00401144  1 37  1   0 0  is_stmt prologue_end
0x00401150 13  0  1   0 0  is_stmt
0x00401154 14  1  1   0 0  is_stmt prologue_end
0x00401158 14  1  1   0 0  is_stmt end_sequence
0x00401020  0  0  1   0 0  is_stmt
0x00401024 12  4  1   0 0  is_stmt prologue_end
0x00401040  0  0  1   0 0  is_stmt
0x0040104b  0  0  1   0 0  is_stmt end_sequence
0x00401160  8  0  1   0 0  is_stmt
0x00401174  6  7  1   0 0  is_stmt prologue_end
0x0040117f  4  7  1   0 0  is_stmt
0x00401181  9  3  1   0 0  is_stmt
0x00401187  9  3  1   0 0  is_stmt end_sequence

Has entries for line 4 and 6 from the initializer (and 8 and 9 from
the ctor), but gdb doesn't seem to want to break on any of them. So
I'm not sure what gdb's doing, but it seems pretty unhelpful
(apparently gdb breaks in to the ctor too late to even let you step
into the initializers... guess that's because the initializers are
called in the prologue according to the debug info):
(gdb) b 1
Breakpoint 1 at 0x401144: file break.cpp, line 1.
(gdb) b 2
Breakpoint 2 at 0x401181: file break.cpp, line 9.
(gdb) b 3
Note: breakpoint 2 also set at pc 0x401181.
Breakpoint 3 at 0x401181: file break.cpp, line 9.
(gdb) b 4
Note: breakpoints 2 and 3 also set at pc 0x401181.
Breakpoint 4 at 0x401181: file break.cpp, line 9.
(gdb) b 5
Note: breakpoints 2, 3 and 4 also set at pc 0x401181.
Breakpoint 5 at 0x401181: file break.cpp, line 9.
(gdb) b 6
Note: breakpoints 2, 3, 4 and 5 also set at pc 0x401181.
Breakpoint 6 at 0x401181: file break.cpp, line 9.
(gdb) b 7
Note: breakpoints 2, 3, 4, 5 and 6 also set at pc 0x401181.
Breakpoint 7 at 0x401181: file break.cpp, line 9.
(gdb) 

[Lldb-commits] [lldb] 7e9e6ac - [lldb][docs] Fix some RST formatting errors related to code examples.

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

Author: Raphael Isemann
Date: 2021-01-17T17:41:05+01:00
New Revision: 7e9e6ac526ebd90fe8ec0b8d2bb6edd3516ab908

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

LOG: [lldb][docs] Fix some RST formatting errors related to code examples.

Mostly just making sure the indentation is right (SBDebugger had 0 spaces
as it was still plain text, the others had too much indentation or other
minor issues).

Added: 


Modified: 
lldb/bindings/interface/SBBroadcaster.i
lldb/bindings/interface/SBCommandInterpreterRunOptions.i
lldb/bindings/interface/SBDebugger.i
lldb/bindings/interface/SBProcess.i
lldb/bindings/interface/SBStructuredData.i
lldb/bindings/interface/SBType.i

Removed: 




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

diff  --git a/lldb/bindings/interface/SBCommandInterpreterRunOptions.i 
b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
index bad099205724..1a618a228bbe 100644
--- a/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
+++ b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
@@ -12,6 +12,7 @@ namespace lldb {
 "SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs 
the code it is fed.
 
 A default SBCommandInterpreterRunOptions object has:
+
 * StopOnContinue: false
 * StopOnError:false
 * StopOnCrash:false

diff  --git a/lldb/bindings/interface/SBDebugger.i 
b/lldb/bindings/interface/SBDebugger.i
index f2e23a7ed780..78d737b48c23 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -12,108 +12,108 @@ namespace lldb {
 "SBDebugger is the primordial object that creates SBTargets and provides
 access to them.  It also manages the overall debugging experiences.
 
-For example (from example/disasm.py),
-
-import lldb
-import os
-import sys
-
-def disassemble_instructions (insts):
-for i in insts:
-print i
-
-...
-
-# Create a new debugger instance
-debugger = lldb.SBDebugger.Create()
-
-# When we step or continue, don't return from the function until the process
-# stops. We do this by setting the async mode to false.
-debugger.SetAsync (False)
-
-# Create a target from a file and arch
-print('Creating a target for \'%s\'' % exe)
-
-target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
-
-if target:
-# If the target is valid set a breakpoint at main
-main_bp = target.BreakpointCreateByName (fname, 
target.GetExecutable().GetFilename());
-
-print main_bp
-
-# Launch the process. Since we specified synchronous mode, we won't return
-# from this function until we hit the breakpoint at main
-process = target.LaunchSimple (None, None, os.getcwd())
-
-# Make sure the launch went ok
-if process:
-# Print some simple process info
-state = process.GetState ()
-print process
-if state == lldb.eStateStopped:
-# Get the first thread
-thread = process.GetThreadAtIndex (0)
-if thread:
-# Print some simple thread info
-print thread
-# Get the first frame
-frame = thread.GetFrameAtIndex (0)
-if frame:
-# Print some simple frame info
-print frame
-function = frame.GetFunction()
-# See if we have debug info (a function)
-if function:
-# We do have a function, print some info for the 
function
-print function
-# Now get all instructions for this function and print 
them
-insts = function.GetInstructions(target)
-disassemble_instructions (insts)
-else:
-# See if we have a symbol in the symbol table for 
where we stopped
-symbol = frame.GetSymbol();
-if symbol:
-# We do have a symbol, print some info for the 
symbol
-print symbol
-# Now get all instructions for this symbol and 
print them
-insts = symbol.GetInstructions(target)
+For example (from example/disasm.py),::
+
+import lldb
+

[Lldb-commits] [lldb] acdc745 - [lldb][docs] Cleanup the Python doc strings for SB API classes

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

Author: Raphael Isemann
Date: 2021-01-17T16:51:07+01:00
New Revision: acdc74568927d47f94816e73b6e105c9460cc3e4

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

LOG: [lldb][docs] Cleanup the Python doc strings for SB API classes

The first line of the doc string ends up on the SB API class summary at
the root page of the Python API  web page of LLDB. Currently many of the
descriptions are missing or are several lines which makes the table really
hard to read.

This just adds the missing docstrings where possible and fixes the formatting
where necessary.

Added: 


Modified: 
lldb/bindings/interface/SBAttachInfo.i
lldb/bindings/interface/SBBreakpoint.i
lldb/bindings/interface/SBCommunication.i
lldb/bindings/interface/SBData.i
lldb/bindings/interface/SBExecutionContext.i
lldb/bindings/interface/SBFileSpecList.i
lldb/bindings/interface/SBFrame.i
lldb/bindings/interface/SBHostOS.i
lldb/bindings/interface/SBInstruction.i
lldb/bindings/interface/SBLanguageRuntime.i
lldb/bindings/interface/SBLaunchInfo.i
lldb/bindings/interface/SBLineEntry.i
lldb/bindings/interface/SBMemoryRegionInfoList.i
lldb/bindings/interface/SBModuleSpec.i
lldb/bindings/interface/SBPlatform.i
lldb/bindings/interface/SBQueue.i
lldb/bindings/interface/SBQueueItem.i
lldb/bindings/interface/SBReproducer.i
lldb/bindings/interface/SBStringList.i
lldb/bindings/interface/SBThreadPlan.i
lldb/bindings/interface/SBTrace.i
lldb/bindings/interface/SBTraceOptions.i
lldb/bindings/interface/SBType.i
lldb/bindings/interface/SBTypeEnumMember.i
lldb/bindings/interface/SBVariablesOptions.i
lldb/bindings/python/python-extensions.swig

Removed: 




diff  --git a/lldb/bindings/interface/SBAttachInfo.i 
b/lldb/bindings/interface/SBAttachInfo.i
index 3f4634e14619..9ac96e6dd7be 100644
--- a/lldb/bindings/interface/SBAttachInfo.i
+++ b/lldb/bindings/interface/SBAttachInfo.i
@@ -7,7 +7,9 @@
 
//===--===//
 
 namespace lldb {
-
+%feature("docstring",
+"Describes how to attach when calling :py:class:`SBTarget.Attach`."
+) SBAttachInfo;
 class SBAttachInfo
 {
 public:

diff  --git a/lldb/bindings/interface/SBBreakpoint.i 
b/lldb/bindings/interface/SBBreakpoint.i
index 983e9facfe20..37fcc7fbab48 100644
--- a/lldb/bindings/interface/SBBreakpoint.i
+++ b/lldb/bindings/interface/SBBreakpoint.i
@@ -313,6 +313,10 @@ public:
 
 class SBBreakpointListImpl;
 
+
+%feature("docstring",
+"Represents a list of :py:class:`SBBreakpoint`."
+) SBBreakpointList;
 class LLDB_API SBBreakpointList
 {
 public:

diff  --git a/lldb/bindings/interface/SBCommunication.i 
b/lldb/bindings/interface/SBCommunication.i
index 87d3d0c9c5e4..8611e83e92ad 100644
--- a/lldb/bindings/interface/SBCommunication.i
+++ b/lldb/bindings/interface/SBCommunication.i
@@ -8,6 +8,9 @@
 
 namespace lldb {
 
+%feature("docstring",
+"Allows sending/receiving data."
+) SBCommunication;
 class SBCommunication
 {
 public:

diff  --git a/lldb/bindings/interface/SBData.i 
b/lldb/bindings/interface/SBData.i
index 3e74240329e0..a1fb4472cd23 100644
--- a/lldb/bindings/interface/SBData.i
+++ b/lldb/bindings/interface/SBData.i
@@ -9,6 +9,9 @@
 
 namespace lldb {
 
+%feature("docstring",
+"Represents a data buffer."
+) SBData;
 class SBData
 {
 public:

diff  --git a/lldb/bindings/interface/SBExecutionContext.i 
b/lldb/bindings/interface/SBExecutionContext.i
index 46968d04ae32..5fc5c0571182 100644
--- a/lldb/bindings/interface/SBExecutionContext.i
+++ b/lldb/bindings/interface/SBExecutionContext.i
@@ -8,6 +8,9 @@
 
 namespace lldb {
 
+%feature("docstring",
+"Describes the program context in which a command should be executed."
+) SBExecutionContext;
 class SBExecutionContext
 {
 public:

diff  --git a/lldb/bindings/interface/SBFileSpecList.i 
b/lldb/bindings/interface/SBFileSpecList.i
index 96641613f459..384dd4c4ae08 100644
--- a/lldb/bindings/interface/SBFileSpecList.i
+++ b/lldb/bindings/interface/SBFileSpecList.i
@@ -8,6 +8,9 @@
 
 namespace lldb {
 
+%feature("docstring",
+"Represents a list of :py:class:`SBFileSpec`."
+) SBFileSpecList;
 class SBFileSpecList
 {
 public:

diff  --git a/lldb/bindings/interface/SBFrame.i 
b/lldb/bindings/interface/SBFrame.i
index b4e9b1c5f542..8ceb03bb7a18 100644
--- a/lldb/bindings/interface/SBFrame.i
+++ b/lldb/bindings/interface/SBFrame.i
@@ -10,6 +10,7 @@ namespace lldb {
 
 %feature("docstring",
 "Represents one of the stack frames associated with a thread.
+
 SBThread contains SBFrame(s). For example (from test/lldbutil.py), ::
 
 def print_stacktrace(thread, string_buffer = False):

diff  --git a/lldb/bindings/interface/SBHostOS.i 
b/lldb/bindings/interface/SBHostOS.i
index 

[Lldb-commits] [PATCH] D94489: [lldb][docs] Use sphinx instead of epydoc to generate LLDB's Python reference

2021-01-17 Thread Thorsten via Phabricator via lldb-commits
tschuett added a comment.

In D94489#2503685 , @teemperor wrote:

> In D94489#2503662 , @tschuett wrote:
>
>> There is no syntax highlighting for Python in sphinx? The code in
>> https://lldb.llvm.org/python_api/lldb.SBDebugger.html#lldb.SBDebugger
>> is hard to read.
>>
>> Even the line breaks between the source code and web page differ.
>
> There is, but someone (probably me) needs to rewrite and update all the 
> documentation in restructured text so that sphinx knows this is a code 
> example (previously we had just plaintext). Currently working on all that.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94489

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


[Lldb-commits] [PATCH] D94489: [lldb][docs] Use sphinx instead of epydoc to generate LLDB's Python reference

2021-01-17 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D94489#2503662 , @tschuett wrote:

> There is no syntax highlighting for Python in sphinx? The code in
> https://lldb.llvm.org/python_api/lldb.SBDebugger.html#lldb.SBDebugger
> is hard to read.
>
> Even the line breaks between the source code and web page differ.

There is, but someone (probably me) needs to rewrite and update all the 
documentation in restructured text so that sphinx knows this is a code example 
(previously we had just plaintext). Currently working on all that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94489

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


[Lldb-commits] [PATCH] D94489: [lldb][docs] Use sphinx instead of epydoc to generate LLDB's Python reference

2021-01-17 Thread Thorsten via Phabricator via lldb-commits
tschuett added a comment.

There is no syntax highlighting for Python in sphinx? The code in
https://lldb.llvm.org/python_api/lldb.SBDebugger.html#lldb.SBDebugger
is hard to read.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94489

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


[Lldb-commits] [lldb] e7bc6c5 - Reland [lldb][docs] Use sphinx instead of epydoc to generate LLDB's Python reference

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

Author: Raphael Isemann
Date: 2021-01-17T12:13:01+01:00
New Revision: e7bc6c594b75602c23cb901f53b3a30d48e2ee78

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

LOG: Reland [lldb][docs] Use sphinx instead of epydoc to generate LLDB's Python 
reference

The build server should now have the missing dependencies.

Original summary:

Currently LLDB uses epydoc to generate the Python API reference for the website.
epydoc however is unmaintained since more than a decade and no longer works with
Python 3. Also whatever setup we had once for generating the documentation on
the website server no longer seems to work, so the current website documentation
has been stale since more than a year.

This patch replaces epydoc with sphinx and its automodapi plugin that can
generate Python API references. LLVM already uses sphinx for the rest of the
documentation, so this way we are more consistent with the rest of LLVM. The
only new dependency is the automodapi plugin for sphinx.

This patch effectively does the following things:
* Remove the epydoc code.
* Make a new dummy Python API page in our website that just calls the Sphinx
  command for generated the API documentation.
* Add a mock _lldb module that is only used when generating the Python API.
 This way we don't have to build all of LLDB to generate the API reference.

Some notes:
* The long list of skips is necessary due to boilerplate functions that SWIG
  is generating. Sadly automodapi is not really scriptable from what I can see,
  so we have to blacklist this stuff manually.
* The .gitignore change because automodapi wants a subfolder of our
  documentation directory to place generated documentation files there. The path
  is also what is used on the website, so we can't really workaround this
  (without copying the whole `docs` dir somewhere else when we build).
* We have to use environment variables to pass our build path to our sphinx
  configuration. Sphinx doesn't support passing variables onto that script.

Reviewed By: JDevlieghere

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

Added: 
lldb/docs/_lldb/__init__.py
lldb/docs/python_api.rst

Modified: 
.gitignore
lldb/docs/CMakeLists.txt
lldb/docs/conf.py
lldb/docs/index.rst
llvm/cmake/modules/AddSphinxTarget.cmake

Removed: 




diff  --git a/.gitignore b/.gitignore
index 5e937552c5f8..c58c673c198a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,3 +63,5 @@ pythonenv*
 /clang/utils/analyzer/projects/*/PatchedSource
 /clang/utils/analyzer/projects/*/ScanBuildResults
 /clang/utils/analyzer/projects/*/RefScanBuildResults
+# automodapi puts generated documentation files here.
+/lldb/docs/python_api/

diff  --git a/lldb/docs/CMakeLists.txt b/lldb/docs/CMakeLists.txt
index b633a4abf054..af18eb22e954 100644
--- a/lldb/docs/CMakeLists.txt
+++ b/lldb/docs/CMakeLists.txt
@@ -15,60 +15,39 @@ if(DOXYGEN_FOUND)
   )
 endif()
 
-if (LLDB_ENABLE_PYTHON)
-  find_program(EPYDOC_EXECUTABLE NAMES epydoc epydoc.py)
-  if(EPYDOC_EXECUTABLE)
-message(STATUS "Found epydoc - ${EPYDOC_EXECUTABLE}")
-
-find_program(DOT_EXECUTABLE dot)
-if(DOT_EXECUTABLE)
-  set(EPYDOC_OPTIONS ${EPYDOC_OPTIONS} --graph all --dotpath 
${DOT_EXECUTABLE})
-  message(STATUS "Found dot - ${DOT_EXECUTABLE}")
-endif()
+if (LLVM_ENABLE_SPHINX)
+  include(AddSphinxTarget)
+endif()
 
-# Pretend to make a python package so that we can generate the reference.
-# Because we don't build liblldb, epydoc will complain that the import of
-# _lldb.so failed, but that doesn't prevent it from generating the docs.
+if (LLDB_ENABLE_PYTHON AND SPHINX_FOUND)
+  if (${SPHINX_OUTPUT_HTML})
+# Pretend that the SWIG generated API is a Python package.
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lldb)
 get_target_property(lldb_bindings_dir swig_wrapper_python BINARY_DIR)
 add_custom_target(lldb-python-doc-package
   COMMAND "${CMAKE_COMMAND}" -E copy "${lldb_bindings_dir}/lldb.py" 
"${CMAKE_CURRENT_BINARY_DIR}/lldb/__init__.py"
-  COMMENT "Copying lldb.py to pretend package.")
+  COMMENT "Copying lldb.py to pretend its a Python package.")
 add_dependencies(lldb-python-doc-package swig_wrapper_python)
 
-set(DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc")
-file(MAKE_DIRECTORY "${DOC_DIR}")
-add_custom_target(lldb-python-doc
-  ${EPYDOC_EXECUTABLE}
-  --html
-  lldb
-  -o ${CMAKE_CURRENT_BINARY_DIR}/python_reference
-  --name "LLDB python API"
-  --url "http://lldb.llvm.org;
-  ${EPYDOC_OPTIONS}
-  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-  COMMENT "Generating LLDB Python API reference with epydoc" VERBATIM
-)
-add_dependencies(lldb-python-doc swig_wrapper_python 
lldb-python-doc-package)
-