[Lldb-commits] [PATCH] D156564: [lldb] Fix test TestBSDArchives.py properly

2023-08-01 Thread Wanyi Ye via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca76281917d0: [lldb] Fix test TestBSDArchives.py properly 
(authored by kusmour).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156564

Files:
  lldb/test/API/functionalities/archives/Makefile
  lldb/test/API/functionalities/archives/TestBSDArchives.py


Index: lldb/test/API/functionalities/archives/TestBSDArchives.py
===
--- lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -167,6 +167,20 @@
 ") of the .o file doesn't match",
 ]
 self.check_frame_variable_errors(thread, error_strings)
+
+# Break at b() should succeed
+(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(
+self, "b", bkpt_module=exe
+)
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stopped", "stop reason = breakpoint"],
+)
+self.expect(
+"frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) 
arg = 2"]
+)
+
 
 @skipIfRemote
 @skipUnlessDarwin
Index: lldb/test/API/functionalities/archives/Makefile
===
--- lldb/test/API/functionalities/archives/Makefile
+++ lldb/test/API/functionalities/archives/Makefile
@@ -18,7 +18,7 @@
 
 libfoo-thin.a: a.o b.o
$(eval LLVM_AR := $(LLVM_TOOLS_DIR)/llvm-ar)
-   $(eval LLVM_ARFLAGS := -rcsDT)
+   $(eval LLVM_ARFLAGS := -rcsUT)
$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^
 
 include Makefile.rules


Index: lldb/test/API/functionalities/archives/TestBSDArchives.py
===
--- lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -167,6 +167,20 @@
 ") of the .o file doesn't match",
 ]
 self.check_frame_variable_errors(thread, error_strings)
+
+# Break at b() should succeed
+(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(
+self, "b", bkpt_module=exe
+)
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stopped", "stop reason = breakpoint"],
+)
+self.expect(
+"frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) arg = 2"]
+)
+
 
 @skipIfRemote
 @skipUnlessDarwin
Index: lldb/test/API/functionalities/archives/Makefile
===
--- lldb/test/API/functionalities/archives/Makefile
+++ lldb/test/API/functionalities/archives/Makefile
@@ -18,7 +18,7 @@
 
 libfoo-thin.a: a.o b.o
 	$(eval LLVM_AR := $(LLVM_TOOLS_DIR)/llvm-ar)
-	$(eval LLVM_ARFLAGS := -rcsDT)
+	$(eval LLVM_ARFLAGS := -rcsUT)
 	$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^
 
 include Makefile.rules
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D156367: [BSDArchive] NULL check the child object file ptr before accessing its member

2023-07-27 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

In D156367#4539916 , @bulbazord wrote:

> Hey, I think this may have broken the green dragon bots. Could you take a 
> look and fix forward or revert? Thanks
>
> https://green.lab.llvm.org/green/view/LLDB/job/as-lldb-cmake/3262/ (You can 
> ignore the `import-std-module` tests, those have been broken some time and 
> are being worked on AFAIK).

Fixed by commit: 4520cc066b2ffe5ac261e3aca887cba3f113b1ff 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156367

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


[Lldb-commits] [PATCH] D156367: [BSDArchive] NULL check the child object file ptr before accessing its member

2023-07-27 Thread Wanyi Ye via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b9eed9c64f3: [BSDArchive] NULL check the child object file 
ptr before accessing its member (authored by kusmour).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156367

Files:
  lldb/source/Core/Module.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  lldb/test/API/functionalities/archives/Makefile
  lldb/test/API/functionalities/archives/TestBSDArchives.py

Index: lldb/test/API/functionalities/archives/TestBSDArchives.py
===
--- lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -129,6 +129,58 @@
 ]
 self.check_frame_variable_errors(thread, error_strings)
 
