[Lldb-commits] [lldb] 1267bb2 - [lldb] TestTypeGetModule.py review improvements

2020-11-01 Thread Ilya Bukonkin via lldb-commits

Author: Ilya Bukonkin
Date: 2020-11-01T13:55:57+03:00
New Revision: 1267bb2e416e42f9c3bbfa7b6cbf4975fa7aa546

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

LOG: [lldb] TestTypeGetModule.py review improvements

Added: 


Modified: 
lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py 
b/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
index 14edc0a14675..5a166e3b38aa 100644
--- a/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
+++ b/lldb/test/API/functionalities/type_get_module/TestTypeGetModule.py
@@ -26,6 +26,7 @@ def find_module(self, target, name):
 
 index += 1
 
+self.assertTrue(result.IsValid())
 return result
 
 def find_comp_unit(self, exe_module, name):
@@ -41,6 +42,7 @@ def find_comp_unit(self, exe_module, name):
 
 index += 1
 
+self.assertTrue(result.IsValid())
 return result
 
 def find_type(self, type_list, name):
@@ -56,39 +58,21 @@ def find_type(self, type_list, name):
 
 index += 1
 
+self.assertTrue(result.IsValid())
 return result
 
 def test(self):
 self.build()
 target  = lldbutil.run_to_breakpoint_make_target(self)
 exe_module = self.find_module(target, 'a.out')
-self.assertTrue(exe_module.IsValid())
-
-type1_name = 'compile_unit1_type'
-type2_name = 'compile_unit2_type'
 
 num_comp_units = exe_module.GetNumCompileUnits()
 self.assertEqual(num_comp_units, 3)
 
 comp_unit = self.find_comp_unit(exe_module, 'compile_unit1.c')
-self.assertTrue(comp_unit.IsValid())
-
-cu_type = self.find_type(comp_unit.GetTypes(), type1_name)
-self.assertTrue(cu_type.IsValid())
-self.assertEqual(cu_type.GetName(), type1_name)
-
+cu_type = self.find_type(comp_unit.GetTypes(), 'compile_unit1_type')
+self.assertTrue(exe_module == cu_type.GetModule())
+
 comp_unit = self.find_comp_unit(exe_module, 'compile_unit2.c')
-self.assertTrue(comp_unit.IsValid())
-
-cu_type = self.find_type(comp_unit.GetTypes(), type2_name)
-self.assertTrue(cu_type.IsValid())
-self.assertEqual(cu_type.GetName(), type2_name)
-
-type1 = target.FindFirstType(type1_name)
-self.assertTrue(type1.IsValid())
-
-type2 = target.FindFirstType(type2_name)
-self.assertTrue(type2.IsValid())
-
-self.assertTrue(exe_module == type1.GetModule() and
-exe_module == type2.GetModule())
+cu_type = self.find_type(comp_unit.GetTypes(), 'compile_unit2_type')
+self.assertTrue(exe_module == cu_type.GetModule())



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


[Lldb-commits] [PATCH] D88483: Add possibility to get module from SBType

2020-11-01 Thread Ilya Bukonkin via Phabricator via lldb-commits
fallkrum added a comment.

Refactored test according to recommendations given during review 1267bb2e416e 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88483

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


[Lldb-commits] [lldb] ba447f3 - [NFC][lldb] Silence unused variable warning

2020-11-01 Thread Nathan James via lldb-commits

Author: Nathan James
Date: 2020-11-01T14:37:06Z
New Revision: ba447f38f6e53e5de68fa264797690b74cb750c0

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

LOG: [NFC][lldb] Silence unused variable warning

Added: 


Modified: 
lldb/source/Host/common/PseudoTerminal.cpp

Removed: 




