[Lldb-commits] [PATCH] D77662: [lldb/test] Make TestLoadUnload compatible with windows

2020-04-14 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.
Closed by commit rGe0dbd025131c: [lldb/test] Make TestLoadUnload compatible 
with windows (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77662

Files:
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/packages/Python/lldbsuite/test/make/dylib.h
  lldb/packages/Python/lldbsuite/test/make/test_common.h
  lldb/test/API/functionalities/load_unload/Makefile
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  lldb/test/API/functionalities/load_unload/a.cpp
  lldb/test/API/functionalities/load_unload/b.cpp
  lldb/test/API/functionalities/load_unload/d.cpp
  lldb/test/API/functionalities/load_unload/main.cpp

Index: lldb/test/API/functionalities/load_unload/main.cpp
===
--- lldb/test/API/functionalities/load_unload/main.cpp
+++ lldb/test/API/functionalities/load_unload/main.cpp
@@ -1,72 +1,57 @@
-#include 
-#include 
+#include "dylib.h"
 #include 
-#include 
-#include 
-#include 
+#include 
 #include 
+#include 
 
-int
-main (int argc, char const *argv[])
-{
-#if defined (__APPLE__)
-const char *a_name = "@executable_path/libloadunload_a.dylib";
-const char *c_name = "@executable_path/libloadunload_c.dylib";
-#else
-const char *a_name = "libloadunload_a.so";
-const char *c_name = "libloadunload_c.so";
-#endif
-void *a_dylib_handle = NULL;
-void *c_dylib_handle = NULL;
-int (*a_function) (void);
-
-a_dylib_handle = dlopen (a_name, RTLD_NOW); // Set break point at this line for test_lldb_process_load_and_unload_commands().
-if (a_dylib_handle == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (1);
-}
-
-a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function");
-if (a_function == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (2);
-}
-printf ("First time around, got: %d\n", a_function ());
-dlclose (a_dylib_handle);
-
-c_dylib_handle = dlopen (c_name, RTLD_NOW);
-if (c_dylib_handle == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (3);
-}
-a_function = (int (*) ()) dlsym (c_dylib_handle, "c_function");
-if (a_function == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (4);
-}
-
-a_dylib_handle = dlopen (a_name, RTLD_NOW);
-if (a_dylib_handle == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (5);
-}
-
-a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function");
-if (a_function == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (6);
-}
-printf ("Second time around, got: %d\n", a_function ());
-dlclose (a_dylib_handle);
-
-int d_function(void);
-printf ("d_function returns: %d\n", d_function());
-
-return 0;
+int main(int argc, char const *argv[]) {
+  const char *a_name = "loadunload_a";
+  const char *c_name = "loadunload_c";
+  void *a_dylib_handle = NULL;
+  void *c_dylib_handle = NULL; // Set break point at this line for test_lldb_process_load_and_unload_commands().
+  int (*a_function)(void);
+
+  a_dylib_handle = dylib_open(a_name);
+  if (a_dylib_handle == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(1);
+  }
+
+  a_function = (int (*)())dylib_get_symbol(a_dylib_handle, "a_function");
+  if (a_function == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(2);
+  }
+  printf("First time around, got: %d\n", a_function());
+  dylib_close(a_dylib_handle);
+
+  c_dylib_handle = dylib_open(c_name);
+  if (c_dylib_handle == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(3);
+  }
+  a_function = (int (*)())dylib_get_symbol(c_dylib_handle, "c_function");
+  if (a_function == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(4);
+  }
+
+  a_dylib_handle = dylib_open(a_name);
+  if (a_dylib_handle == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(5);
+  }
+
+  a_function = (int (*)())dylib_get_symbol(a_dylib_handle, "a_function");
+  if (a_function == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(6);
+  }
+  printf("Second time around, got: %d\n", a_function());
+  dylib_close(a_dylib_handle);
+
+  int LLDB_DYLIB_IMPORT d_function(void);
+  printf("d_function returns: %d\n", d_function());
+
+  return 0;
 }
Index: lldb/test/API/functionalities/load_unload/d.cpp
===
--- lldb/test/API/functionalities/load_unload/d.cpp
+++ lldb/test/API/functionalities/load_unload/d.cpp
@@ -5,8 +5,6 @@
 
 int d_global = d_init();
 
-int
-d_function ()
-{ // Find this line number within d_dunction().
-

[Lldb-commits] [PATCH] D77662: [lldb/test] Make TestLoadUnload compatible with windows

2020-04-10 Thread Saleem Abdulrasool via Phabricator via lldb-commits
compnerd added a comment.

@labath - can this get merged so that I can rebase and get D77287 
 merged?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77662



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


[Lldb-commits] [PATCH] D77662: [lldb/test] Make TestLoadUnload compatible with windows

2020-04-09 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

Well, it looks to go _me_.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77662



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


[Lldb-commits] [PATCH] D77662: [lldb/test] Make TestLoadUnload compatible with windows

2020-04-09 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 4 inline comments as done.
labath added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/make/Makefile.rules:477
 ifeq (1,$(USE_LIBDL))
-   ifneq ($(OS),NetBSD)
+   ifeq (,$(filter $(OS), NetBSD Windows_NT))
LDFLAGS += -ldl

amccarth wrote:
> I'm no expert in makefile syntax (especially not for Unix-y versions), but 
> this looks weird, with the leading comma and the matching parenthesis for 
> `$(filter` sitting near the end of the expression.  Is this right?
Yes, it is.

The "leading" comma introduces a empty string as the first argument to `ifeq`. 
Then the `$filter` thingy will turn `$OS` into an empty string iff it matches 
one of the strings it got as an argument (technically it will just remove any 
subwords which match those strings, but since `$OS` is just a single word, the 
effect is the same). 
So this is a very convoluted way of writing `$(OS) in [NetBSD, Windows_NT]` but:
a) it is consistent with other usages in these makefiles
b) I don't actually know of a better way to write that. If you do, let me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77662



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


[Lldb-commits] [PATCH] D77662: [lldb/test] Make TestLoadUnload compatible with windows

2020-04-08 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/make/Makefile.rules:477
 ifeq (1,$(USE_LIBDL))
-   ifneq ($(OS),NetBSD)
+   ifeq (,$(filter $(OS), NetBSD Windows_NT))
LDFLAGS += -ldl

I'm no expert in makefile syntax (especially not for Unix-y versions), but this 
looks weird, with the leading comma and the matching parenthesis for `$(filter` 
sitting near the end of the expression.  Is this right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77662



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


[Lldb-commits] [PATCH] D77662: [lldb/test] Make TestLoadUnload compatible with windows

2020-04-08 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 255921.
labath edited the summary of this revision.
labath added a comment.

Remove bogus runCmd. Everything should check out now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77662

Files:
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/packages/Python/lldbsuite/test/make/dylib.h
  lldb/packages/Python/lldbsuite/test/make/test_common.h
  lldb/test/API/functionalities/load_unload/Makefile
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  lldb/test/API/functionalities/load_unload/a.cpp
  lldb/test/API/functionalities/load_unload/b.cpp
  lldb/test/API/functionalities/load_unload/d.cpp
  lldb/test/API/functionalities/load_unload/main.cpp

Index: lldb/test/API/functionalities/load_unload/main.cpp
===
--- lldb/test/API/functionalities/load_unload/main.cpp
+++ lldb/test/API/functionalities/load_unload/main.cpp
@@ -1,72 +1,57 @@
-#include 
-#include 
+#include "dylib.h"
 #include 
-#include 
-#include 
-#include 
+#include 
 #include 
+#include 
 
-int
-main (int argc, char const *argv[])
-{
-#if defined (__APPLE__)
-const char *a_name = "@executable_path/libloadunload_a.dylib";
-const char *c_name = "@executable_path/libloadunload_c.dylib";
-#else
-const char *a_name = "libloadunload_a.so";
-const char *c_name = "libloadunload_c.so";
-#endif
-void *a_dylib_handle = NULL;
-void *c_dylib_handle = NULL;
-int (*a_function) (void);
-
-a_dylib_handle = dlopen (a_name, RTLD_NOW); // Set break point at this line for test_lldb_process_load_and_unload_commands().
-if (a_dylib_handle == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (1);
-}
-
-a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function");
-if (a_function == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (2);
-}
-printf ("First time around, got: %d\n", a_function ());
-dlclose (a_dylib_handle);
-
-c_dylib_handle = dlopen (c_name, RTLD_NOW);
-if (c_dylib_handle == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (3);
-}
-a_function = (int (*) ()) dlsym (c_dylib_handle, "c_function");
-if (a_function == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (4);
-}
-
-a_dylib_handle = dlopen (a_name, RTLD_NOW);
-if (a_dylib_handle == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (5);
-}
-
-a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function");
-if (a_function == NULL)
-{
-fprintf (stderr, "%s\n", dlerror());
-exit (6);
-}
-printf ("Second time around, got: %d\n", a_function ());
-dlclose (a_dylib_handle);
-
-int d_function(void);
-printf ("d_function returns: %d\n", d_function());
-
-return 0;
+int main(int argc, char const *argv[]) {
+  const char *a_name = "loadunload_a";
+  const char *c_name = "loadunload_c";
+  void *a_dylib_handle = NULL;
+  void *c_dylib_handle = NULL; // Set break point at this line for test_lldb_process_load_and_unload_commands().
+  int (*a_function)(void);
+
+  a_dylib_handle = dylib_open(a_name);
+  if (a_dylib_handle == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(1);
+  }
+
+  a_function = (int (*)())dylib_get_symbol(a_dylib_handle, "a_function");
+  if (a_function == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(2);
+  }
+  printf("First time around, got: %d\n", a_function());
+  dylib_close(a_dylib_handle);
+
+  c_dylib_handle = dylib_open(c_name);
+  if (c_dylib_handle == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(3);
+  }
+  a_function = (int (*)())dylib_get_symbol(c_dylib_handle, "c_function");
+  if (a_function == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(4);
+  }
+
+  a_dylib_handle = dylib_open(a_name);
+  if (a_dylib_handle == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(5);
+  }
+
+  a_function = (int (*)())dylib_get_symbol(a_dylib_handle, "a_function");
+  if (a_function == NULL) {
+fprintf(stderr, "%s\n", dylib_last_error());
+exit(6);
+  }
+  printf("Second time around, got: %d\n", a_function());
+  dylib_close(a_dylib_handle);
+
+  int LLDB_DYLIB_IMPORT d_function(void);
+  printf("d_function returns: %d\n", d_function());
+
+  return 0;
 }
Index: lldb/test/API/functionalities/load_unload/d.cpp
===
--- lldb/test/API/functionalities/load_unload/d.cpp
+++ lldb/test/API/functionalities/load_unload/d.cpp
@@ -5,8 +5,6 @@
 
 int d_global = d_init();
 
-int
-d_function ()
-{ // Find this line number within d_dunction().
-return 700;
+int LLDB_DYLIB_EXPORT d_function() {
+  return