+@skipIfRemote
+@skipUnlessDarwin
+def test_frame_var_errors_when_thin_archive_malformed(self):
+"""
+Create thin archive libfoo.a and make it malformed to make sure
+we don't crash and report an appropriate error when resolving
+breakpoint using debug map.
+"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+libfoo_path = self.getBuildArtifact("libfoo.a")
+libthin_path = self.getBuildArtifact("libfoo-thin.a")
+objfile_a = self.getBuildArtifact("a.o")
+# Replace the libfoo.a file with a thin archive containing the same
+# debug information (a.o, b.o). Then remove a.o from the file system
+# so we force an error when we set a breakpoint on a() function.
+# Since the a.o is missing, the debug info won't be loaded and we
+# should see an error when trying to break into a().
+os.remove(libfoo_path)
+shutil.copyfile(libthin_path, libfoo_path)
+os.remove(objfile_a)
+
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+# We won't be able to see source file
+self.expect(
+"b a",
+substrs=["Breakpoint 1: where = a.out`a, address ="],
+)
+# Break at a() should fail
+(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(
+self, "a", bkpt_module=exe
+)
+error_strings = [
+'"a.o" object from the "',
+"libfoo.a\" archive: either the .o file doesn't exist in the archive or the modification time (0x",
+") of the .o file doesn't match",
+]
+self.check_frame_variable_errors(thread, error_strings)
+
+# Break at b() should succeed
+(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(
+self, "b", bkpt_module=exe
+)
+self.expect(
+"thread list",
+STOPPED_DUE_TO_BREAKPOINT,
+substrs=["stopped", "stop reason = breakpoint"],
+)
+self.expect(
+"frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) arg = 2"]
+)
+
 @skipIfRemote
 @skipUnlessDarwin
 def test_frame_var_errors_when_mtime_mistmatch_for_object_in_archive(self):
Index: lldb/test/API/functionalities/archives/Makefile
===
--- lldb/test/API/functionalities/archives/Makefile
+++ lldb/test/API/functionalities/archives/Makefile
@@ -2,7 +2,7 @@
 EXE :=  # Define a.out explicitly
 MAKE_DSYM := NO
 
-all: a.out libbar.a
+all: a.out libbar.a libfoo-thin.a
 
 a.out: main.o libfoo.a
 	$(LD) $(LDFLAGS) $^ -o $@
@@ -16,4 +16,9 @@
 	$(eval LLVM_ARFLAGS := -rcsDT)
 	$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^
 
+libfoo-thin.a: a.o b.o
+	$(eval LLVM_AR := $(LLVM_TOOLS_DIR)/llvm-ar)
+	$(eval LLVM_ARFLAGS := -rcsDT)
+	$(LLVM_AR) $(LLVM_ARFLAGS) $@ $^
+
 include Makefile.rules
Index: lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
===
--- lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -540,7 +540,8 @@
   std::shared_ptr child_data_sp =
   FileSystem::Instance().CreateDataBuffer(child, file_size,
   file_offset);
-  if (child_data_sp->GetByteSize() != object->file_size)
+  if (!child_data_sp ||
+  child_data_sp->GetByteSize() != object->file_size)
 return ObjectFileSP();
   lldb::offset_t data_offset = 0;
   return ObjectFile::FindPlugin(
Index: lldb/source/Core/Module.cpp
===
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -1285,7 +1285,8 @@
   // those values that 

[Lldb-commits] [PATCH] D153390: [lldb][Windows] Fix ZipFileResolver tests

2023-06-22 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour accepted this revision.
kusmour added a comment.

The fix looks straightforward. And @splhack has verified locally. Accepting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153390

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


[Lldb-commits] [PATCH] D152757: [lldb][ObjectFileELF] Set ModuleSpec file offset and size

2023-06-15 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:592
   if (data_sp->GetByteSize() < length)
-data_sp = MapFileData(file, -1, file_offset);
+data_sp = MapFileData(file, length, file_offset);
   if (data_sp)

splhack wrote:
> bulbazord wrote:
> > A length of `-1` means "map the whole file", if my understanding is 
> > correct. Why do we want to change this to `length` instead of just -1? Or 
> > is this `file` the entire zip file?
> I'm now updating this diff to add comments to clarify the intention.
> 
> For Android zip .so file (D152759),
> the ModuleSpec `spec` will have these info with this diff.
> - object offset = .so file offset inside the zip file
> - object size = .so file size
> 
> PlatformAndroid requires this module spec to call DownloadModuleSlice in 
> order to download the .so file from the zip file using adb shell dd.
> - file spec = "zip_path!/lib_path"
> - file offset = .so file offset inside the zip file == dd skip parameter
> - file size = .so file size == dd count parameter
> 
> And ObjectFileELF will calculate CRC32 if the ELF does not have GNU BuildID, 
> that will use the `data_sp` size. Which is set by `MapFileData`. Currently 
> `-1` == the whole zip file size. (In fact, lldb-server is crashing due to 
> SIGSEGV.) It is supposed to be the .so file size. 
> In the unittest, the test .so file has CRC32 `7D6E4738`. And it should be the 
> same for the file size.
> 
> offset-test.bin contains
> -1024bytes of '\0'
> - liboffset-test.so (file offset = 1024, file size = 3600, CRC32 '7D6E4738')
> - 16bytes of '\0'
Reading from [[ 
https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#opening-shared-libraries-directly-from-an-apk
 | Opening shared libraries directly from an APK ]]
Because the `.so` file is now page aligned and has offset, the actual size 
should <= the size of `file`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152757

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


[Lldb-commits] [PATCH] D137665: [lldb-vscode] Send Selected Statistics Dump in Terminated Event

2022-11-15 Thread Wanyi Ye via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bc86ae83e95: [lldb-vscode] Send Selected Statistics Dump in 
Terminated Event (authored by kusmour).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137665

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/terminated-event/Makefile
  lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
  lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -204,7 +204,7 @@
 g_vsc.sent_terminated_event = true;
 g_vsc.RunTerminateCommands();
 // Send a "terminated" event
-llvm::json::Object event(CreateEventObject("terminated"));
+llvm::json::Object event(CreateTerminatedEventObject());
 g_vsc.SendJSON(llvm::json::Value(std::move(event)));
   }
 }
@@ -2949,7 +2949,7 @@
   const uint32_t addr_size = g_vsc.target.GetProcess().GetAddressByteSize();
   lldb::SBValue reg_set = g_vsc.variables.registers.GetValueAtIndex(0);
   const uint32_t num_regs = reg_set.GetNumChildren();
-  for (uint32_t reg_idx=0; reg_idx pairs
+void FilterAndGetValueForKey(const lldb::SBStructuredData data, const char *key,
+ llvm::json::Object ) {
+  lldb::SBStructuredData value = data.GetValueForKey(key);
+  std::string key_utf8 = llvm::json::fixUTF8(key);
+  if (strcmp(key, "modules") == 0)
+return;
+  switch (value.GetType()) {
+  case lldb::eStructuredDataTypeFloat:
+out.try_emplace(key_utf8, value.GetFloatValue());
+break;
+  case lldb::eStructuredDataTypeInteger:
+out.try_emplace(key_utf8, value.GetIntegerValue());
+break;
+  case lldb::eStructuredDataTypeArray: {
+lldb::SBStream contents;
+value.GetAsJSON(contents);
+out.try_emplace(key_utf8, llvm::json::fixUTF8(contents.GetData()));
+  } break;
+  case lldb::eStructuredDataTypeBoolean:
+out.try_emplace(key_utf8, value.GetBooleanValue());
+break;
+  case lldb::eStructuredDataTypeString: {
+// Get the string size before reading
+const size_t str_length = value.GetStringValue(nullptr, 0);
+std::string str(str_length + 1, 0);
+value.GetStringValue([0], str_length);
+out.try_emplace(key_utf8, llvm::json::fixUTF8(str));
+  } break;
+  case lldb::eStructuredDataTypeDictionary: {
+lldb::SBStream contents;
+value.GetAsJSON(contents);
+out.try_emplace(key_utf8, llvm::json::fixUTF8(contents.GetData()));
+  } break;
+  case lldb::eStructuredDataTypeNull:
+  case lldb::eStructuredDataTypeGeneric:
+  case lldb::eStructuredDataTypeInvalid:
+break;
+  }
+}
+
+void addStatistic(llvm::json::Object ) {
+  lldb::SBStructuredData statistics = g_vsc.target.GetStatistics();
+  bool is_dictionary =
+  statistics.GetType() == lldb::eStructuredDataTypeDictionary;
+  if (!is_dictionary)
+return;
+  llvm::json::Object stats_body;
+
+  lldb::SBStringList keys;
+  if (!statistics.GetKeys(keys))
+return;
+  for (size_t i = 0; i < keys.GetSize(); i++) {
+const char *key = keys.GetStringAtIndex(i);
+FilterAndGetValueForKey(statistics, key, stats_body);
+  }
+  event.try_emplace("statistics", std::move(stats_body));
+}
+
+llvm::json::Object CreateTerminatedEventObject() {
+  llvm::json::Object event(CreateEventObject("terminated"));
+  addStatistic(event);
+  return event;
+}
+
 std::string JSONToString(const llvm::json::Value ) {
   std::string data;
   llvm::raw_string_ostream os(data);
Index: lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include "foo.h"
+
+int main(int argc, char const *argv[]) {
+  std::cout << "Hello World!" << std::endl; // main breakpoint 1
+  foo();
+  return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
@@ -0,0 +1 @@
+int foo();
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
@@ -0,0 +1,3 @@
+int foo() {
+return 12;
+}
Index: 

[Lldb-commits] [PATCH] D137003: [lldb-vscode] Send Statistics Dump in terminated event

2022-11-04 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

In D137003#3908918 , @shafik wrote:

> It looks like this change broke `TestVSCode_terminatedEvent.py` see Green 
> Dragon build bot: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/48111/
>
> Please fix or revert.

I will fix test by disabling checking the 'memory' filed. However, when I run 
the test locally, I got different results, see below:

  
{"event":"terminated","seq":0,"statistics":{"memory":"{\"strings\":{\"bytesTotal\":1843200,\"bytesUnused\":897741,\"bytesUsed\":945459}}","targets":"[{\"breakpoints\":[{\"details\":{\"Breakpoint\":{\"BKPTOptions\":{\"AutoContinue\":false,\"ConditionText\":\"\",\"EnabledState\":true,\"IgnoreCount\":0,\"OneShotState\":false},\"BKPTResolver\":{\"Options\":{\"NameMask\":[56],\"Offset\":0,\"SkipPrologue\":true,\"SymbolNames\":[\"foo\"]},\"Type\":\"SymbolName\"},\"Hardware\":false,\"Names\":[\"vscode\"],\"SearchFilter\":{\"Options\":{},\"Type\":\"Unconstrained\"}}},\"id\":1,\"internal\":false,\"numLocations\":1,\"numResolvedLocations\":1,\"resolveTime\":0.0020691},{\"details\":{\"Breakpoint\":{\"BKPTOptions\":{\"AutoContinue\":false,\"ConditionText\":\"\",\"EnabledState\":true,\"IgnoreCount\":0,\"OneShotState\":false},\"BKPTResolver\":{\"Options\":{\"Column\":0,\"Exact\":false,\"FileName\":\"/data/users/wanyi/llvm-sand/external/llvm-project/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp\",\"Inlines\":true,\"LineNumber\":5,\"Offset\":0,\"SkipPrologue\":true},\"Type\":\"FileAndLine\"},\"Hardware\":false,\"Names\":[\"vscode\"],\"SearchFilter\":{\"Options\":{},\"Type\":\"Unconstrained\"}}},\"id\":2,\"internal\":false,\"numLocations\":0,\"numResolvedLocations\":0,\"resolveTime\":0.256624999},{\"details\":{\"Breakpoint\":{\"BKPTOptions\":{\"AutoContinue\":false,\"ConditionText\":\"\",\"EnabledState\":true,\"IgnoreCount\":0,\"OneShotState\":false},\"BKPTResolver\":{\"Options\":{\"Language\":\"c\",\"NameMask\":[4,4,4,4,4,4],\"Offset\":0,\"SkipPrologue\":false,\"SymbolNames\":[\"_dl_debug_state\",\"rtld_db_dlactivity\",\"__dl_rtld_db_dlactivity\",\"r_debug_state\",\"_r_debug_state\",\"_rtld_debug_state\"]},\"Type\":\"SymbolName\"},\"Hardware\":false,\"SearchFilter\":{\"Options\":{\"ModuleList\":[\"/usr/lib64/ld-2.28.so\"]},\"Type\":\"Modules\"}}},\"id\":-1,\"internal\":true,\"kindDescription\":\"shared-library-event\",\"numLocations\":1,\"numResolvedLocations\":1,\"resolveTime\":0.00036601}],\"expressionEvaluation\":{\"failures\":0,\"successes\":0},\"firstStopTime\":0.163219069,\"frameVariable\":{\"failures\":0,\"successes\":0},\"launchOrAttachTime\":0.124005952,\"moduleIdentifiers\":[94453879969136,94453879680352,94453878991776,139787361446016,139787361476896,139787361522272,139787361656656,139787361825984,139787361883552],\"signals\":[{\"SIGSTOP\":1}],\"sourceMapDeduceCount\":0,\"stopCount\":8,\"targetCreateTime\":0.00060895,\"totalBreakpointResolveTime\":0.259059996}]","totalDebugInfoByteSize":1668056,"totalDebugInfoEnabled":3,"totalDebugInfoIndexLoadedFromCache":0,"totalDebugInfoIndexSavedToCache":0,"totalDebugInfoIndexTime":0.0325389998,"totalDebugInfoParseTime":0.371056,"totalModuleCount":10,"totalModuleCountHasDebugInfo":3,"totalSymbolTableIndexTime":0.051369,"totalSymbolTableParseTime":0.228127002,"totalSymbolTableStripped":0,"totalSymbolTablesLoadedFromCache":0,"totalSymbolTablesSavedToCache":0},"type":"event"}
  --> 
  Content-Length: 88
  
  
{"command":"disconnect","type":"request","arguments":{"terminateDebuggee":true},"seq":8}
  <-- 
  Content-Length: 81
  
  
{"command":"disconnect","request_seq":8,"seq":0,"success":true,"type":"response"}
  
  = END =
  PASS: LLDB 
(/data/users/wanyi/llvm-sand/build/Debug/fbcode-x86_64/toolchain/bin/clang-x86_64)
 :: test_terminated_event 
(TestVSCode_terminatedEvent.TestVSCode_terminatedEvent)
  --
  Ran 1 test in 7.237s
  
  RESULT: PASSED (1 passes, 0 failures, 0 errors, 0 skipped, 0 expected 
failures, 0 unexpected successes)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137003

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


[Lldb-commits] [PATCH] D137003: [lldb-vscode] Send Statistics Dump in terminated event

2022-11-03 Thread Wanyi Ye via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
kusmour marked an inline comment as done.
Closed by commit rGe3ccbae30927: [lldb-vscode] Send Statistics Dump in 
terminated event (authored by kusmour).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137003

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/terminated-event/Makefile
  lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
  lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -204,7 +204,7 @@
 g_vsc.sent_terminated_event = true;
 g_vsc.RunTerminateCommands();
 // Send a "terminated" event
-llvm::json::Object event(CreateEventObject("terminated"));
+llvm::json::Object event(CreateTerminatedEventObject());
 g_vsc.SendJSON(llvm::json::Value(std::move(event)));
   }
 }
@@ -2949,7 +2949,7 @@
   const uint32_t addr_size = g_vsc.target.GetProcess().GetAddressByteSize();
   lldb::SBValue reg_set = g_vsc.variables.registers.GetValueAtIndex(0);
   const uint32_t num_regs = reg_set.GetNumChildren();
-  for (uint32_t reg_idx=0; reg_idx pairs
+void FilterAndGetValueForKey(const lldb::SBStructuredData data, const char *key,
+ llvm::json::Object ) {
+  lldb::SBStructuredData value = data.GetValueForKey(key);
+  std::string key_utf8 = llvm::json::fixUTF8(key);
+  if (strcmp(key, "modules") == 0)
+return;
+  switch (value.GetType()) {
+  case lldb::eStructuredDataTypeFloat:
+out.try_emplace(key_utf8, value.GetFloatValue());
+break;
+  case lldb::eStructuredDataTypeInteger:
+out.try_emplace(key_utf8, value.GetIntegerValue());
+break;
+  case lldb::eStructuredDataTypeArray: {
+lldb::SBStream contents;
+value.GetAsJSON(contents);
+EmplaceSafeString(out, key, contents.GetData());
+  } break;
+  case lldb::eStructuredDataTypeBoolean:
+out.try_emplace(key_utf8, value.GetBooleanValue());
+break;
+  case lldb::eStructuredDataTypeString: {
+// Get the string size before reading
+const size_t str_length = value.GetStringValue(nullptr, 0);
+std::string str(str_length + 1, 0);
+value.GetStringValue([0], str_length);
+EmplaceSafeString(out, key, str);
+  } break;
+  case lldb::eStructuredDataTypeDictionary: {
+lldb::SBStream contents;
+value.GetAsJSON(contents);
+EmplaceSafeString(out, key, contents.GetData());
+  } break;
+  case lldb::eStructuredDataTypeNull:
+  case lldb::eStructuredDataTypeGeneric:
+  case lldb::eStructuredDataTypeInvalid:
+break;
+  }
+}
+
+void addStatistic(llvm::json::Object ) {
+  lldb::SBStructuredData statistics = g_vsc.target.GetStatistics();
+  bool is_dictionary =
+  statistics.GetType() == lldb::eStructuredDataTypeDictionary;
+  if (!is_dictionary)
+return;
+  llvm::json::Object stats_body;
+
+  lldb::SBStringList keys;
+  if (!statistics.GetKeys(keys))
+return;
+  for (size_t i = 0; i < keys.GetSize(); i++) {
+const char *key = keys.GetStringAtIndex(i);
+FilterAndGetValueForKey(statistics, key, stats_body);
+  }
+  event.try_emplace("statistics", std::move(stats_body));
+}
+
+llvm::json::Object CreateTerminatedEventObject() {
+  llvm::json::Object event(CreateEventObject("terminated"));
+  addStatistic(event);
+  return event;
+}
+
 std::string JSONToString(const llvm::json::Value ) {
   std::string data;
   llvm::raw_string_ostream os(data);
Index: lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include "foo.h"
+
+int main(int argc, char const *argv[]) {
+  std::cout << "Hello World!" << std::endl; // main breakpoint 1
+  foo();
+  return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
@@ -0,0 +1 @@
+int foo();
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
@@ -0,0 +1,3 @@
+int foo() {
+return 12;
+}
Index: lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py

[Lldb-commits] [PATCH] D137284: Override CalculateFrameVariableError in SymbolFileOnDemand

2022-11-02 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

It'd be great to put some background in the summary.

The issue is introduced when adding Symbol OnDemand feature. We added a wrapper 
that ignore the error. And this affected the ability to populate the error when 
we have this feature turned on :D

(something like this, would be nice to link back to the symbol OnDemand patch 
as well)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137284

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


[Lldb-commits] [PATCH] D136177: [lldb-vscode] Send Statistics Dump in terminated event

2022-10-25 Thread Wanyi Ye via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
kusmour marked 3 inline comments as done.
Closed by commit rGc8a26f8c6de3: [lldb-vscode] Send Statistics Dump in 
terminated event (authored by kusmour).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136177

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/terminated-event/Makefile
  lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
  lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
  lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -204,7 +204,7 @@
 g_vsc.sent_terminated_event = true;
 g_vsc.RunTerminateCommands();
 // Send a "terminated" event
-llvm::json::Object event(CreateEventObject("terminated"));
+llvm::json::Object event(CreateTerminatedEventObject());
 g_vsc.SendJSON(llvm::json::Value(std::move(event)));
   }
 }
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -485,6 +485,12 @@
   llvm::StringRef debug_adaptor_path,
   llvm::StringRef comm_file);
 
+/// Create a "Terminated" JSON object that contains statistics
+///
+/// \return
+/// A body JSON object with debug info and breakpoint info
+llvm::json::Object CreateTerminatedEventObject();
+
 /// Convert a given JSON object to a string.
 std::string JSONToString(const llvm::json::Value );
 
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -19,6 +19,7 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/API/SBDeclaration.h"
+#include "lldb/API/SBStructuredData.h"
 #include "lldb/API/SBValue.h"
 #include "lldb/Host/PosixApi.h"
 
@@ -1139,6 +1140,21 @@
   return reverse_request;
 }
 
+llvm::json::Object CreateTerminatedEventObject() {
+  llvm::json::Object event(CreateEventObject("terminated"));
+  lldb::SBStructuredData statistics = g_vsc.target.GetStatistics();
+  bool is_dictionary =
+  statistics.GetType() == lldb::eStructuredDataTypeDictionary;
+  if (!is_dictionary) {
+return event;
+  }
+
+  lldb::SBStream stats_stream;
+  statistics.GetAsJSON(stats_stream);
+  event.try_emplace("statistics", llvm::json::fixUTF8(stats_stream.GetData()));
+  return event;
+}
+
 std::string JSONToString(const llvm::json::Value ) {
   std::string data;
   llvm::raw_string_ostream os(data);
Index: lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp
@@ -0,0 +1,8 @@
+#include 
+#include "foo.h"
+
+int main(int argc, char const *argv[]) {
+  std::cout << "Hello World!" << std::endl; // main breakpoint 1
+  foo();
+  return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.h
@@ -0,0 +1 @@
+int foo();
Index: lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp
@@ -0,0 +1,3 @@
+int foo() {
+return 12;
+}
Index: lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py
@@ -0,0 +1,60 @@
+"""
+Test lldb-vscode terminated event
+"""
+
+import vscode
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbvscode_testcase
+import re
+import json
+
+class TestVSCode_terminatedEvent(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfRemote
+def test_terminated_event(self):
+'''
+Terminated Event
+Now contains the statistics of a debug session:
+metatdata:
+totalDebugInfoByteSize > 0
+totalDebugInfoEnabled > 0
+

[Lldb-commits] [PATCH] D65363: [lldb-vscode] add `launchCommands` to handle launch specific commands

2019-11-04 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour marked an inline comment as done.
kusmour added inline comments.



Comment at: lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp:1280
   // Reenable async events and start the event thread to catch async events.
-  g_vsc.debugger.SetAsync(true);
+  // g_vsc.debugger.SetAsync(true);
 }

wallace wrote:
> was this intentional?
ohh yes, it should be deleted


Repository:
  rL LLVM

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

https://reviews.llvm.org/D65363



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


[Lldb-commits] [PATCH] D65784: [lldb] delete "--platform-path" option from "target create"

2019-08-07 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

In D65784#1616118 , @jasonmolenda 
wrote:

> Yeah, it's not currently hooked up to anything; I'm returning to 
> remote-platform testing soon, if we've lost some necessary functionality I 
> can re-add it, but this option right now isn't doing anything.


Thank you for your reply. Would  you like to merge this change? I can abandon 
it if you are going to work on this.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D65784



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


[Lldb-commits] [PATCH] D65784: [lldb] delete "--platform-path" option from "target create"

2019-08-05 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added a reviewer: xiaobai.
Herald added subscribers: lldb-commits, abidh.
Herald added a project: LLDB.

This option is dead. lldb under platform mode can resolve the path wether it's 
on remote platform or not
clean the option to avoid misleading


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D65784

Files:
  lldb/source/Commands/CommandObjectTarget.cpp


Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -220,9 +220,6 @@
 m_option_group(), m_arch_option(),
 m_core_file(LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename,
 "Fullpath to a core file to use for this target."),
-m_platform_path(LLDB_OPT_SET_1, false, "platform-path", 'P', 0,
-eArgTypePath,
-"Path to the remote file to use for this target."),
 m_symbol_file(LLDB_OPT_SET_1, false, "symfile", 's', 0,
   eArgTypeFilename,
   "Fullpath to a stand alone debug "
@@ -248,7 +245,6 @@
 
 m_option_group.Append(_arch_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_core_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
-m_option_group.Append(_platform_path, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_symbol_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_remote_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_add_dependents, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
@@ -472,7 +468,6 @@
   OptionGroupOptions m_option_group;
   OptionGroupArchitecture m_arch_option;
   OptionGroupFile m_core_file;
-  OptionGroupFile m_platform_path;
   OptionGroupFile m_symbol_file;
   OptionGroupFile m_remote_file;
   OptionGroupDependents m_add_dependents;


Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -220,9 +220,6 @@
 m_option_group(), m_arch_option(),
 m_core_file(LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename,
 "Fullpath to a core file to use for this target."),
-m_platform_path(LLDB_OPT_SET_1, false, "platform-path", 'P', 0,
-eArgTypePath,
-"Path to the remote file to use for this target."),
 m_symbol_file(LLDB_OPT_SET_1, false, "symfile", 's', 0,
   eArgTypeFilename,
   "Fullpath to a stand alone debug "
@@ -248,7 +245,6 @@
 
 m_option_group.Append(_arch_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_core_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
-m_option_group.Append(_platform_path, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_symbol_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_remote_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
 m_option_group.Append(_add_dependents, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
@@ -472,7 +468,6 @@
   OptionGroupOptions m_option_group;
   OptionGroupArchitecture m_arch_option;
   OptionGroupFile m_core_file;
-  OptionGroupFile m_platform_path;
   OptionGroupFile m_symbol_file;
   OptionGroupFile m_remote_file;
   OptionGroupDependents m_add_dependents;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65363: [lldb-vscode] add `launchCommands` to handle launch specific commands

2019-07-31 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 212683.
kusmour added a comment.

complete the corresponding test for extra `launchCommands`


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D65363

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/launch/TestVSCode_launch.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1180,6 +1180,7 @@
   g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands");
   g_vsc.stop_commands = GetStrings(arguments, "stopCommands");
   g_vsc.exit_commands = GetStrings(arguments, "exitCommands");
+  auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
 
@@ -1252,11 +1253,19 @@
 
   // Run any pre run LLDB commands the user specified in the launch.json
   g_vsc.RunPreRunCommands();
+  if (launchCommands.empty()) {
+// Disable async events so the launch will be successful when we return from
+// the launch call and the launch will happen synchronously
+g_vsc.debugger.SetAsync(false);
+g_vsc.target.Launch(g_vsc.launch_info, error);
+g_vsc.debugger.SetAsync(true);
+  } else {
+g_vsc.RunLLDBCommands("Running launchCommands:", launchCommands);
+// The custom commands might have created a new target so we should use the
+// selected target after these commands are run.
+g_vsc.target = g_vsc.debugger.GetSelectedTarget();
+  }
 
-  // Disable async events so the launch will be successful when we return from
-  // the launch call and the launch will happen synchronously
-  g_vsc.debugger.SetAsync(false);
-  g_vsc.target.Launch(g_vsc.launch_info, error);
   if (error.Fail()) {
 response["success"] = llvm::json::Value(false);
 EmplaceSafeString(response, "message", std::string(error.GetCString()));
@@ -1266,7 +1275,7 @@
   SendProcessEvent(Launch);
   g_vsc.SendJSON(llvm::json::Value(CreateEventObject("initialized")));
   // Reenable async events and start the event thread to catch async events.
-  g_vsc.debugger.SetAsync(true);
+  // g_vsc.debugger.SetAsync(true);
 }
 
 // "NextRequest": {
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -558,7 +558,7 @@
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
-   debuggerRoot=None):
+   debuggerRoot=None, launchCommands=None):
 args_dict = {
 'program': program
 }
@@ -591,6 +591,8 @@
 args_dict['sourcePath'] = sourcePath
 if debuggerRoot:
 args_dict['debuggerRoot'] = debuggerRoot
+if launchCommands:
+args_dict['launchCommands'] = launchCommands
 command_dict = {
 'command': 'launch',
 'type': 'request',
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -245,20 +245,17 @@
 self.assertTrue(response['success'],
 'attach failed (%s)' % (response['message']))
 
-def build_and_launch(self, program, args=None, cwd=None, env=None,
- stopOnEntry=False, disableASLR=True,
- disableSTDIO=False, shellExpandArguments=False,
- trace=False, initCommands=None, preRunCommands=None,
- stopCommands=None, exitCommands=None,
- sourcePath=None, debuggerRoot=None):
-'''Build the default Makefile target, create the VSCode debug adaptor,
-   and launch the process.
+def launch(self, program=None, args=None, cwd=None, env=None,
+   stopOnEntry=False, disableASLR=True,
+   disableSTDIO=False, shellExpandArguments=False,
+   trace=False, initCommands=None, preRunCommands=None,
+   stopCommands=None, exitCommands=None,sourcePath= None,
+   debuggerRoot=None, launchCommands=None):
+'''Sending launch request to 

[Lldb-commits] [PATCH] D65363: [lldb-vscode] add `launchCommands` to handle launch specific commands

2019-07-26 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added a reviewer: xiaobai.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This can help `lldb-vscode` handle launch commands associate with remote 
platform
attach request have field `attachCommands` to handle attach specific commands
add a corresponding one for launch request
if no launch command is provided, create a new target and launch; otherwise, 
execute the launch command


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D65363

Files:
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1180,6 +1180,7 @@
   g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands");
   g_vsc.stop_commands = GetStrings(arguments, "stopCommands");
   g_vsc.exit_commands = GetStrings(arguments, "exitCommands");
+  auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
 
@@ -1252,11 +1253,19 @@
 
   // Run any pre run LLDB commands the user specified in the launch.json
   g_vsc.RunPreRunCommands();
-
-  // Disable async events so the launch will be successful when we return from
-  // the launch call and the launch will happen synchronously
   g_vsc.debugger.SetAsync(false);
-  g_vsc.target.Launch(g_vsc.launch_info, error);
+  if (launchCommands.empty()) {
+// Disable async events so the launch will be successful when we return 
from
+// the launch call and the launch will happen synchronously
+g_vsc.target.Launch(g_vsc.launch_info, error);
+// g_vsc.debugger.SetAsync(true);
+  } else {
+g_vsc.RunLLDBCommands("Running launchCommands:", launchCommands);
+// The custom commands might have created a new target so we should use the
+// selected target after these commands are run.
+g_vsc.target = g_vsc.debugger.GetSelectedTarget();
+  }
+
   if (error.Fail()) {
 response["success"] = llvm::json::Value(false);
 EmplaceSafeString(response, "message", std::string(error.GetCString()));


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1180,6 +1180,7 @@
   g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands");
   g_vsc.stop_commands = GetStrings(arguments, "stopCommands");
   g_vsc.exit_commands = GetStrings(arguments, "exitCommands");
+  auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
 
@@ -1252,11 +1253,19 @@
 
   // Run any pre run LLDB commands the user specified in the launch.json
   g_vsc.RunPreRunCommands();
-
-  // Disable async events so the launch will be successful when we return from
-  // the launch call and the launch will happen synchronously
   g_vsc.debugger.SetAsync(false);
-  g_vsc.target.Launch(g_vsc.launch_info, error);
+  if (launchCommands.empty()) {
+// Disable async events so the launch will be successful when we return from
+// the launch call and the launch will happen synchronously
+g_vsc.target.Launch(g_vsc.launch_info, error);
+// g_vsc.debugger.SetAsync(true);
+  } else {
+g_vsc.RunLLDBCommands("Running launchCommands:", launchCommands);
+// The custom commands might have created a new target so we should use the
+// selected target after these commands are run.
+g_vsc.target = g_vsc.debugger.GetSelectedTarget();
+  }
+
   if (error.Fail()) {
 response["success"] = llvm::json::Value(false);
 EmplaceSafeString(response, "message", std::string(error.GetCString()));
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64767: [lldb][test_suite] Update tests with unexpected pass on Android aarch64

2019-07-16 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

In D64767#1587311 , @labath wrote:

> Whether a lot of these tests (e.g. all watchpoint related tests) pass or fail 
> may depend on the exact android device you are running the tests against. 
> However, you are the only ones running android tests ATM, so that does not 
> matter much right now. If that ever changes, we'll have to do something 
> smarter here...


Thank you very much! I will test on more devices later.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64767



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


[Lldb-commits] [PATCH] D64769: [lldb][test_suite] change the test main.cpp to avoid expression reschedule

2019-07-16 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

In D64769#1587318 , @labath wrote:

> The change is fine, but for my own education, could you elaborate on what 
> this "delayed calculation" is, and how does it make the test fail?


The test set the breakpoint to the return statement, even thought the compiler 
flag `-O0` was set, the first hit to that bp showed that `g_common_1 = 0` which 
actually should be 21. The test assume when we hit the return statement, the 
value should already be calculated, but that's not the case for NDK20 clang.

So we reproduce the test manually, turned out that the value was calculated 
later. lldb first hit the return statement then jump back to line 20. By 
looking at the assembly that clang provided, it indeed jump back and forth.

It's possible that the jumping behavior is caused by optimization, considering 
there're some other tests having similar problem, and the behavior changed a 
lot from NDK 19 to 20. I made this change because this is irrelevant to testing 
global variables.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64769



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


[Lldb-commits] [PATCH] D64771: [lldb][test_suite] skip tests of `libstdcpp` on Android and clean up

2019-07-15 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added reviewers: xiaobai, labath.
Herald added subscribers: lldb-commits, srhines.
Herald added a project: LLDB.

Delete the android target from `libstdcpp` test category, since android no 
longer support libstdcxx


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64771

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/make/Android.rules


Index: lldb/packages/Python/lldbsuite/test/make/Android.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -72,24 +72,18 @@
 
 ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \
-isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \
-   -D__ANDROID_API__=$(API_LEVEL)
-ARCH_LDFLAGS += 
--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
+   -D__ANDROID_API__=$(API_LEVEL) \
+   -isystem 
$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include
 
-ifeq (1,$(USE_LIBSTDCPP))
-   ARCH_CFLAGS += \
-   -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
-   -isystem 
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
-   -isystem 
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
+ARCH_LDFLAGS += 
--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
 
-   ARCH_LDFLAGS += 
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
-else
-   ARCH_CXXFLAGS += \
-   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
-   -isystem $(NDK_ROOT)/sources/android/support/include \
-   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
+ARCH_CXXFLAGS += \
+   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
+   -isystem $(NDK_ROOT)/sources/android/support/include \
+   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
 
-   ARCH_LDFLAGS += \
-   -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
-   
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
-   -lc++abi
-endif
+ARCH_LDFLAGS += \
+   -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
+   
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
+   -lc++abi \
+   -nostdlib++
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1171,8 +1171,10 @@
 from lldbsuite.test import lldbplatformutil
 
 platform = lldbplatformutil.getPlatform()
+if lldbplatformutil.target_is_android():
+platform = "android"
 if platform == "linux":
-  return True, "libstdcxx always present"
+return True, "libstdcxx always present"
 return False, "Don't know how to build with libstdcxx on %s" % platform
 
 def checkLibstdcxxSupport():


Index: lldb/packages/Python/lldbsuite/test/make/Android.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -72,24 +72,18 @@
 
 ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \
 	-isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \
-	-D__ANDROID_API__=$(API_LEVEL)
-ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
+	-D__ANDROID_API__=$(API_LEVEL) \
+	-isystem $(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include
 
-ifeq (1,$(USE_LIBSTDCPP))
-	ARCH_CFLAGS += \
-		-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
-		-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
-		-isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
+ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
 
-	ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
-else
-	ARCH_CXXFLAGS += \
-		-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
-		-isystem $(NDK_ROOT)/sources/android/support/include \
-		-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
+ARCH_CXXFLAGS += \
+	-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
+	-isystem $(NDK_ROOT)/sources/android/support/include \
+	-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
 
-	ARCH_LDFLAGS += \
-		-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
-		$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
-		-lc++abi
-endif
+ARCH_LDFLAGS += \
+	-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
+	

[Lldb-commits] [PATCH] D64769: [lldb][test_suite] change the test main.cpp to avoid expression reschedule

2019-07-15 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added reviewers: xiaobai, labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Added a local variable to hold the return value to avoid delayed calculation on 
variables
This issue occurred when using NDK 20 clang with `-O0` flag set


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64769

Files:
  lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c


Index: lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
===
--- lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
+++ lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
@@ -20,5 +20,6 @@
 g_common_1 = g_file_global_int / g_file_static_int;
 static const char *g_func_static_cstr = "g_func_static_cstr";
 printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
-return g_file_global_int + g_a + g_common_1 + *g_ptr; // Set break point 
at this line.   break $source:$line; continue; var -global g_a -global 
g_global_int
+int return_val = g_file_global_int + g_a + g_common_1 + *g_ptr;
+return return_val; // Set break point at this line.   break 
$source:$line; continue; var -global g_a -global g_global_int
 }


Index: lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
===
--- lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
+++ lldb/packages/Python/lldbsuite/test/lang/c/global_variables/main.c
@@ -20,5 +20,6 @@
 g_common_1 = g_file_global_int / g_file_static_int;
 static const char *g_func_static_cstr = "g_func_static_cstr";
 printf ("%s %s\n", g_file_global_cstr, g_file_static_cstr);
-return g_file_global_int + g_a + g_common_1 + *g_ptr; // Set break point at this line.   break $source:$line; continue; var -global g_a -global g_global_int
+int return_val = g_file_global_int + g_a + g_common_1 + *g_ptr;
+return return_val; // Set break point at this line.   break $source:$line; continue; var -global g_a -global g_global_int
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64767: [lldb][test_suite] Update tests with unexpected pass on Android aarch64

2019-07-15 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added reviewers: xiaobai, labath.
Herald added subscribers: lldb-commits, kristof.beyls, javed.absar, srhines.
Herald added a project: LLDB.

update some test decorates that can actually pass on andriod aarch64


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64767

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
  
lldb/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py
  
lldb/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
  
lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
  
lldb/packages/Python/lldbsuite/test/functionalities/target_command/TestTargetCommand.py
  
lldb/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py
  
lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
  
lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py
  
lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
  
lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
  
lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
  
lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py

Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -1279,7 +1279,6 @@
 
 @llgs_test
 @skipUnlessPlatform(oslist=['linux'])
-@expectedFailureAndroid
 @skipIf(archs=no_match(['arm', 'aarch64']))
 def test_hardware_breakpoint_set_and_remove_work_llgs(self):
 self.init_llgs_test()
Index: lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
===
--- lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
+++ lldb/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py
@@ -36,6 +36,7 @@
 @expectedFailureAll(
 oslist=["linux"],
 archs=["aarch64"],
+triple=no_match(".*-android"),
 bugnumber="llvm.org/pr27710")
 @skipIfWindows  # Watchpoints not supported on Windows, and this test hangs
 def test_watchpoint_cond_api(self):
Index: lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/packages/Python/lldbsuite/test/lang/c/global_variables/TestGlobalVariables.py
@@ -22,7 +22,10 @@
 self.shlib_names = ["a"]
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureAll(oslist=["linux"], archs=["aarch64"], bugnumber="llvm.org/pr37301")
+@expectedFailureAll(oslist=["linux"],
+archs=["aarch64"],
+triple=no_match(".*-android"),
+bugnumber="llvm.org/pr37301")
 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
===
--- lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
+++ lldb/packages/Python/lldbsuite/test/lang/c/const_variables/TestConstVariables.py
@@ -31,6 +31,7 @@
 archs=[
 'arm',
 'aarch64'],
+triple=no_match(".*-android"),
 bugnumber="llvm.org/pr27883")
 @expectedFailureAll(
 oslist=["windows"],
Index: lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
===
--- lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
+++ lldb/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_events/TestWatchpointEvents.py
@@ -25,6 +25,7 @@
 @expectedFailureAll(
 oslist=["linux"],
 archs=["aarch64"],
+triple=no_match(".*-android"),
 

[Lldb-commits] [PATCH] D64583: [lldb][test_suite] Fix skipIfTargetAndroid decorator

2019-07-11 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 209325.
kusmour edited the summary of this revision.
kusmour added a comment.
Herald added a subscriber: abidh.

add more context to diff


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64583

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -596,18 +596,13 @@
 """Decorate the item to skip tests that should be skipped on Windows."""
 return skipIfPlatform(["windows"])(func)

-def skipIfTargetAndroid(func):
-return unittest2.skipIf(lldbplatformutil.target_is_android(),
-"skip on target Android")(func)
-
-
 def skipUnlessWindows(func):
 """Decorate the item to skip tests that should be skipped on any 