diff  --git a/lldb/source/Host/common/PseudoTerminal.cpp 
b/lldb/source/Host/common/PseudoTerminal.cpp
index c5f101caffe3..de76e8ab4f68 100644
--- a/lldb/source/Host/common/PseudoTerminal.cpp
+++ b/lldb/source/Host/common/PseudoTerminal.cpp
@@ -106,6 +106,7 @@ std::string PseudoTerminal::GetSecondaryName() const {
   char buf[PATH_MAX];
   buf[0] = '\0';
   int r = ptsname_r(m_primary_fd, buf, sizeof(buf));
+  (void)r;
   assert(r == 0);
   return buf;
 #else



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


[Lldb-commits] [PATCH] D90556: [LLDB][NFC] treat Lua error codes in a more explicit manner

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

This patch is a minor suggestion to not rely on the fact
that the `LUA_OK` macro is 0.

This assumption could change in future versions of the C API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90556

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -18,7 +18,7 @@
   int error =
   luaL_loadbuffer(m_lua_state, buffer.data(), buffer.size(), "buffer") ||
   lua_pcall(m_lua_state, 0, 0, 0);
-  if (!error)
+  if (error == LUA_OK)
 return llvm::Error::success();
 
   llvm::Error e = llvm::make_error(
@@ -44,7 +44,7 @@
 
   int error = luaL_loadfile(m_lua_state, filename.data()) ||
   lua_pcall(m_lua_state, 0, 1, 0);
-  if (error) {
+  if (error != LUA_OK) {
 llvm::Error e = llvm::make_error(
 llvm::formatv("{0}\n", lua_tostring(m_lua_state, -1)),
 llvm::inconvertibleErrorCode());


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -18,7 +18,7 @@
   int error =
   luaL_loadbuffer(m_lua_state, buffer.data(), buffer.size(), "buffer") ||
   lua_pcall(m_lua_state, 0, 0, 0);
-  if (!error)
+  if (error == LUA_OK)
 return llvm::Error::success();
 
   llvm::Error e = llvm::make_error(
@@ -44,7 +44,7 @@
 
   int error = luaL_loadfile(m_lua_state, filename.data()) ||
   lua_pcall(m_lua_state, 0, 1, 0);
-  if (error) {
+  if (error != LUA_OK) {
 llvm::Error e = llvm::make_error(
 llvm::formatv("{0}\n", lua_tostring(m_lua_state, -1)),
 llvm::inconvertibleErrorCode());
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D87173: Ignores functions that have a range starting outside of a code section

2020-11-01 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 302150.
aadsm added a comment.

Used -s to feed commands and disabled errors when interpreting them


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87173

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/function-entries-invalid-addresses.yaml

Index: lldb/test/Shell/SymbolFile/DWARF/function-entries-invalid-addresses.yaml
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/function-entries-invalid-addresses.yaml
@@ -0,0 +1,366 @@
+# RUN: split-file %s %t
+# RUN: yaml2obj %t/test.yaml > %t/test.obj
+
+#--- check-main.lldb-commands
+image lookup -F main
+# RUN: %lldb %t/test.obj -b -o "settings set interpreter.stop-command-source-on-error false" -s %t/check-main.lldb-commands | FileCheck --check-prefix MAIN %s
+# MAIN: 1 match found {{.*}}
+
+#--- check-foo.lldb-commands
+image lookup -F foo
+# RUN: %lldb %t/test.obj -b -o "settings set interpreter.stop-command-source-on-error false" -s %t/check-foo.lldb-commands | FileCheck --check-prefix FOO %s
+# FOO-NOT: 1 match found {{.*}}
+
+#--- test.yaml
+# int foo() {
+# return 1;
+# }
+#
+# int main() {
+# return 0;
+# }
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x0107
+  cpusubtype:  0x0003
+  filetype:0x000A
+  ncmds:   7
+  sizeofcmds:  1400
+  flags:   0x
+  reserved:0x
+LoadCommands:
+  - cmd: LC_UUID
+cmdsize: 24
+uuid:FD292DBF-A309-369B-A588-00E20D0E84CF
+  - cmd: LC_BUILD_VERSION
+cmdsize: 24
+platform:1
+minos:   659200
+sdk: 659206
+ntools:  0
+  - cmd: LC_SYMTAB
+cmdsize: 24
+symoff:  4096
+nsyms:   3
+stroff:  4144
+strsize: 33
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __PAGEZERO
+vmaddr:  0
+vmsize:  4294967296
+fileoff: 0
+filesize:0
+maxprot: 0
+initprot:0
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 232
+segname: __TEXT
+vmaddr:  4294967296
+vmsize:  16384
+fileoff: 0
+filesize:0
+maxprot: 5
+initprot:5
+nsects:  2
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x00013FA0
+size:24
+offset:  0x
+align:   4
+reloff:  0x
+nreloc:  0
+flags:   0x8400
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+content: CFFAEDFE070103000A0007007805
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x00013FB8
+size:72
+offset:  0x
+align:   2
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+content: CFFAEDFE070103000A00070078051B001800FD292DBFA309369BA58800E20D0E84CF32001800010F0A00
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __LINKEDIT
+vmaddr:  4294983680
+vmsize:  4096
+fileoff: 4096
+filesize:81
+maxprot: 1
+initprot:1
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 952
+segname: __DWARF
+vmaddr:  4294987776
+vmsize:  4096
+fileoff: 8192
+filesize:826
+maxprot: 7
+initprot:3
+nsects:  6
+flags:   0
+Sections:
+  - sectname:__debug_pubnames
+segname: __DWARF
+addr:0x00015052
+size:35
+offset:  0x2052
+align:   0
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__de

[Lldb-commits] [PATCH] D87172: Check if debug line sequences are starting after the first code segment

2020-11-01 Thread António Afonso via Phabricator via lldb-commits
aadsm added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:503-505
+  if (section_list) {
+InitializeFirstCodeAddress(*section_list);
+  }

labath wrote:
> clayborg wrote:
> > remove braces
> or even fold the declaration into the if condition.
folding was not possible as clang-formatter didn't allow it.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87172

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


[Lldb-commits] [PATCH] D90557: [LLDB/Lua] call lua_close() on Lua dtor

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

This patch calls `lua_close()` on Lua dtor.

This guarantees that the Lua GC finalizers are honored, aside from the
usual internal clean up.

It also guarantees a call to the `__close` metamethod of any active
to-be-closed variable in Lua 5.4.

Since the previous `luaL_openlibs()` was a noop, because the standard
library is cached internally, I've removed it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90557

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -33,7 +33,7 @@
 
   ~Lua() {
 assert(m_lua_state);
-luaL_openlibs(m_lua_state);
+lua_close(m_lua_state);
   }
 
   llvm::Error Run(llvm::StringRef buffer);


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -33,7 +33,7 @@
 
   ~Lua() {
 assert(m_lua_state);
-luaL_openlibs(m_lua_state);
+lua_close(m_lua_state);
   }
 
   llvm::Error Run(llvm::StringRef buffer);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D87868: [RFC] When calling the process mmap try to call all found instead of just the first one

2020-11-01 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 302178.
aadsm added a comment.
Herald added subscribers: MaskRay, emaste.
Herald added a reviewer: espindola.

Also set the symbol as external when it is weak


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87868

Files:
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp


Index: lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
===
--- lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
+++ lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
@@ -48,9 +48,9 @@
   ConstString("mmap"), eFunctionNameTypeFull, include_symbols,
   include_inlines, sc_list);
   const uint32_t count = sc_list.GetSize();
-  if (count > 0) {
+  for (uint32_t i = 0; i < count; i++) {
 SymbolContext sc;
-if (sc_list.GetContextAtIndex(0, sc)) {
+if (sc_list.GetContextAtIndex(i, sc) && sc.symbol->IsExternal()) {
   const uint32_t range_scope =
   eSymbolContextFunction | eSymbolContextSymbol;
   const bool use_inline_block_range = false;
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2264,8 +2264,10 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-if (symbol.getBinding() == STB_WEAK)
+if (symbol.getBinding() == STB_WEAK) {
   dc_symbol.SetIsWeak(true);
+  dc_symbol.SetIsExternal(true);
+}
 symtab->AddSymbol(dc_symbol);
   }
   return i;


Index: lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
===
--- lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
+++ lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
@@ -48,9 +48,9 @@
   ConstString("mmap"), eFunctionNameTypeFull, include_symbols,
   include_inlines, sc_list);
   const uint32_t count = sc_list.GetSize();
-  if (count > 0) {
+  for (uint32_t i = 0; i < count; i++) {
 SymbolContext sc;
-if (sc_list.GetContextAtIndex(0, sc)) {
+if (sc_list.GetContextAtIndex(i, sc) && sc.symbol->IsExternal()) {
   const uint32_t range_scope =
   eSymbolContextFunction | eSymbolContextSymbol;
   const bool use_inline_block_range = false;
Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2264,8 +2264,10 @@
 symbol_size_valid,  // Symbol size is valid
 has_suffix, // Contains linker annotations?
 flags); // Symbol flags.
-if (symbol.getBinding() == STB_WEAK)
+if (symbol.getBinding() == STB_WEAK) {
   dc_symbol.SetIsWeak(true);
+  dc_symbol.SetIsExternal(true);
+}
 symtab->AddSymbol(dc_symbol);
   }
   return i;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70885: [lldb] Use explicit lldb commands on tests

2020-11-01 Thread António Afonso via Phabricator via lldb-commits
aadsm updated this revision to Diff 302180.
aadsm added a comment.
Herald added a subscriber: JDevlieghere.
Herald added a reviewer: JDevlieghere.

Use set and rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70885

Files:
  lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py


Index: lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
===
--- lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
+++ lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
@@ -382,8 +382,8 @@
 # breakpoints get hit
 launchCommands = [
 'target create "%s"' % (program),
-'br s -f main.c -l %d' % first_line,
-'br s -f main.c -l %d' % second_line,
+'breakpoint set -f main.c -l %d' % first_line,
+'breakpoint set -f main.c -l %d' % second_line,
 'process launch --stop-at-entry'
 ]
 


Index: lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
===
--- lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
+++ lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
@@ -382,8 +382,8 @@
 # breakpoints get hit
 launchCommands = [
 'target create "%s"' % (program),
-'br s -f main.c -l %d' % first_line,
-'br s -f main.c -l %d' % second_line,
+'breakpoint set -f main.c -l %d' % first_line,
+'breakpoint set -f main.c -l %d' % second_line,
 'process launch --stop-at-entry'
 ]
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90557: [LLDB/Lua] call lua_close() on Lua dtor

2020-11-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90557

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


[Lldb-commits] [PATCH] D70885: [lldb] Use explicit lldb commands on tests

2020-11-01 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70885

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