non-Windows platform."""
 return skipUnlessPlatform(["windows"])(func)


 def skipUnlessDarwin(func):
 """Decorate the item to skip tests that should be skipped on any non 
Darwin platform."""
 return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)

 def skipUnlessTargetAndroid(func):
@@ -652,9 +647,9 @@
 "requires one of %s" % (", ".join(oslist)))


-def skipIfTargetAndroid(api_levels=None, archs=None):
+def skipIfTargetAndroid(bugnumber=None, api_levels=None, archs=None):
 """Decorator to skip tests when the target is Android.

 Arguments:
 api_levels - The API levels for which the test should be skipped. If
 it is None, then the test will be skipped for all API levels.
@@ -665,8 +660,9 @@
 _skip_for_android(
 "skipping for android",
 api_levels,
-archs))
+archs),
+bugnumber)

 def skipUnlessSupportedTypeAttribute(attr):
 """Decorate the item to skip test unless Clang supports type 
__attribute__(attr)."""
 def compiler_doesnt_support_struct_attribute(self):


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -596,18 +596,13 @@
 """Decorate the item to skip tests that should be skipped on Windows."""
 return skipIfPlatform(["windows"])(func)

-def skipIfTargetAndroid(func):
-return unittest2.skipIf(lldbplatformutil.target_is_android(),
-"skip on target Android")(func)
-
-
 def skipUnlessWindows(func):
 """Decorate the item to skip tests that should be skipped on any non-Windows platform."""
 return skipUnlessPlatform(["windows"])(func)


 def skipUnlessDarwin(func):
 """Decorate the item to skip tests that should be skipped on any non Darwin platform."""
 return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)

 def skipUnlessTargetAndroid(func):
@@ -652,9 +647,9 @@
 "requires one of %s" % (", ".join(oslist)))


-def skipIfTargetAndroid(api_levels=None, archs=None):
+def skipIfTargetAndroid(bugnumber=None, api_levels=None, archs=None):
 """Decorator to skip tests when the target is Android.

 Arguments:
 api_levels - The API levels for which the test should be skipped. If
 it is None, then the test will be skipped for all API levels.
@@ -665,8 +660,9 @@
 _skip_for_android(
 "skipping for android",
 api_levels,
-archs))
+archs),
+bugnumber)

 def skipUnlessSupportedTypeAttribute(attr):
 """Decorate the item to skip test unless Clang supports type __attribute__(attr)."""
 def compiler_doesnt_support_struct_attribute(self):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64583: [lldb][test_suite] Fix skipIfTargetAndroid decorator

2019-07-11 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added a reviewer: xiaobai.
Herald added subscribers: lldb-commits, srhines.
Herald added a project: LLDB.

Delete the duplicate func `skipIfTargetAndroid`
Fix the old one


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64583

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -596,11 +596,6 @@
 """Decorate the item to skip tests that should be skipped on Windows."""
 return skipIfPlatform(["windows"])(func)

-def skipIfTargetAndroid(func):
-return unittest2.skipIf(lldbplatformutil.target_is_android(),
-"skip on target Android")(func)
-
-
 def skipUnlessWindows(func):
 """Decorate the item to skip tests that should be skipped on any 
non-Windows platform."""
 return skipUnlessPlatform(["windows"])(func)
@@ -652,7 +647,7 @@
 "requires one of %s" % (", ".join(oslist)))


-def skipIfTargetAndroid(api_levels=None, archs=None):
+def skipIfTargetAndroid(bugnumber=None, api_levels=None, archs=None):
 """Decorator to skip tests when the target is Android.

 Arguments:
@@ -665,7 +660,8 @@
 _skip_for_android(
 "skipping for android",
 api_levels,
-archs))
+archs),
+bugnumber)

 def skipUnlessSupportedTypeAttribute(attr):
 """Decorate the item to skip test unless Clang supports type 
__attribute__(attr)."""


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -596,11 +596,6 @@
 """Decorate the item to skip tests that should be skipped on Windows."""
 return skipIfPlatform(["windows"])(func)

-def skipIfTargetAndroid(func):
-return unittest2.skipIf(lldbplatformutil.target_is_android(),
-"skip on target Android")(func)
-
-
 def skipUnlessWindows(func):
 """Decorate the item to skip tests that should be skipped on any non-Windows platform."""
 return skipUnlessPlatform(["windows"])(func)
@@ -652,7 +647,7 @@
 "requires one of %s" % (", ".join(oslist)))


-def skipIfTargetAndroid(api_levels=None, archs=None):
+def skipIfTargetAndroid(bugnumber=None, api_levels=None, archs=None):
 """Decorator to skip tests when the target is Android.

 Arguments:
@@ -665,7 +660,8 @@
 _skip_for_android(
 "skipping for android",
 api_levels,
-archs))
+archs),
+bugnumber)

 def skipUnlessSupportedTypeAttribute(attr):
 """Decorate the item to skip test unless Clang supports type __attribute__(attr)."""
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64434: [lldb] Quick Fix: IRExecutionUnit check pointer before access it

2019-07-09 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added reviewers: xiaobai, compnerd.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Move checking pointer code block before accessing the pointer
This caused lldb to crash when testing on Android


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64434

Files:
  lldb/source/Expression/IRExecutionUnit.cpp


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -285,9 +285,6 @@

   m_execution_engine_up.reset(builder.create(target_machine));

-  m_strip_underscore =
-  (m_execution_engine_up->getDataLayout().getGlobalPrefix() == '_');
-
   if (!m_execution_engine_up) {
 error.SetErrorToGenericError();
 error.SetErrorStringWithFormat("Couldn't JIT the function: %s",
@@ -295,6 +292,9 @@
 return;
   }

+  m_strip_underscore =
+  (m_execution_engine_up->getDataLayout().getGlobalPrefix() == '_');
+
   class ObjectDumper : public llvm::ObjectCache {
   public:
 void notifyObjectCompiled(const llvm::Module *module,


Index: lldb/source/Expression/IRExecutionUnit.cpp
===
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -285,9 +285,6 @@

   m_execution_engine_up.reset(builder.create(target_machine));

-  m_strip_underscore =
-  (m_execution_engine_up->getDataLayout().getGlobalPrefix() == '_');
-
   if (!m_execution_engine_up) {
 error.SetErrorToGenericError();
 error.SetErrorStringWithFormat("Couldn't JIT the function: %s",
@@ -295,6 +292,9 @@
 return;
   }

+  m_strip_underscore =
+  (m_execution_engine_up->getDataLayout().getGlobalPrefix() == '_');
+
   class ObjectDumper : public llvm::ObjectCache {
   public:
 void notifyObjectCompiled(const llvm::Module *module,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D64118: [lldb_test_suite] Fix lldb test suite targeting remote Android

2019-07-08 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 208465.
kusmour edited the summary of this revision.
kusmour added a comment.

added method skipIfTargetAndroid


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D64118

Files:
  
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/make/Android.rules


Index: lldb/packages/Python/lldbsuite/test/make/Android.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -90,5 +90,6 @@
 
ARCH_LDFLAGS += \
-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
-   
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a
+   
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
+   -lc++abi
 endif
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -596,6 +596,10 @@
 """Decorate the item to skip tests that should be skipped on Windows."""
 return skipIfPlatform(["windows"])(func)
 
+def skipIfTargetAndroid(func):
+return unittest2.skipIf(lldbplatformutil.target_is_android(),
+"skip on target Android")(func)
+
 
 def skipUnlessWindows(func):
 """Decorate the item to skip tests that should be skipped on any 
non-Windows platform."""
@@ -606,6 +610,10 @@
 """Decorate the item to skip tests that should be skipped on any non 
Darwin platform."""
 return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)
 
+def skipUnlessTargetAndroid(func):
+return unittest2.skipUnless(lldbplatformutil.target_is_android(),
+"requires target to be Android")(func)
+
 
 def skipIfHostIncompatibleWithRemote(func):
 """Decorate the item to skip tests if binaries built on this host are 
incompatible."""
Index: 
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
===
--- 
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
+++ 
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
@@ -16,7 +16,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@skipUnlessPlatform(['android'])
+@skipUnlessTargetAndroid
 def test_cache_line_size(self):
 self.build(dictionary=self.getBuildFlags())
 exe = self.getBuildArtifact("a.out")


Index: lldb/packages/Python/lldbsuite/test/make/Android.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -90,5 +90,6 @@
 
 	ARCH_LDFLAGS += \
 		-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
-		$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a
+		$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
+		-lc++abi
 endif
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -596,6 +596,10 @@
 """Decorate the item to skip tests that should be skipped on Windows."""
 return skipIfPlatform(["windows"])(func)
 
+def skipIfTargetAndroid(func):
+return unittest2.skipIf(lldbplatformutil.target_is_android(),
+"skip on target Android")(func)
+
 
 def skipUnlessWindows(func):
 """Decorate the item to skip tests that should be skipped on any non-Windows platform."""
@@ -606,6 +610,10 @@
 """Decorate the item to skip tests that should be skipped on any non Darwin platform."""
 return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)
 
+def skipUnlessTargetAndroid(func):
+return unittest2.skipUnless(lldbplatformutil.target_is_android(),
+"requires target to be Android")(func)
+
 
 def skipIfHostIncompatibleWithRemote(func):
 """Decorate the item to skip tests if binaries built on this host are incompatible."""
Index: lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
===
--- lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
+++ lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
@@ -16,7 +16,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@skipUnlessPlatform(['android'])
+

[Lldb-commits] [PATCH] D64118: [lldb_test_suite] Fix lldb test suite targeting remote Android

2019-07-02 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added a reviewer: xiaobai.
Herald added subscribers: lldb-commits, srhines.
Herald added a project: LLDB.

Fixed `Android.rules` for running test suite on remote android

- the build configuration is not compatible with ndk structure, change it to 
link to static libc++
- generally clang should be able to use libc++ and will link against the right 
library, but some libc++ installations require the user manually link libc++abi.
- add flag `-lc++abi` to fix the test binary build failure

Added `skipIfTargetAndroid` for better test support

- the `skipIfPlatform` method will ask `lldbplatformutil.getPlatform()` for 
platform info which is actually the os type, and *Android* is not os type but 
environment
- create this function to handle the android target condition


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D64118

Files:
  
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/make/Android.rules


Index: lldb/packages/Python/lldbsuite/test/make/Android.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -90,5 +90,6 @@
 
ARCH_LDFLAGS += \
-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
-   
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a
+   
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
+   -lc++abi
 endif
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -606,6 +606,10 @@
 """Decorate the item to skip tests that should be skipped on any non 
Darwin platform."""
 return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)
 
+def skipUnlessTargetAndroid(func):
+return unittest2.skipUnless(lldbplatformutil.target_is_android(),
+"requires target to be Android")(func)
+
 
 def skipIfHostIncompatibleWithRemote(func):
 """Decorate the item to skip tests if binaries built on this host are 
incompatible."""
Index: 
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
===
--- 
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
+++ 
lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
@@ -16,7 +16,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@skipUnlessPlatform(['android'])
+@skipUnlessTargetAndroid
 def test_cache_line_size(self):
 self.build(dictionary=self.getBuildFlags())
 exe = self.getBuildArtifact("a.out")


Index: lldb/packages/Python/lldbsuite/test/make/Android.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Android.rules
+++ lldb/packages/Python/lldbsuite/test/make/Android.rules
@@ -90,5 +90,6 @@
 
 	ARCH_LDFLAGS += \
 		-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
-		$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a
+		$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \
+		-lc++abi
 endif
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -606,6 +606,10 @@
 """Decorate the item to skip tests that should be skipped on any non Darwin platform."""
 return skipUnlessPlatform(lldbplatformutil.getDarwinOSTriples())(func)
 
+def skipUnlessTargetAndroid(func):
+return unittest2.skipUnless(lldbplatformutil.target_is_android(),
+"requires target to be Android")(func)
+
 
 def skipIfHostIncompatibleWithRemote(func):
 """Decorate the item to skip tests if binaries built on this host are incompatible."""
Index: lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
===
--- lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
+++ lldb/packages/Python/lldbsuite/test/android/platform/TestDefaultCacheLineSize.py
@@ -16,7 +16,7 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@skipUnlessPlatform(['android'])
+@skipUnlessTargetAndroid
 def test_cache_line_size(self):
 self.build(dictionary=self.getBuildFlags())
 exe = self.getBuildArtifact("a.out")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-06-19 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 205640.
kusmour added a comment.

allow SysV_x86_64 ABI to handle unknown OS type
this should fix the test `SymbolFile/DWARF/debug_loc.s`


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  
lldb/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -24,6 +24,11 @@
 
 #define DEFINE_GPR(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase
 #define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
+#define DEFINE_FPU_XMM(reg)\
+  #reg, NULL, 16, 0, eEncodingUint, eFormatVectorOfUInt64, \
+  {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM,\
+   LLDB_INVALID_REGNUM, lldb_##reg##_x86_64},  \
+  nullptr, nullptr, nullptr, 0
 
 namespace {
 
@@ -51,7 +56,24 @@
   eRegisterIndexR14,
   eRegisterIndexR15,
   eRegisterIndexRip,
-  eRegisterIndexRflags
+  eRegisterIndexRflags,
+
+  eRegisterIndexXmm0,
+  eRegisterIndexXmm1,
+  eRegisterIndexXmm2,
+  eRegisterIndexXmm3,
+  eRegisterIndexXmm4,
+  eRegisterIndexXmm5,
+  eRegisterIndexXmm6,
+  eRegisterIndexXmm7,
+  eRegisterIndexXmm8,
+  eRegisterIndexXmm9,
+  eRegisterIndexXmm10,
+  eRegisterIndexXmm11,
+  eRegisterIndexXmm12,
+  eRegisterIndexXmm13,
+  eRegisterIndexXmm14,
+  eRegisterIndexXmm15
 };
 
 // Array of all register information supported by Windows x86
@@ -133,14 +155,14 @@
  nullptr,
  0},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr,
  nullptr,
  0},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr,
@@ -188,6 +210,22 @@
  nullptr,
  nullptr,
  0},
+{DEFINE_FPU_XMM(xmm0)},
+{DEFINE_FPU_XMM(xmm1)},
+{DEFINE_FPU_XMM(xmm2)},
+{DEFINE_FPU_XMM(xmm3)},
+{DEFINE_FPU_XMM(xmm4)},
+{DEFINE_FPU_XMM(xmm5)},
+{DEFINE_FPU_XMM(xmm6)},
+{DEFINE_FPU_XMM(xmm7)},
+{DEFINE_FPU_XMM(xmm8)},
+{DEFINE_FPU_XMM(xmm9)},
+{DEFINE_FPU_XMM(xmm10)},
+{DEFINE_FPU_XMM(xmm11)},
+{DEFINE_FPU_XMM(xmm12)},
+{DEFINE_FPU_XMM(xmm13)},
+{DEFINE_FPU_XMM(xmm14)},
+{DEFINE_FPU_XMM(xmm15)}
 };
 
 static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -202,10 +240,20 @@
 eRegisterIndexR12, eRegisterIndexR13, eRegisterIndexR14,
 eRegisterIndexR15, eRegisterIndexRip, eRegisterIndexRflags};
 
+uint32_t g_fpu_reg_indices[] = {
+eRegisterIndexXmm0,  eRegisterIndexXmm1,  eRegisterIndexXmm2,
+eRegisterIndexXmm3,  eRegisterIndexXmm4,  eRegisterIndexXmm5,
+eRegisterIndexXmm6,  eRegisterIndexXmm7,  eRegisterIndexXmm8,
+eRegisterIndexXmm9,  eRegisterIndexXmm10, eRegisterIndexXmm11,
+eRegisterIndexXmm12, eRegisterIndexXmm13, eRegisterIndexXmm14,
+eRegisterIndexXmm15
+};
+
 RegisterSet g_register_sets[] = {
 {"General Purpose Registers", "gpr",
  llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
-};
+{"Floating Point Registers", "fpu",
+ llvm::array_lengthof(g_fpu_reg_indices), g_fpu_reg_indices}};
 }
 
 // Constructors and Destructors
@@ -242,7 +290,9 @@
   if (reg_info == nullptr)
 return false;
 
-  switch (reg_info->kinds[eRegisterKindLLDB]) {
+  const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+
+  switch (reg) {
   case lldb_rax_x86_64:
 reg_value.SetUInt64(m_context.Rax);
 break;
@@ -297,6 +347,70 @@
   case lldb_rflags_x86_64:
 reg_value.SetUInt64(m_context.EFlags);
 break;
+  case lldb_xmm0_x86_64:
+reg_value.SetBytes(_context.Xmm0,
+   reg_info->byte_size, endian::InlHostByteOrder());
+break;
+  case lldb_xmm1_x86_64:
+reg_value.SetBytes(_context.Xmm1,
+   reg_info->byte_size, 

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-06-18 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

@labath Hi, you're right about the `lld`, it didn't make the test pass, instead 
it became unsupported.

In D62213#1548835 , @labath wrote:

> Can you elaborate on that? How exactly did it break this test?


So the problem here is that, `llvm-mc` constructs the Triple correctly, but 
lldb does not preserve all the information from it, at least it does not know 
about the OS type.

> Maybe we should make the SysV abi plugin match unknown oss too...

I'm not sure this is the right thing to do, but this should fix the problem.

> The only format where we have trouble determining the OS is ELF, and it's a 
> pretty good bet that any elf file will be using the "SysV" ABI...

Can you provide more information about this? It sounds like a bug


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213



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


[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-06-18 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 205390.
kusmour added a comment.

the OS check in SysV x64 ABI broke the test `SymbolFile/DWARF/debug_loc.s`
added a restriction `lld` to `#REQUIRES`


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  lldb/lit/SymbolFile/DWARF/debug_loc.s
  
lldb/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -24,6 +24,11 @@
 
 #define DEFINE_GPR(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase
 #define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
+#define DEFINE_FPU_XMM(reg)\
+  #reg, NULL, 16, 0, eEncodingUint, eFormatVectorOfUInt64, \
+  {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM,\
+   LLDB_INVALID_REGNUM, lldb_##reg##_x86_64},  \
+  nullptr, nullptr, nullptr, 0
 
 namespace {
 
@@ -51,7 +56,24 @@
   eRegisterIndexR14,
   eRegisterIndexR15,
   eRegisterIndexRip,
-  eRegisterIndexRflags
+  eRegisterIndexRflags,
+
+  eRegisterIndexXmm0,
+  eRegisterIndexXmm1,
+  eRegisterIndexXmm2,
+  eRegisterIndexXmm3,
+  eRegisterIndexXmm4,
+  eRegisterIndexXmm5,
+  eRegisterIndexXmm6,
+  eRegisterIndexXmm7,
+  eRegisterIndexXmm8,
+  eRegisterIndexXmm9,
+  eRegisterIndexXmm10,
+  eRegisterIndexXmm11,
+  eRegisterIndexXmm12,
+  eRegisterIndexXmm13,
+  eRegisterIndexXmm14,
+  eRegisterIndexXmm15
 };
 
 // Array of all register information supported by Windows x86
@@ -133,14 +155,14 @@
  nullptr,
  0},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr,
  nullptr,
  0},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr,
@@ -188,6 +210,22 @@
  nullptr,
  nullptr,
  0},
+{DEFINE_FPU_XMM(xmm0)},
+{DEFINE_FPU_XMM(xmm1)},
+{DEFINE_FPU_XMM(xmm2)},
+{DEFINE_FPU_XMM(xmm3)},
+{DEFINE_FPU_XMM(xmm4)},
+{DEFINE_FPU_XMM(xmm5)},
+{DEFINE_FPU_XMM(xmm6)},
+{DEFINE_FPU_XMM(xmm7)},
+{DEFINE_FPU_XMM(xmm8)},
+{DEFINE_FPU_XMM(xmm9)},
+{DEFINE_FPU_XMM(xmm10)},
+{DEFINE_FPU_XMM(xmm11)},
+{DEFINE_FPU_XMM(xmm12)},
+{DEFINE_FPU_XMM(xmm13)},
+{DEFINE_FPU_XMM(xmm14)},
+{DEFINE_FPU_XMM(xmm15)}
 };
 
 static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -202,10 +240,20 @@
 eRegisterIndexR12, eRegisterIndexR13, eRegisterIndexR14,
 eRegisterIndexR15, eRegisterIndexRip, eRegisterIndexRflags};
 
+uint32_t g_fpu_reg_indices[] = {
+eRegisterIndexXmm0,  eRegisterIndexXmm1,  eRegisterIndexXmm2,
+eRegisterIndexXmm3,  eRegisterIndexXmm4,  eRegisterIndexXmm5,
+eRegisterIndexXmm6,  eRegisterIndexXmm7,  eRegisterIndexXmm8,
+eRegisterIndexXmm9,  eRegisterIndexXmm10, eRegisterIndexXmm11,
+eRegisterIndexXmm12, eRegisterIndexXmm13, eRegisterIndexXmm14,
+eRegisterIndexXmm15
+};
+
 RegisterSet g_register_sets[] = {
 {"General Purpose Registers", "gpr",
  llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
-};
+{"Floating Point Registers", "fpu",
+ llvm::array_lengthof(g_fpu_reg_indices), g_fpu_reg_indices}};
 }
 
 // Constructors and Destructors
@@ -242,7 +290,9 @@
   if (reg_info == nullptr)
 return false;
 
-  switch (reg_info->kinds[eRegisterKindLLDB]) {
+  const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+
+  switch (reg) {
   case lldb_rax_x86_64:
 reg_value.SetUInt64(m_context.Rax);
 break;
@@ -297,6 +347,70 @@
   case lldb_rflags_x86_64:
 reg_value.SetUInt64(m_context.EFlags);
 break;
+  case lldb_xmm0_x86_64:
+reg_value.SetBytes(_context.Xmm0,
+   reg_info->byte_size, endian::InlHostByteOrder());
+break;
+  case lldb_xmm1_x86_64:
+reg_value.SetBytes(_context.Xmm1,
+   

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-06-14 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 204885.
kusmour added a comment.

complete the code for floating point registers and cleaned up
the support for floating point registers fixed `TestRegistersIterator` update 
the testcased


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  
lldb/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -24,6 +24,11 @@
 
 #define DEFINE_GPR(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase
 #define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
+#define DEFINE_FPU_XMM(reg)\
+  #reg, NULL, 16, 0, eEncodingUint, eFormatVectorOfUInt64, \
+  {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM,\
+   LLDB_INVALID_REGNUM, lldb_##reg##_x86_64},  \
+  nullptr, nullptr, nullptr, 0
 
 namespace {
 
@@ -51,7 +56,24 @@
   eRegisterIndexR14,
   eRegisterIndexR15,
   eRegisterIndexRip,
-  eRegisterIndexRflags
+  eRegisterIndexRflags,
+
+  eRegisterIndexXmm0,
+  eRegisterIndexXmm1,
+  eRegisterIndexXmm2,
+  eRegisterIndexXmm3,
+  eRegisterIndexXmm4,
+  eRegisterIndexXmm5,
+  eRegisterIndexXmm6,
+  eRegisterIndexXmm7,
+  eRegisterIndexXmm8,
+  eRegisterIndexXmm9,
+  eRegisterIndexXmm10,
+  eRegisterIndexXmm11,
+  eRegisterIndexXmm12,
+  eRegisterIndexXmm13,
+  eRegisterIndexXmm14,
+  eRegisterIndexXmm15
 };
 
 // Array of all register information supported by Windows x86
@@ -133,14 +155,14 @@
  nullptr,
  0},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr,
  nullptr,
  0},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr,
@@ -188,6 +210,22 @@
  nullptr,
  nullptr,
  0},
+{DEFINE_FPU_XMM(xmm0)},
+{DEFINE_FPU_XMM(xmm1)},
+{DEFINE_FPU_XMM(xmm2)},
+{DEFINE_FPU_XMM(xmm3)},
+{DEFINE_FPU_XMM(xmm4)},
+{DEFINE_FPU_XMM(xmm5)},
+{DEFINE_FPU_XMM(xmm6)},
+{DEFINE_FPU_XMM(xmm7)},
+{DEFINE_FPU_XMM(xmm8)},
+{DEFINE_FPU_XMM(xmm9)},
+{DEFINE_FPU_XMM(xmm10)},
+{DEFINE_FPU_XMM(xmm11)},
+{DEFINE_FPU_XMM(xmm12)},
+{DEFINE_FPU_XMM(xmm13)},
+{DEFINE_FPU_XMM(xmm14)},
+{DEFINE_FPU_XMM(xmm15)}
 };
 
 static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -202,10 +240,20 @@
 eRegisterIndexR12, eRegisterIndexR13, eRegisterIndexR14,
 eRegisterIndexR15, eRegisterIndexRip, eRegisterIndexRflags};
 
+uint32_t g_fpu_reg_indices[] = {
+eRegisterIndexXmm0,  eRegisterIndexXmm1,  eRegisterIndexXmm2,
+eRegisterIndexXmm3,  eRegisterIndexXmm4,  eRegisterIndexXmm5,
+eRegisterIndexXmm6,  eRegisterIndexXmm7,  eRegisterIndexXmm8,
+eRegisterIndexXmm9,  eRegisterIndexXmm10, eRegisterIndexXmm11,
+eRegisterIndexXmm12, eRegisterIndexXmm13, eRegisterIndexXmm14,
+eRegisterIndexXmm15
+};
+
 RegisterSet g_register_sets[] = {
 {"General Purpose Registers", "gpr",
  llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
-};
+{"Floating Point Registers", "fpu",
+ llvm::array_lengthof(g_fpu_reg_indices), g_fpu_reg_indices}};
 }
 
 // Constructors and Destructors
@@ -242,7 +290,9 @@
   if (reg_info == nullptr)
 return false;
 
-  switch (reg_info->kinds[eRegisterKindLLDB]) {
+  const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+
+  switch (reg) {
   case lldb_rax_x86_64:
 reg_value.SetUInt64(m_context.Rax);
 break;
@@ -297,6 +347,70 @@
   case lldb_rflags_x86_64:
 reg_value.SetUInt64(m_context.EFlags);
 break;
+  case lldb_xmm0_x86_64:
+reg_value.SetBytes(_context.Xmm0,
+   reg_info->byte_size, endian::InlHostByteOrder());
+break;
+  case lldb_xmm1_x86_64:
+reg_value.SetBytes(_context.Xmm1,
+

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-06-13 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 204695.
kusmour added a comment.

Added support for XMM registers.
Now the step out on a function returns floating point number should have the 
right value.
To play with it, define a function

  float getFloat(float value) {
  return value;
  }

set a break point and step out 
LLDB will print out the right value if debugging on Windows-x86_64


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
  lldb/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -24,6 +24,12 @@
 
 #define DEFINE_GPR(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase
 #define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
+#define DEFINE_FPU_XMM(reg)\
+  #reg, NULL, 16,   \
+  0, eEncodingUint, eFormatVectorOfUInt64, \
+  {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM,\
+   LLDB_INVALID_REGNUM, lldb_##reg##_x86_64},\
+  nullptr, nullptr, nullptr, 0
 
 namespace {
 
@@ -51,7 +57,24 @@
   eRegisterIndexR14,
   eRegisterIndexR15,
   eRegisterIndexRip,
-  eRegisterIndexRflags
+  eRegisterIndexRflags,
+
+  eRegisterIndexXmm0,
+  eRegisterIndexXmm1,
+  eRegisterIndexXmm2,
+  eRegisterIndexXmm3,
+  eRegisterIndexXmm4,
+  eRegisterIndexXmm5,
+  eRegisterIndexXmm6,
+  eRegisterIndexXmm7,
+  eRegisterIndexXmm8,
+  eRegisterIndexXmm9,
+  eRegisterIndexXmm10,
+  eRegisterIndexXmm11,
+  eRegisterIndexXmm12,
+  eRegisterIndexXmm13,
+  eRegisterIndexXmm14,
+  eRegisterIndexXmm15
 };
 
 // Array of all register information supported by Windows x86
@@ -133,14 +156,14 @@
  nullptr,
  0},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr,
  nullptr,
  0},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr,
@@ -188,6 +211,22 @@
  nullptr,
  nullptr,
  0},
+{DEFINE_FPU_XMM(xmm0)},
+{DEFINE_FPU_XMM(xmm1)},
+{DEFINE_FPU_XMM(xmm2)},
+{DEFINE_FPU_XMM(xmm3)},
+{DEFINE_FPU_XMM(xmm4)},
+{DEFINE_FPU_XMM(xmm5)},
+{DEFINE_FPU_XMM(xmm6)},
+{DEFINE_FPU_XMM(xmm7)},
+{DEFINE_FPU_XMM(xmm8)},
+{DEFINE_FPU_XMM(xmm9)},
+{DEFINE_FPU_XMM(xmm10)},
+{DEFINE_FPU_XMM(xmm11)},
+{DEFINE_FPU_XMM(xmm12)},
+{DEFINE_FPU_XMM(xmm13)},
+{DEFINE_FPU_XMM(xmm14)},
+{DEFINE_FPU_XMM(xmm15)}
 };
 
 static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
@@ -202,10 +241,20 @@
 eRegisterIndexR12, eRegisterIndexR13, eRegisterIndexR14,
 eRegisterIndexR15, eRegisterIndexRip, eRegisterIndexRflags};
 
+uint32_t g_fpu_reg_indices[] = {
+eRegisterIndexXmm0,  eRegisterIndexXmm1,  eRegisterIndexXmm2,
+eRegisterIndexXmm3,  eRegisterIndexXmm4,  eRegisterIndexXmm5,
+eRegisterIndexXmm6,  eRegisterIndexXmm7,  eRegisterIndexXmm8,
+eRegisterIndexXmm9,  eRegisterIndexXmm10, eRegisterIndexXmm11,
+eRegisterIndexXmm12, eRegisterIndexXmm13, eRegisterIndexXmm14,
+eRegisterIndexXmm15
+};
+
 RegisterSet g_register_sets[] = {
 {"General Purpose Registers", "gpr",
  llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
-};
+{"Floating Point Registers", "fpu",
+ llvm::array_lengthof(g_fpu_reg_indices), g_fpu_reg_indices}};
 }
 
 // Constructors and Destructors
@@ -242,7 +291,9 @@
   if (reg_info == nullptr)
 return false;
 
-  switch (reg_info->kinds[eRegisterKindLLDB]) {
+  const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+
+  switch (reg) {
   case lldb_rax_x86_64:
 reg_value.SetUInt64(m_context.Rax);
 break;
@@ -297,6 +348,70 @@
   case lldb_rflags_x86_64:
 reg_value.SetUInt64(m_context.EFlags);
 break;
+  case lldb_xmm0_x86_64:
+

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-06-04 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 203061.
kusmour added a comment.

Update the `GetReturnValueObjectImpl` using function `CanPassInRegisters` to 
explicitly check

NOTE: There's NO register context info about registers beyond general purpose 
registers
So floating point return type is not supported since it uses XMM0 to return
need to update register context for windows x64


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -133,14 +133,14 @@
  nullptr,
  0},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr,
  nullptr,
  0},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr,
Index: lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_library(lldbPluginABIWindows_x86_64 PLUGIN
+  ABIWindows_x86_64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
@@ -0,0 +1,99 @@
+//===-- ABIWindows_x86_64.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABIWindows_x86_64_h_
+#define liblldb_ABIWindows_x86_64_h_
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIWindows_x86_64 : public lldb_private::ABI {
+public:
+  ~ABIWindows_x86_64() override = default;
+
+  size_t GetRedZoneSize() const override;
+
+  bool PrepareTrivialCall(lldb_private::Thread , lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread ,
+ lldb_private::ValueList ) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP _sp,
+   lldb::ValueObjectSP _value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread ,
+   lldb_private::CompilerType ) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  // In Windows_x86_64 ABI, stack will always be maintained 16-byte aligned
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+	  if (cfa & (16ull - 1ull))
+  return false; // Not 16 byte aligned
+if (cfa == 0)
+  return false; // Zero is not a valid stack address
+return true;
+  }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// We have a 64 bit address space, so anything is valid as opcodes
+// aren't fixed width...
+return true;
+  }
+
+  const lldb_private::RegisterInfo *
+  GetRegisterInfoArray(uint32_t ) override;
+
+  bool GetPointerReturnRegister(const char *) override;
+
+  //--
+  // Static Functions
+  //--
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec );
+
+  static lldb_private::ConstString 

[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-06-03 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 202824.
kusmour added a comment.

1. Limit the `TestReturnValue` for nested struct and class (cpp support) to 
only x86_64
2. This patch somehow fix the bug: pr36870 
 for Systerm V ABI (windows is 
waiting for this change to go in). So I change the test to allow passing on 
SysV-x86_64


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62702

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/Makefile
  
lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/call-func.c
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/call-func.cpp
  lldb/packages/Python/lldbsuite/test/lang/cpp/trivial_abi/TestTrivialABI.py
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -3911,6 +3911,14 @@
   return GetCanonicalQualType(type)->isVoidType();
 }
 
+bool ClangASTContext::CanPassInRegisters(const CompilerType ) {
+  if (auto *record_decl = 
+  ClangASTContext::GetAsRecordDecl(type)) {
+return record_decl->canPassInRegisters();
+  }
+  return false;
+}
+
 bool ClangASTContext::SupportsLanguage(lldb::LanguageType language) {
   return ClangASTContextSupportsLanguage(language);
 }
Index: lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
===
--- lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -30,6 +30,8 @@
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Status.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -1558,6 +1560,55 @@
   return return_valobj_sp;
 }
 
+// The compiler will flatten the nested aggregate type into single
+// layer and push the value to stack
+// This helper function will flatten an aggregate type
+// and return true if it can be returned in register(s) by value
+// return false if the aggregate is in memory
+static bool FlattenAggregateType(
+Thread , ExecutionContext _ctx,
+CompilerType _compiler_type,
+uint32_t data_byte_offset,
+std::vector _field_offsets,
+std::vector _compiler_types) {
+
+  const uint32_t num_children = return_compiler_type.GetNumFields();
+  for (uint32_t idx = 0; idx < num_children; ++idx) {
+std::string name;
+bool is_signed;
+uint32_t count;
+bool is_complex;
+
+uint64_t field_bit_offset = 0;
+CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
+idx, name, _bit_offset, nullptr, nullptr);
+llvm::Optional field_bit_width =
+  field_compiler_type.GetBitSize();
+
+// if we don't know the size of the field (e.g. invalid type), exit
+if (!field_bit_width || *field_bit_width == 0) {
+  return false;
+}
+
+uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset;
+
+const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
+if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+field_compiler_type.IsPointerType() ||
+field_compiler_type.IsFloatingPointType(count, is_complex)) {
+  aggregate_field_offsets.push_back(field_byte_offset);
+  aggregate_compiler_types.push_back(field_compiler_type);
+} else if (field_type_flags & eTypeHasChildren) {
+  if (!FlattenAggregateType(thread, exe_ctx, field_compiler_type,
+field_byte_offset, aggregate_field_offsets,
+aggregate_compiler_types)) {
+return false;
+  }
+}
+  }
+  return true;
+}
+
 ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
 Thread , CompilerType _compiler_type) const {
   ValueObjectSP return_valobj_sp;
@@ -1580,10 +1631,17 @@
   if (return_compiler_type.IsAggregateType()) {
 Target *target = exe_ctx.GetTargetPtr();
 bool is_memory = true;
-if (*bit_width <= 128) {
-  ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
+std::vector aggregate_field_offsets;
+std::vector aggregate_compiler_types;
+if (return_compiler_type.GetTypeSystem()->CanPassInRegisters(
+  return_compiler_type) &&
+  *bit_width <= 128 &&
+  FlattenAggregateType(thread, exe_ctx, return_compiler_type,
+  0, aggregate_field_offsets,
+  aggregate_compiler_types)) {
+  ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
   DataBufferSP data_sp(new 

[Lldb-commits] [PATCH] D62771: [LLDBRegisterNum] Update function call llvm::codeview::getRegisterNames(CPUType) in lldb

2019-06-03 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour abandoned this revision.
kusmour marked an inline comment as done.
kusmour added a comment.

D62772  toke care of this


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62771



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


[Lldb-commits] [PATCH] D62771: [LLDBRegisterNum] Update function call llvm::codeview::getRegisterNames(CPUType) in lldb

2019-06-01 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour marked 2 inline comments as done.
kusmour added inline comments.



Comment at: 
lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp:32
+case llvm::Triple::ArchType::aarch64_32:
+  cpu = llvm::codeview::CPUType::ARM64;
+default:

xiaobai wrote:
> break here
omg thx


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62771



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


[Lldb-commits] [PATCH] D62771: [LLDBRegisterNum] Update function call llvm::codeview::getRegisterNames(CPUType) in lldb

2019-06-01 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 202585.
kusmour added a comment.

fix switch statement


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62771

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp


Index: 
lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
@@ -24,9 +24,19 @@
 using namespace lldb_private::postfix;
 
 static uint32_t ResolveLLDBRegisterNum(llvm::StringRef reg_name, 
llvm::Triple::ArchType arch_type) {
+  llvm::codeview::CPUType cpu;
+  switch(arch_type) {
+case llvm::Triple::ArchType::aarch64:
+case llvm::Triple::ArchType::aarch64_be:
+case llvm::Triple::ArchType::aarch64_32:
+  cpu = llvm::codeview::CPUType::ARM64;
+  break;
+default:
+  cpu = llvm::codeview::CPUType::X64;
+  }
   // lookup register name to get lldb register number
   llvm::ArrayRef> register_names =
-  llvm::codeview::getRegisterNames();
+  llvm::codeview::getRegisterNames(cpu);
   auto it = llvm::find_if(
   register_names,
   [_name](const llvm::EnumEntry _entry) {


Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
@@ -24,9 +24,19 @@
 using namespace lldb_private::postfix;
 
 static uint32_t ResolveLLDBRegisterNum(llvm::StringRef reg_name, llvm::Triple::ArchType arch_type) {
+  llvm::codeview::CPUType cpu;
+  switch(arch_type) {
+case llvm::Triple::ArchType::aarch64:
+case llvm::Triple::ArchType::aarch64_be:
+case llvm::Triple::ArchType::aarch64_32:
+  cpu = llvm::codeview::CPUType::ARM64;
+  break;
+default:
+  cpu = llvm::codeview::CPUType::X64;
+  }
   // lookup register name to get lldb register number
   llvm::ArrayRef> register_names =
-  llvm::codeview::getRegisterNames();
+  llvm::codeview::getRegisterNames(cpu);
   auto it = llvm::find_if(
   register_names,
   [_name](const llvm::EnumEntry _entry) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-06-01 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour marked 2 inline comments as done.
kusmour added inline comments.



Comment at: lldb/source/Symbol/ClangASTContext.cpp:3915
+bool ClangASTContext::CanPassInRegisters(const CompilerType ) {
+  if (clang::RecordDecl *record_decl = 
+  ClangASTContext::GetAsRecordDecl(type)) {

compnerd wrote:
> I think that using `auto` instead of `clang::RecordDecl` here is fine as you 
> are already spelling that out in the `ClangASTContext::GetAsRecordDecl`.
got it


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62702



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


[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-06-01 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 202574.
kusmour marked an inline comment as done.
kusmour added a comment.

small update :)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62702

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/TypeSystem.h
  
lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/call-func.c
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/call-func.cpp
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -3911,6 +3911,14 @@
   return GetCanonicalQualType(type)->isVoidType();
 }
 
+bool ClangASTContext::CanPassInRegisters(const CompilerType ) {
+  if (auto *record_decl = 
+  ClangASTContext::GetAsRecordDecl(type)) {
+return record_decl->canPassInRegisters();
+  }
+  return false;
+}
+
 bool ClangASTContext::SupportsLanguage(lldb::LanguageType language) {
   return ClangASTContextSupportsLanguage(language);
 }
Index: lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
===
--- lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -30,6 +30,8 @@
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Status.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -1558,6 +1560,55 @@
   return return_valobj_sp;
 }
 
+// The compiler will flatten the nested aggregate type into single
+// layer and push the value to stack
+// This helper function will flatten an aggregate type
+// and return true if it can be returned in register(s) by value
+// return false if the aggregate is in memory
+static bool FlattenAggregateType(
+Thread , ExecutionContext _ctx,
+CompilerType _compiler_type,
+uint32_t data_byte_offset,
+std::vector _field_offsets,
+std::vector _compiler_types) {
+
+  const uint32_t num_children = return_compiler_type.GetNumFields();
+  for (uint32_t idx = 0; idx < num_children; ++idx) {
+std::string name;
+bool is_signed;
+uint32_t count;
+bool is_complex;
+
+uint64_t field_bit_offset = 0;
+CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
+idx, name, _bit_offset, nullptr, nullptr);
+llvm::Optional field_bit_width =
+  field_compiler_type.GetBitSize();
+
+// if we don't know the size of the field (e.g. invalid type), exit
+if (!field_bit_width || *field_bit_width == 0) {
+  return false;
+}
+
+uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset;
+
+const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
+if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+field_compiler_type.IsPointerType() ||
+field_compiler_type.IsFloatingPointType(count, is_complex)) {
+  aggregate_field_offsets.push_back(field_byte_offset);
+  aggregate_compiler_types.push_back(field_compiler_type);
+} else if (field_type_flags & eTypeHasChildren) {
+  if (!FlattenAggregateType(thread, exe_ctx, field_compiler_type,
+field_byte_offset, aggregate_field_offsets,
+aggregate_compiler_types)) {
+return false;
+  }
+}
+  }
+  return true;
+}
+
 ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
 Thread , CompilerType _compiler_type) const {
   ValueObjectSP return_valobj_sp;
@@ -1580,10 +1631,17 @@
   if (return_compiler_type.IsAggregateType()) {
 Target *target = exe_ctx.GetTargetPtr();
 bool is_memory = true;
-if (*bit_width <= 128) {
-  ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
+std::vector aggregate_field_offsets;
+std::vector aggregate_compiler_types;
+if (return_compiler_type.GetTypeSystem()->CanPassInRegisters(
+  return_compiler_type) &&
+  *bit_width <= 128 &&
+  FlattenAggregateType(thread, exe_ctx, return_compiler_type,
+  0, aggregate_field_offsets,
+  aggregate_compiler_types)) {
+  ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
   DataBufferSP data_sp(new DataBufferHeap(16, 0));
-  DataExtractor return_ext(data_sp, target_byte_order,
+  DataExtractor return_ext(data_sp, byte_order,
target->GetArchitecture().GetAddressByteSize());
 
   const RegisterInfo *rax_info =
@@ -1613,40 +1671,33 @@
   uint32_t integer_bytes =
   0; // Tracks how much of the rax/rds registers we've consumed so far
 
-  

[Lldb-commits] [PATCH] D62771: [LLDBregisterNum] Update function call llvm::codeview::getRegisterNames(CPUType) in lldb

2019-06-01 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added reviewers: xiaobai, compnerd.
Herald added subscribers: lldb-commits, kristof.beyls, javed.absar.
Herald added a project: LLDB.

llvm updated the function from `llvm::codeview::getRegisterNames()` to 
`llvm::codeview::getRegisterNames(CPUType)`
according to the function implementation, there are only two different register 
number list: ARM64 for ARM64, X64 for all others
the backends for arm64 and aarch64 are merged so from lldb side, aarch64 will 
have `llvm::codeview::CPUType::ARM64`
and others will set CPUType to `llvm::codeview::CPUType::X64` for now


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D62771

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp


Index: 
lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
@@ -24,9 +24,18 @@
 using namespace lldb_private::postfix;
 
 static uint32_t ResolveLLDBRegisterNum(llvm::StringRef reg_name, 
llvm::Triple::ArchType arch_type) {
+  llvm::codeview::CPUType cpu;
+  switch(arch_type) {
+case llvm::Triple::ArchType::aarch64:
+case llvm::Triple::ArchType::aarch64_be:
+case llvm::Triple::ArchType::aarch64_32:
+  cpu = llvm::codeview::CPUType::ARM64;
+default:
+  cpu = llvm::codeview::CPUType::X64;
+  }
   // lookup register name to get lldb register number
   llvm::ArrayRef> register_names =
-  llvm::codeview::getRegisterNames();
+  llvm::codeview::getRegisterNames(cpu);
   auto it = llvm::find_if(
   register_names,
   [_name](const llvm::EnumEntry _entry) {


Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
@@ -24,9 +24,18 @@
 using namespace lldb_private::postfix;
 
 static uint32_t ResolveLLDBRegisterNum(llvm::StringRef reg_name, llvm::Triple::ArchType arch_type) {
+  llvm::codeview::CPUType cpu;
+  switch(arch_type) {
+case llvm::Triple::ArchType::aarch64:
+case llvm::Triple::ArchType::aarch64_be:
+case llvm::Triple::ArchType::aarch64_32:
+  cpu = llvm::codeview::CPUType::ARM64;
+default:
+  cpu = llvm::codeview::CPUType::X64;
+  }
   // lookup register name to get lldb register number
   llvm::ArrayRef> register_names =
-  llvm::codeview::getRegisterNames();
+  llvm::codeview::getRegisterNames(cpu);
   auto it = llvm::find_if(
   register_names,
   [_name](const llvm::EnumEntry _entry) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-05-31 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 202517.
kusmour added a comment.
Herald added a subscriber: teemperor.

added a virtual function `CanPassInRegister` in TypeSystem class
to provide info about type can be passed in register or not
`ClangASTContext` will refer to `clang::RecordDecl::canPassInRegister` for this 
info
and later `SwiftASTContext` can provide the equivalent 
updated the test to test on C++
and provided class test, including base class, subclass, abstract class (this 
one must be in memory)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62702

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/TypeSystem.h
  
lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/call-func.c
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/call-func.cpp
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Symbol/ClangASTContext.cpp

Index: lldb/source/Symbol/ClangASTContext.cpp
===
--- lldb/source/Symbol/ClangASTContext.cpp
+++ lldb/source/Symbol/ClangASTContext.cpp
@@ -3911,6 +3911,14 @@
   return GetCanonicalQualType(type)->isVoidType();
 }
 
+bool ClangASTContext::CanPassInRegisters(const CompilerType ) {
+  if (clang::RecordDecl *record_decl = 
+  ClangASTContext::GetAsRecordDecl(type)) {
+return record_decl->canPassInRegisters();
+  }
+  return false;
+}
+
 bool ClangASTContext::SupportsLanguage(lldb::LanguageType language) {
   return ClangASTContextSupportsLanguage(language);
 }
Index: lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
===
--- lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -30,6 +30,8 @@
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Status.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -1558,6 +1560,55 @@
   return return_valobj_sp;
 }
 
+// The compiler will flatten the nested aggregate type into single
+// layer and push the value to stack
+// This helper function will flatten an aggregate type
+// and return true if it can be returned in register(s) by value
+// return false if the aggregate is in memory
+static bool FlattenAggregateType(
+Thread , ExecutionContext _ctx,
+CompilerType _compiler_type,
+uint32_t data_byte_offset,
+std::vector _field_offsets,
+std::vector _compiler_types) {
+
+  const uint32_t num_children = return_compiler_type.GetNumFields();
+  for (uint32_t idx = 0; idx < num_children; ++idx) {
+std::string name;
+bool is_signed;
+uint32_t count;
+bool is_complex;
+
+uint64_t field_bit_offset = 0;
+CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
+idx, name, _bit_offset, nullptr, nullptr);
+llvm::Optional field_bit_width =
+  field_compiler_type.GetBitSize();
+
+// if we don't know the size of the field (e.g. invalid type), exit
+if (!field_bit_width || *field_bit_width == 0) {
+  return false;
+}
+
+uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset;
+
+const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
+if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+field_compiler_type.IsPointerType() ||
+field_compiler_type.IsFloatingPointType(count, is_complex)) {
+  aggregate_field_offsets.push_back(field_byte_offset);
+  aggregate_compiler_types.push_back(field_compiler_type);
+} else if (field_type_flags & eTypeHasChildren) {
+  if (!FlattenAggregateType(thread, exe_ctx, field_compiler_type,
+field_byte_offset, aggregate_field_offsets,
+aggregate_compiler_types)) {
+return false;
+  }
+}
+  }
+  return true;
+}
+
 ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
 Thread , CompilerType _compiler_type) const {
   ValueObjectSP return_valobj_sp;
@@ -1580,10 +1631,17 @@
   if (return_compiler_type.IsAggregateType()) {
 Target *target = exe_ctx.GetTargetPtr();
 bool is_memory = true;
-if (*bit_width <= 128) {
-  ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
+std::vector aggregate_field_offsets;
+std::vector aggregate_compiler_types;
+if (return_compiler_type.GetTypeSystem()->CanPassInRegisters(
+  return_compiler_type) &&
+  *bit_width <= 128 &&
+  FlattenAggregateType(thread, exe_ctx, return_compiler_type,
+  0, aggregate_field_offsets,
+  aggregate_compiler_types)) {
+  ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
   DataBufferSP data_sp(new 

[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-05-31 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

In D62702#1525655 , @compnerd wrote:

> Actually, I think that we should extend `CompilerType` and `TypeSystem` to 
> expose Clang's knowledge of whether a type is passed in a register by means 
> of using `clang::RecordDecl::isPassInRegisters`


Can't agree more. Thanks!!


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62702



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


[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-05-30 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 202340.
kusmour added a comment.

simplify the method in 'FlattenAggregateType'
added test for nested struct returned in registers


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62702

Files:
  
lldb/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py
  lldb/packages/Python/lldbsuite/test/functionalities/return-value/call-func.c
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Index: lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
===
--- lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -30,6 +30,8 @@
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Status.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -1558,6 +1560,47 @@
   return return_valobj_sp;
 }
 
+// The compiler will flatten the nested aggregate type into single
+// layer and push the value to stack
+// This helper function will flatten an aggregate type
+// and return true if it can be returned in register(s) by value
+// return false if the aggregate is in memory
+static bool FlattenAggregateType(
+ExecutionContext _ctx,
+CompilerType _compiler_type,
+uint32_t data_byte_offset,
+std::vector _field_offsets,
+std::vector _compiler_types) {
+  const uint32_t num_children = return_compiler_type.GetNumFields();
+  for (uint32_t idx = 0; idx < num_children; ++idx) {
+std::string name;
+bool is_signed;
+uint32_t count;
+bool is_complex;
+
+uint64_t field_bit_offset = 0;
+CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
+idx, name, _bit_offset, nullptr, nullptr);
+
+uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset;
+
+const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
+if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+field_compiler_type.IsPointerType() ||
+field_compiler_type.IsFloatingPointType(count, is_complex)) {
+  aggregate_field_offsets.push_back(field_byte_offset);
+  aggregate_compiler_types.push_back(field_compiler_type);
+} else if (field_type_flags & eTypeHasChildren) {
+  if (!FlattenAggregateType(exe_ctx, field_compiler_type,
+field_byte_offset, aggregate_field_offsets,
+aggregate_compiler_types)) {
+return false;
+  }
+}
+  }
+  return true;
+}
+
 ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
 Thread , CompilerType _compiler_type) const {
   ValueObjectSP return_valobj_sp;
@@ -1580,10 +1623,14 @@
   if (return_compiler_type.IsAggregateType()) {
 Target *target = exe_ctx.GetTargetPtr();
 bool is_memory = true;
-if (*bit_width <= 128) {
-  ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
+std::vector aggregate_field_offsets;
+std::vector aggregate_compiler_types;
+if (*bit_width <= 128 && FlattenAggregateType(exe_ctx, return_compiler_type,
+  0, aggregate_field_offsets,
+  aggregate_compiler_types)) {
+  ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
   DataBufferSP data_sp(new DataBufferHeap(16, 0));
-  DataExtractor return_ext(data_sp, target_byte_order,
+  DataExtractor return_ext(data_sp, byte_order,
target->GetArchitecture().GetAddressByteSize());
 
   const RegisterInfo *rax_info =
@@ -1613,40 +1660,26 @@
   uint32_t integer_bytes =
   0; // Tracks how much of the rax/rds registers we've consumed so far
 
-  const uint32_t num_children = return_compiler_type.GetNumFields();
+  const uint32_t num_children = aggregate_compiler_types.size();
 
   // Since we are in the small struct regime, assume we are not in memory.
   is_memory = false;
-
   for (uint32_t idx = 0; idx < num_children; idx++) {
-std::string name;
-uint64_t field_bit_offset = 0;
 bool is_signed;
-bool is_complex;
 uint32_t count;
+bool is_complex;
 
-CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
-idx, name, _bit_offset, nullptr, nullptr);
-llvm::Optional field_bit_width =
-field_compiler_type.GetBitSize();
-
-// if we don't know the size of the field (e.g. invalid type), just
-// bail out
-if (!field_bit_width || *field_bit_width == 0)
-  break;
+CompilerType field_compiler_type = aggregate_compiler_types[idx];
+uint32_t field_byte_width = (uint32_t) (*field_compiler_type.GetByteSize());
+uint32_t field_byte_offset = aggregate_field_offsets[idx];
 
-// 

[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-05-30 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour added a comment.

@jingham working on the unit test rn. will upload soon


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62702



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


[Lldb-commits] [PATCH] D62702: [ABI] Fix SystemV ABI to handle nested aggregate type returned in register

2019-05-30 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added reviewers: xiaobai, compnerd.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add a function to flatten the nested aggregate type


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D62702

Files:
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Index: lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
===
--- lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -30,6 +30,8 @@
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/Status.h"
 
+#include 
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -1558,6 +1560,62 @@
   return return_valobj_sp;
 }
 
+// The compiler will faltten the nested aggregate type into single
+// layer and push the value to stack
+// This helper function will flatten an aggregate type
+// and return true if it can be returned in register(s) by value
+// return false if the aggregate is in memory
+static bool FlattenAggregateType(
+ExecutionContext _ctx,
+CompilerType _compiler_type,
+uint32_t data_byte_offset,
+std::vector _field_offsets,
+std::vector _compiler_types) {
+  const uint32_t num_children = return_compiler_type.GetNumFields();
+  for (uint32_t idx = 0; idx < num_children; ++idx) {
+std::string name;
+bool is_signed;
+uint32_t count;
+bool is_complex;
+
+const bool transparent_pointers = false;
+const bool omit_empty_base_classes = true;
+const bool ignore_array_bounds = false;
+uint32_t child_byte_size = 0;
+int32_t child_byte_offset = 0;
+uint32_t child_bitfield_bit_size = 0;
+uint32_t child_bitfield_bit_offset = 0;
+bool child_is_base_class = false;
+bool child_is_deref_of_parent = false;
+uint64_t language_flags;
+CompilerType field_compiler_type =
+return_compiler_type.GetChildCompilerTypeAtIndex(
+_ctx, idx, transparent_pointers, omit_empty_base_classes,
+ignore_array_bounds, name, child_byte_size, child_byte_offset,
+child_bitfield_bit_size, child_bitfield_bit_offset,
+child_is_base_class, child_is_deref_of_parent, nullptr,
+language_flags);
+
+const uint64_t field_bit_offset = child_byte_offset * 8;
+uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset;
+
+const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
+if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+field_compiler_type.IsPointerType() ||
+field_compiler_type.IsFloatingPointType(count, is_complex)) {
+  aggregate_field_offsets.push_back(field_byte_offset);
+  aggregate_compiler_types.push_back(field_compiler_type);
+} else if (field_type_flags & eTypeHasChildren) {
+  if (!FlattenAggregateType(exe_ctx, field_compiler_type,
+field_byte_offset, aggregate_field_offsets,
+aggregate_compiler_types)) {
+return false;
+  }
+}
+  }
+  return true;
+}
+
 ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
 Thread , CompilerType _compiler_type) const {
   ValueObjectSP return_valobj_sp;
@@ -1580,10 +1638,14 @@
   if (return_compiler_type.IsAggregateType()) {
 Target *target = exe_ctx.GetTargetPtr();
 bool is_memory = true;
-if (*bit_width <= 128) {
-  ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
+std::vector aggregate_field_offsets;
+std::vector aggregate_compiler_types;
+if (*bit_width <= 128 && FlattenAggregateType(exe_ctx, return_compiler_type,
+  0, aggregate_field_offsets,
+  aggregate_compiler_types)) {
+  ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
   DataBufferSP data_sp(new DataBufferHeap(16, 0));
-  DataExtractor return_ext(data_sp, target_byte_order,
+  DataExtractor return_ext(data_sp, byte_order,
target->GetArchitecture().GetAddressByteSize());
 
   const RegisterInfo *rax_info =
@@ -1613,40 +1675,27 @@
   uint32_t integer_bytes =
   0; // Tracks how much of the rax/rds registers we've consumed so far
 
-  const uint32_t num_children = return_compiler_type.GetNumFields();
+  // const uint32_t num_children = return_compiler_type.GetNumFields();
+  const uint32_t num_children = aggregate_compiler_types.size();
 
   // Since we are in the small struct regime, assume we are not in memory.
   is_memory = false;
-
   for (uint32_t idx = 0; idx < num_children; idx++) {
-std::string name;
-uint64_t field_bit_offset = 0;
 bool is_signed;
-bool is_complex;
 uint32_t count;
+bool is_complex;
 
-CompilerType field_compiler_type = 

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-05-24 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 201377.
kusmour added a comment.

update the `CreateDefaultUnwindPlan`.
return false or give empty Unwind Plan may cause lldb to crash and break tests 
on windows.
So for now, copy the SysV-x86_64


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -133,14 +133,14 @@
  nullptr,
  0},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr,
  nullptr,
  0},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr,
Index: lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_library(lldbPluginABIWindows_x86_64 PLUGIN
+  ABIWindows_x86_64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
@@ -0,0 +1,99 @@
+//===-- ABIWindows_x86_64.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABIWindows_x86_64_h_
+#define liblldb_ABIWindows_x86_64_h_
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIWindows_x86_64 : public lldb_private::ABI {
+public:
+  ~ABIWindows_x86_64() override = default;
+
+  size_t GetRedZoneSize() const override;
+
+  bool PrepareTrivialCall(lldb_private::Thread , lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread ,
+ lldb_private::ValueList ) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP _sp,
+   lldb::ValueObjectSP _value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread ,
+   lldb_private::CompilerType ) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  // In Windows_x86_64 ABI, stack will always be maintained 16-byte aligned
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+	  if (cfa & (16ull - 1ull))
+  return false; // Not 16 byte aligned
+if (cfa == 0)
+  return false; // Zero is not a valid stack address
+return true;
+  }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// We have a 64 bit address space, so anything is valid as opcodes
+// aren't fixed width...
+return true;
+  }
+
+  const lldb_private::RegisterInfo *
+  GetRegisterInfoArray(uint32_t ) override;
+
+  bool GetPointerReturnRegister(const char *) override;
+
+  //--
+  // Static Functions
+  //--
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec );
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  //--
+  // PluginInterface protocol
+  

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-05-22 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 200844.
kusmour added a comment.

update nit


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -133,14 +133,14 @@
  nullptr,
  0},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr,
  nullptr,
  0},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr,
Index: lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_library(lldbPluginABIWindows_x86_64 PLUGIN
+  ABIWindows_x86_64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
@@ -0,0 +1,99 @@
+//===-- ABIWindows_x86_64.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABIWindows_x86_64_h_
+#define liblldb_ABIWindows_x86_64_h_
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIWindows_x86_64 : public lldb_private::ABI {
+public:
+  ~ABIWindows_x86_64() override = default;
+
+  size_t GetRedZoneSize() const override;
+
+  bool PrepareTrivialCall(lldb_private::Thread , lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread ,
+ lldb_private::ValueList ) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP _sp,
+   lldb::ValueObjectSP _value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread ,
+   lldb_private::CompilerType ) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  // In Windows_x86_64 ABI, stack will always be maintained 16-byte aligned
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+	  if (cfa & (16ull - 1ull))
+  return false; // Not 16 byte aligned
+if (cfa == 0)
+  return false; // Zero is not a valid stack address
+return true;
+  }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// We have a 64 bit address space, so anything is valid as opcodes
+// aren't fixed width...
+return true;
+  }
+
+  const lldb_private::RegisterInfo *
+  GetRegisterInfoArray(uint32_t ) override;
+
+  bool GetPointerReturnRegister(const char *) override;
+
+  //--
+  // Static Functions
+  //--
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec );
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  //--
+  // PluginInterface protocol
+  //--
+
+  lldb_private::ConstString GetPluginName() override;
+
+  uint32_t GetPluginVersion() override;
+

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-05-22 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour marked an inline comment as done.
kusmour added inline comments.



Comment at: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp:1096
+  if (arch_type == llvm::Triple::x86_64
+&& os_type == llvm::Triple::OSType::Win32) {
+return ABISP(new ABIWindows_x86_64(process_sp));

compnerd wrote:
> Nit: I think that `arch.GetTriple().isOSWindows()` is nicer than the explicit 
> check of `Win32`.
got it



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213



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


[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-05-21 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour marked 16 inline comments as done.
kusmour added inline comments.



Comment at: 
lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp:1257-1259
+
+// We currently only support extracting values with Clang QualTypes. Do we
+// care about others?

xiaobai wrote:
> I don't see any references to clang in the below code. Is this still accurate?
not relevant, deleted



Comment at: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp:1359
+  } else {
+// FIXME - don't know how to do 80 bit long doubles yet.
+error.SetErrorString(

compnerd wrote:
> FP80 is not supported on Windows, this should be a hard error.
I changed it to provide a correct error message. Is it better to put an 
assertion or return here?



Comment at: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp:1466
+  } else if (*byte_size == sizeof(long double)) {
+// Don't handle long double since that can be encoded as 80 bit
+// floats...

compnerd wrote:
> `long double` is the same as `double` on Windows.
got it thanks



Comment at: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp:1811
+
+// Windows doesn't use rbp
+// Let this return false

xiaobai wrote:
> nit: Windows-x86_64 doesn't use rbp
thanks



Comment at: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h:59
+
+ if (cfa & (8ull - 1ull))
+  return false; // Not 8 byte aligned

compnerd wrote:
> This should be made strict as per the Windows ABI.
windows is 16-byte aligned, updated.



Comment at: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h:63
+  return false; // Zero is not a valid stack address
+return true;
+  }

compnerd wrote:
> Can we add an additional test please?  In particular, leaf frames are 
> permitted to have unaligned stacks.
can you provide more information about this? On windows a leaf function doesn't 
require a stack frame. But a frame function that doesn't call other function is 
not required to align the stack


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213



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


[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-05-21 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour updated this revision to Diff 200622.
kusmour added a comment.
Herald added a subscriber: fedor.sergeev.

update a new version based on comment.
cleaned some useless comment
change to use CHAR_BIT for readability


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62213

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -113,12 +113,12 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr},
Index: lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_library(lldbPluginABIWindows_x86_64 PLUGIN
+  ABIWindows_x86_64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
@@ -0,0 +1,99 @@
+//===-- ABIWindows_x86_64.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABIWindows_x86_64_h_
+#define liblldb_ABIWindows_x86_64_h_
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIWindows_x86_64 : public lldb_private::ABI {
+public:
+  ~ABIWindows_x86_64() override = default;
+
+  size_t GetRedZoneSize() const override;
+
+  bool PrepareTrivialCall(lldb_private::Thread , lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread ,
+ lldb_private::ValueList ) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP _sp,
+   lldb::ValueObjectSP _value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread ,
+   lldb_private::CompilerType ) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  // In Windows_x86_64 ABI, stack will always be maintained 16-byte aligned
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+	  if (cfa & (16ull - 1ull))
+  return false; // Not 8 byte aligned
+if (cfa == 0)
+  return false; // Zero is not a valid stack address
+return true;
+  }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// We have a 64 bit address space, so anything is valid as opcodes
+// aren't fixed width...
+return true;
+  }
+
+  const lldb_private::RegisterInfo *
+  GetRegisterInfoArray(uint32_t ) override;
+
+  bool GetPointerReturnRegister(const char *) override;
+
+  //--
+  // Static Functions
+  //--
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec );
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  //--
+  // PluginInterface protocol
+  

[Lldb-commits] [PATCH] D62213: [ABI] Implement Windows ABI for x86_64

2019-05-21 Thread Wanyi Ye via Phabricator via lldb-commits
kusmour created this revision.
kusmour added reviewers: xiaobai, compnerd.
kusmour added a project: LLDB.
Herald added subscribers: lldb-commits, teemperor, mgorny.

Implement the ABI for WIndows-x86_64 including register info and calling 
convention.
Handled nested struct returned in register (SysV doesn't have it supported)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D62213

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/CMakeLists.txt
  lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
  lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Index: lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
===
--- lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -113,12 +113,12 @@
  nullptr,
  nullptr},
 {DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_REGNUM_GENERIC_ARG5,
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r10_x86_64},
  nullptr,
  nullptr},
 {DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_REGNUM_GENERIC_ARG6,
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
   LLDB_INVALID_REGNUM, lldb_r11_x86_64},
  nullptr,
  nullptr},
Index: lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_library(lldbPluginABIWindows_x86_64 PLUGIN
+  ABIWindows_x86_64.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbTarget
+  LINK_COMPONENTS
+Support
+  )
Index: lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
@@ -0,0 +1,112 @@
+//===-- ABIWindows_x86_64.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_ABIWindows_x86_64_h_
+#define liblldb_ABIWindows_x86_64_h_
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIWindows_x86_64 : public lldb_private::ABI {
+public:
+  ~ABIWindows_x86_64() override = default;
+
+  size_t GetRedZoneSize() const override;
+
+  bool PrepareTrivialCall(lldb_private::Thread , lldb::addr_t sp,
+  lldb::addr_t functionAddress,
+  lldb::addr_t returnAddress,
+  llvm::ArrayRef args) const override;
+
+  bool GetArgumentValues(lldb_private::Thread ,
+ lldb_private::ValueList ) const override;
+
+  lldb_private::Status
+  SetReturnValueObject(lldb::StackFrameSP _sp,
+   lldb::ValueObjectSP _value) override;
+
+  lldb::ValueObjectSP
+  GetReturnValueObjectImpl(lldb_private::Thread ,
+   lldb_private::CompilerType ) const override;
+
+  bool
+  CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan _plan) override;
+
+  bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+  // In Windows_x86_64 ABI, stack will always be maintained 16-byte aligned.
+  // Below is from Sys_V_x86_64:
+  // When there is a trap handler on the stack, e.g. _sigtramp in userland
+  // code, we've seen that the stack pointer is often not aligned properly
+  // before the handler is invoked.  This means that lldb will stop the unwind
+  // early -- before the function which caused the trap.
+  //
+  // To work around this, we relax that alignment to be just word-size
+  // (8-bytes).
+  // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+  // in other environments there can be a large number of different functions
+  // involved in async traps.
+  bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+// Make sure the stack call frame addresses are 8 byte aligned
+
+	  if (cfa & (8ull - 1ull))
+  return false; // Not 8 byte aligned
+if (cfa == 0)
+  return false; // Zero is not a valid stack address
+return true;
+  }
+
+  bool CodeAddressIsValid(lldb::addr_t pc) override {
+// We have a 64 bit address space, so anything is valid as opcodes
+// aren't fixed width...
+