[Lldb-commits] [lldb] 3784fc4 - Remove set-but-unused variable

2021-08-26 Thread David Blaikie via lldb-commits

Author: David Blaikie
Date: 2021-08-26T16:58:47-07:00
New Revision: 3784fc493eb254bbed422f0bc83f01bee94a8195

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

LOG: Remove set-but-unused variable

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f2ed6330e36d1..0bab2b3ae7512 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1967,16 +1967,12 @@ bool DWARFASTParserClang::CompleteRecordType(const 
DWARFDIE ,
   TypeSystemClang::StartTagDeclarationDefinition(clang_type);
 }
 
-int tag_decl_kind = -1;
 AccessType default_accessibility = eAccessNone;
 if (tag == DW_TAG_structure_type) {
-  tag_decl_kind = clang::TTK_Struct;
   default_accessibility = eAccessPublic;
 } else if (tag == DW_TAG_union_type) {
-  tag_decl_kind = clang::TTK_Union;
   default_accessibility = eAccessPublic;
 } else if (tag == DW_TAG_class_type) {
-  tag_decl_kind = clang::TTK_Class;
   default_accessibility = eAccessPrivate;
 }
 



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


[Lldb-commits] [PATCH] D108061: [lldb] Add support for shared library load when executable called through ld.

2021-08-26 Thread Rumeet Dhindsa via Phabricator via lldb-commits
rdhindsa marked 2 inline comments as done and an inline comment as not done.
rdhindsa added a comment.

This patch caused a test failure when it was submitted two days ago, so I 
reverted it that day. However, I have not been able to reproduce the failure 
locally even using the cmake config from bot.

Failure was in api/multithreaded/TestMultithreaded.py

Failing bot link: 
https://lab.llvm.org/buildbot/#/builders/68/builds/17556/steps/6/logs/stdio

I would appreciate any ideas to be able to repro it locally. The email from 
buildbot showed Sigsegv:

  Traceback (most recent call last):
File 
"/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 149, in wrapper
  return func(*args, **kwargs)
File 
"/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/api/multithreaded/TestMultithreaded.py",
 line 37, in test_python_stop_hook
  'test_python_stop_hook')
File 
"/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/api/multithreaded/TestMultithreaded.py",
 line 116, in build_and_test
  check_call(exe, env=env, stdout=fnull, stderr=fnull)
File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
  raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command 
'['/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/api/multithreaded/TestMultithreaded.test_python_stop_hook/test_python_stop_hook',
 
'/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/api/multithreaded/TestMultithreaded.test_python_stop_hook/inferior_program']'
 died with .
  Config=x86_64-/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108061

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


[Lldb-commits] [PATCH] D108061: [lldb] Add support for shared library load when executable called through ld.

2021-08-26 Thread Rumeet Dhindsa via Phabricator via lldb-commits
rdhindsa updated this revision to Diff 368988.
rdhindsa marked 6 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108061

Files:
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/test/API/functionalities/dyld-launch-linux/Makefile
  lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py
  lldb/test/API/functionalities/dyld-launch-linux/main.cpp
  lldb/test/API/functionalities/dyld-launch-linux/signal_file.cpp
  lldb/test/API/functionalities/dyld-launch-linux/signal_file.h

Index: lldb/test/API/functionalities/dyld-launch-linux/signal_file.h
===
--- /dev/null
+++ lldb/test/API/functionalities/dyld-launch-linux/signal_file.h
@@ -0,0 +1 @@
+int get_signal_crash();
Index: lldb/test/API/functionalities/dyld-launch-linux/signal_file.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/dyld-launch-linux/signal_file.cpp
@@ -0,0 +1,7 @@
+#include "signal_file.h"
+#include 
+
+int get_signal_crash(void) {
+  raise(SIGSEGV);
+  return 0;
+}
Index: lldb/test/API/functionalities/dyld-launch-linux/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/dyld-launch-linux/main.cpp
@@ -0,0 +1,6 @@
+#include "signal_file.h"
+
+int main() {
+  // Break here
+  return get_signal_crash();
+}
Index: lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py
===
--- /dev/null
+++ lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py
@@ -0,0 +1,52 @@
+"""
+Test that LLDB can launch a linux executable through the dynamic loader and still hit a breakpoint.
+"""
+
+import lldb
+import os
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestLinux64LaunchingViaDynamicLoader(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIf(oslist=no_match(['linux']))
+@no_debug_info_test
+def test(self):
+self.build()
+candidates = [
+"/lib64/ld-linux-x86-64.so.2",
+"/usr/lib/ld-linux-x86-64.so.2"
+]
+exe = next((c for c in candidates if os.path.exists(c)), None)
+if not os.path.exists(exe):
+return
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+# Set breakpoints both on shared library function as well as on
+# main. Both of them will be pending breakpoints.
+breakpoint_main = target.BreakpointCreateBySourceRegex("// Break here", lldb.SBFileSpec("main.cpp"))
+breakpoint_shared_library = target.BreakpointCreateBySourceRegex("get_signal_crash", lldb.SBFileSpec("signal_file.cpp"))
+launch_info = lldb.SBLaunchInfo([ "--library-path", self.get_process_working_directory(), self.getBuildArtifact("a.out")])
+launch_info.SetWorkingDirectory(self.get_process_working_directory())
+error = lldb.SBError()
+process = target.Launch(launch_info, error)
+self.assertTrue(error.Success())
+
+# Stopped on main here.
+self.assertEqual(process.GetState(), lldb.eStateStopped)
+thread = process.GetSelectedThread()
+self.assertIn("main", thread.GetFrameAtIndex(0).GetDisplayFunctionName())
+process.Continue()
+
+# Stopped on get_signal_crash function here.
+self.assertEqual(process.GetState(), lldb.eStateStopped)
+self.assertIn("get_signal_crash", thread.GetFrameAtIndex(0).GetDisplayFunctionName())
+process.Continue()
+
+# Stopped because of generated signal.
+self.assertEqual(process.GetState(), lldb.eStateStopped)
+self.assertIn("raise", thread.GetFrameAtIndex(0).GetDisplayFunctionName())
+self.assertIn("get_signal_crash", thread.GetFrameAtIndex(1).GetDisplayFunctionName())
Index: lldb/test/API/functionalities/dyld-launch-linux/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/dyld-launch-linux/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+DYLIB_NAME := signal_file
+DYLIB_CXX_SOURCES := signal_file.cpp
+include Makefile.rules
Index: lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
===
--- lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -333,28 +333,48 @@
 LLDB_LOG(log, "Rendezvous structure is not set up yet. "
   "Trying to locate rendezvous breakpoint in the interpreter "
   "by symbol name.");

[Lldb-commits] [PATCH] D108768: [lldb] [DynamicRegisterInfo] Fix mistaken reg type when calculating offsets

2021-08-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny abandoned this revision.
mgorny added a comment.

Ok, I think it might just be `Dump()` being broken. I've found another bug with 
my code, and things seem to work after fixing it, so I suppose the problem is 
not really worth my effort right now.


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

https://reviews.llvm.org/D108768

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


[Lldb-commits] [PATCH] D108257: Add type to the output for FieldDecl when logging in ClangASTSource::layoutRecordType

2021-08-26 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a4a498a884a: [LLDB] Add type to the output for FieldDecl 
when logging in ClangASTSource… (authored by shafik).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108257

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1571,8 +1571,10 @@
 fe = record->field_end();
  fi != fe; ++fi) {
   LLDB_LOG(log,
-   "LRT (FieldDecl*){0}, Name = '{1}', Offset = {2} bits",
-   *fi, fi->getName(), field_offsets[*fi]);
+   "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = "
+   "{3} bits",
+   *fi, fi->getName(), fi->getType().getAsString(),
+   field_offsets[*fi]);
 }
 DeclFromParser parser_cxx_record =
 DynCast(parser_record);


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1571,8 +1571,10 @@
 fe = record->field_end();
  fi != fe; ++fi) {
   LLDB_LOG(log,
-   "LRT (FieldDecl*){0}, Name = '{1}', Offset = {2} bits",
-   *fi, fi->getName(), field_offsets[*fi]);
+   "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = "
+   "{3} bits",
+   *fi, fi->getName(), fi->getType().getAsString(),
+   field_offsets[*fi]);
 }
 DeclFromParser parser_cxx_record =
 DynCast(parser_record);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2a4a498 - [LLDB] Add type to the output for FieldDecl when logging in ClangASTSource::layoutRecordType

2021-08-26 Thread Shafik Yaghmour via lldb-commits

Author: Shafik Yaghmour
Date: 2021-08-26T11:17:47-07:00
New Revision: 2a4a498a884ad929dad5dc72e20c76adfecfc78c

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

LOG: [LLDB] Add type to the output for FieldDecl when logging in 
ClangASTSource::layoutRecordType

I was debugging a problem and noticed that it would have been helpful to have
the type of each FieldDecl when looking at the output from
ClangASTSource::layoutRecordType.

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

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 58b6b625bfeca..ae93252e55212 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1571,8 +1571,10 @@ bool ClangASTSource::layoutRecordType(const RecordDecl 
*record, uint64_t ,
 fe = record->field_end();
  fi != fe; ++fi) {
   LLDB_LOG(log,
-   "LRT (FieldDecl*){0}, Name = '{1}', Offset = {2} bits",
-   *fi, fi->getName(), field_offsets[*fi]);
+   "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = "
+   "{3} bits",
+   *fi, fi->getName(), fi->getType().getAsString(),
+   field_offsets[*fi]);
 }
 DeclFromParser parser_cxx_record =
 DynCast(parser_record);



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


[Lldb-commits] [PATCH] D108257: Add type to the output for FieldDecl when logging in ClangASTSource::layoutRecordType

2021-08-26 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 368935.
shafik added a comment.

Applying formatting


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

https://reviews.llvm.org/D108257

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1571,8 +1571,10 @@
 fe = record->field_end();
  fi != fe; ++fi) {
   LLDB_LOG(log,
-   "LRT (FieldDecl*){0}, Name = '{1}', Offset = {2} bits",
-   *fi, fi->getName(), field_offsets[*fi]);
+   "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = "
+   "{3} bits",
+   *fi, fi->getName(), fi->getType().getAsString(),
+   field_offsets[*fi]);
 }
 DeclFromParser parser_cxx_record =
 DynCast(parser_record);


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1571,8 +1571,10 @@
 fe = record->field_end();
  fi != fe; ++fi) {
   LLDB_LOG(log,
-   "LRT (FieldDecl*){0}, Name = '{1}', Offset = {2} bits",
-   *fi, fi->getName(), field_offsets[*fi]);
+   "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = "
+   "{3} bits",
+   *fi, fi->getName(), fi->getType().getAsString(),
+   field_offsets[*fi]);
 }
 DeclFromParser parser_cxx_record =
 DynCast(parser_record);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c62ef02 - [NFC] Removing deprecated intel-features test folder

2021-08-26 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2021-08-26T10:36:00-07:00
New Revision: c62ef0255d904fdd99173493e8e064a2dde598e8

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

LOG: [NFC] Removing deprecated intel-features test folder

This folder has no valid tests anymore

Added: 


Modified: 


Removed: 
lldb/test/API/tools/intel-features/intel-pt/test/Makefile
lldb/test/API/tools/intel-features/intel-pt/test/main.cpp



diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile 
b/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
deleted file mode 100644
index 8b20bcb0..
--- a/lldb/test/API/tools/intel-features/intel-pt/test/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules

diff  --git a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp 
b/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
deleted file mode 100644
index d2750fff56b5..
--- a/lldb/test/API/tools/intel-features/intel-pt/test/main.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-int fun(int a) { return a * a + 1; }
-
-int main() {
-  int z = 0;
-  for (int i = 0; i < 1; i++) { // Break for loop
-z += fun(z);
-  }
-
-  return 0; // Break 1
-}



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


[Lldb-commits] [lldb] 600a2a7 - [NFC] Remove deprecated Intel PT test

2021-08-26 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2021-08-26T10:34:04-07:00
New Revision: 600a2a7ec07aa0215c094d2d8b4c0325189ad30d

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

LOG: [NFC] Remove deprecated Intel PT test

Added: 


Modified: 


Removed: 
lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py



diff  --git 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py 
b/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
deleted file mode 100644
index 8c6c9cf4fbb75..0
--- 
a/lldb/test/API/tools/intel-features/intel-pt/test/TestIntelPTSimpleBinary.py
+++ /dev/null
@@ -1,61 +0,0 @@
-from __future__ import print_function
-
-import os
-import lldb
-import time
-
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-from lldbsuite.test import configuration
-
-
-class TestIntelPTSimpleBinary(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-NO_DEBUG_INFO_TESTCASE = True
-
-def setUp(self):
-TestBase.setUp(self)
-
-if 'intel-pt' not in configuration.enabled_plugins:
-self.skipTest("The intel-pt test plugin is not enabled")
-
-plugin_path = os.path.join(configuration.lldb_libs_dir, 
"liblldbIntelFeatures.so")
-self.runCmd("plugin load " + plugin_path)
-
-@skipIf(oslist=no_match(['linux']))
-@skipIf(archs=no_match(['i386', 'x86_64']))
-@skipIfRemote
-def test_basic_flow(self):
-"""Test collection, decoding, and dumping instructions"""
-
-self.build()
-exe = self.getBuildArtifact("a.out")
-lldbutil.run_to_name_breakpoint(self, "main", exe_name=exe)
-# We start tracing from main
-self.runCmd("processor-trace start all")
-
-# We check the trace after the for loop
-self.runCmd("b " + str(line_number('main.cpp', '// Break 1')))
-self.runCmd("c")
-
-# We wait a little bit to ensure the processor has send the PT packets 
to
-# the memory
-time.sleep(.1)
-
-# We find the start address of the 'fun' function for a later check
-target = self.dbg.GetSelectedTarget()
-fun_start_adddress = target.FindFunctions("fun")[0].GetSymbol() \
-.GetStartAddress().GetLoadAddress(target)
-
-# We print the last instructions
-self.expect("processor-trace show-instr-log -c 100",
-patterns=[
-# We expect to have seen the first instruction of 'fun'
-hex(fun_start_adddress),
-# We expect to see the exit condition of the for loop
-"at main.cpp:" + str(line_number('main.cpp', '// Break for 
loop'))
-])
-
-self.runCmd("processor-trace stop")



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


[Lldb-commits] [PATCH] D108768: [lldb] [DynamicRegisterInfo] Fix mistaken reg type when calculating offsets

2021-08-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny planned changes to this revision.
mgorny added a comment.

`TestRemoteRegNums` suggests that there's also code relying on remote regnums 
being used there. What a mess :-(.


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

https://reviews.llvm.org/D108768

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


[Lldb-commits] [PATCH] D108768: [lldb] [DynamicRegisterInfo] Fix mistaken reg type when calculating offsets

2021-08-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, jasonmolenda, JDevlieghere.
mgorny requested review of this revision.

Fix the DynamicRegisterInfo::ConfigureOffsets() method to treat
value_regs as local register numbers (eRegisterKindLLDB) rather than
gdb-remote numbers (eRegisterKindProcessPlugin).  This seems consistent
with other uses in the class, and it fixes calculating register offsets
when remote and local register numbers are not in sync.


https://reviews.llvm.org/D108768

Files:
  lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp


Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -663,9 +663,7 @@
   if (reg.byte_offset == LLDB_INVALID_INDEX32) {
 uint32_t value_regnum = reg.value_regs[0];
 if (value_regnum != LLDB_INVALID_INDEX32)
-  reg.byte_offset =
-  GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
-  ->byte_offset;
+  reg.byte_offset = GetRegisterInfoAtIndex(value_regnum)->byte_offset;
   }
 }
 


Index: lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
===
--- lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -663,9 +663,7 @@
   if (reg.byte_offset == LLDB_INVALID_INDEX32) {
 uint32_t value_regnum = reg.value_regs[0];
 if (value_regnum != LLDB_INVALID_INDEX32)
-  reg.byte_offset =
-  GetRegisterInfoAtIndex(remote_to_local_regnum_map[value_regnum])
-  ->byte_offset;
+  reg.byte_offset = GetRegisterInfoAtIndex(value_regnum)->byte_offset;
   }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D108233: WIP: Add minidump save-core functionality to ELF object files

2021-08-26 Thread Andrej Korman via Phabricator via lldb-commits
Aj0SK added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp:225
+m.SizeOfImage = static_cast(
+mod->GetObjectFile()->GetByteSize());
+m.Checksum = static_cast(0);

clayborg wrote:
> I am not sure if the object file's full size is the right value here. I think 
> the right value would be the last contiguous loaded address range for a given 
> file. This information is going to be used to set the load addresses of any 
> sections in the object file when it is loaded, and if we have a huge ELF file 
> that has tons of debug info, this is going to make the loaded address range 
> way too big.
> 
> So the algorithm I would suggest is:
> 1 - grab the section that contains base address:
> 2 - in a loop, grab the next section that starts  at the end of this section, 
> and as long as the addresses are contiguous, increase the SizeOfImage:
> 
> So something like:
> ```
> lldb::SectionSP sect_sp = mod->GetObjectFile()->GetBaseAddress().GetSection();
> uint64_t SizeOfImage = 0;
> if (sect_sp) {
>   lldb::addr_t sect_addr = sect_sp->GetLoadAddress();
>   // Use memory size since zero fill sections, like ".bss", will be smaller 
> on disk.
>   lldb::addr_t sect_size = sect_sp->MemorySize(); 
>   // This will usually be zero, but make sure to calculate the BaseOfImage 
> offset.
>   const lldb::addr_t base_sect_offset = m.BaseOfImage - sect_addr;
>   SizeOfImage = sect_size - base_sect_offset;
>   lldb::addr_t next_sect_addr = sect_addr + sect_size;
>   Address sect_so_addr;
>   target.ResolveLoadAddress(next_sect_addr, sect_so_addr);
>   lldb::SectionSP next_sect_sp = sect_so_addr.GetSections();
>   while (next_sect_sp && next_sect_sp->GetLoadBaseAddress() == 
> next_sect_addr)) {
> sect_size = sect_sp->MemorySize(); 
> SizeOfImage += sect_size;
> next_sect_addr += sect_size;
> target.ResolveLoadAddress(next_sect_addr, sect_so_addr);
> next_sect_sp = sect_so_addr.GetSections();
>   }
>   m.SizeOfImage = static_cast(SizeOfImage);
> } else {
>   m.SizeOfImage = static_cast(sect_size);
> }
> ```
> 
Thank you for the suggestion. I will add it to the next revision.



Comment at: lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp:519
+lldb_private::Status
+MinidumpFileBuilder::AddMemoryList(const lldb::ProcessSP _sp) {
+  Status error;

clayborg wrote:
> This should take in the CoreStyle and only emit what was asked for.
> 
> If style is set to "eSaveCoreStackOnly", then grab only the memory regions 
> for each thread stack pointer and save only those. 
> 
> We can't tell from LLDB APIs if a page is dirty, so if we get 
> "eSaveCoreDirtyOnly", then we will need to save all memory regions that have 
> write permissions.
> 
> If it is either "eSaveCoreFull"  or "eSaveCoreUnspecified" then save 
> everything.
I agree that this code should take care of a CoreStyle but it poses a 
significant problem to this implementation as it was mainly designed to save 
smaller Minidumps. This solution stores all of the information in memory before 
dumping them (this eases an implementation quite a bit because of the way how 
Minidump pointers (offsets) are working). This implementation, on my machine, 
exhausted memory before the minidump could be written in case of a full memory 
dump. At this time, we don't plan to reimplement this solution in the way it 
would allow to store all the data on disc at the time of minidump creation so 
there are two possible solutions that I see:

1. If the type of the CoreStyle is full or dirty, this plugin will return false 
from the SaveCore function. Then maybe the default CoreStyle for this plugin 
should be changed to "eSaveCoreStackOnly".

2. To the best of my knowledge, it should be theoretically possible to 
reimplement Dump() method to sort of take special care of a MemoryListStream, 
dumping also the memory information at the end of the minidump file as I think 
the memory dump is the most stressful for the memory and otherwise there is no 
problem with this.



Comment at: lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp:667
+if (memory_buffer) {
+  size_t size = memory_buffer->getBufferSize();
+  AddDirectory(stream, size);

clayborg wrote:
> Do we need to make sure size is not zero?
I can add this. The idea was that even if the file is "empty", we at least give 
the user opening the minidump the information that we have been able to find 
this file and add it to the minidump instead of only not providing any 
information at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108233

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


[Lldb-commits] [PATCH] D108061: [lldb] Add support for shared library load when executable called through ld.

2021-08-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added inline comments.
This revision now requires changes to proceed.



Comment at: 
lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py:13
+
+def test(self):
+self.build()

Could we just make the test Linux-specific? I doubt we'll ever find a 
`/lib64/ld-linux-x86-64.so.2` on macOS. In theory you could also move the build 
behind the file-existence check, but then the test will PASS instead of 
UNSUPPORTED (and the later better fits the situation that this doesn't run 
because it isn't supported).

Also if you add `no_debug_info_test` then we only run this test once (which 
makes the test about 3x faster).

```
lang=Python
 @skipIf(oslist=no_match(['linux']))
 @no_debug_info_test
 def test(self):
```



Comment at: 
lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.py:15
+self.build()
+exe = "/lib64/ld-linux-x86-64.so.2"
+if(os.path.exists(exe)):

Could we make this based on a list of files? There will be people with slightly 
different paths/file names so I anyway anticipate that we get more candidates 
to check here:

```
lang=python
candidates = [
"/lib64/ld-linux-x86-64.so.2",
"/usr/lib/ld-linux-x86-64.so.2"
]
exe = next((c for c in candidates if os.path.exists(c)), None)
if not exe:
return
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108061

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


[Lldb-commits] [PATCH] D108717: Fix Reference case for TypeSystemClang::GetChildCompilerTypeAtIndex(...) to avoid possible invalid cast

2021-08-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:6505
 if (idx_is_valid) {
-  const clang::ReferenceType *reference_type =
-  llvm::cast(GetQualType(type).getTypePtr());
-  CompilerType pointee_clang_type =
-  GetType(reference_type->getPointeeType());
+  CompilerType pointee_clang_type;
+

shafik wrote:
> teemperor wrote:
> > I really like the idea of reusing the TypeSystemClang functions here (we 
> > should do this everywhere I think). FWIW, I think this can all just be 
> > `CompilerType pointee_clang_type = GetNonReferenceType(type);` From the 
> > code below `GetPointeeType` would also work. We already call the variable 
> > here `pointee` type so I don't think calling references pointers here will 
> > hurt too much, so I think both is fine.
> I tried `GetNonReferenceType(type).GetPointeeType()` but I get back an empty 
> `CompilerType` it looks like it is doing almost exactly the same thing as the 
> previous code:
> 
> `(*this)->getAs()`
I mean the whole thing could be just `GetNonReferenceType`. 
`GetNonReferenceType` gives you the underlying type, so the `GetPointeeType` 
after would just fail (-> empty return type) when it gets whatever the 
underlying type is:

```
CompilerType int_ref = ...;
int_ref.GetName() // -> "int &"
int_ref.GetNonReferenceType().GetName() // -> "int"
int_ref.GetPointeeType().GetName() // -> "int"

CompilerType int = ...;
int.GetName() // -> "int"
int_ref..GetPointeeType().GetName() // -> "" (Invalid CompilerType as int isn't 
a pointer/reference
```



Comment at: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:6508
+  if (parent_type_class == clang::Type::LValueReference)
+pointee_clang_type = GetLValueReferenceType(type).GetPointeeType();
+  else

shafik wrote:
> teemperor wrote:
> > I think the logic here is reversed? `type` is a reference type (potentially 
> > behind a typedef). `GetLValueReferenceType` on `type` returns the reference 
> > type *to* that type. Not the underlying reference. The fallback for this is 
> > just that it returns the current type IIRC if you already have a reference, 
> > that's why this works. So, `GetLValueReferenceType` is just a no-op and 
> > `GetPointeeType` is doing the actual dereferencing. I think just the 
> > `GetPointeeType` is needed.
> Maybe I am confused but I thought given:
> 
> ```
> TypedefType 0x7fb11c841460 'std::__compressed_pair_elem std::basic_string, class 
> std::allocator >::__rep, 0, false>::const_reference' sugar
> |-Typedef 0x7fb11c8413f0 'const_reference'
> `-LValueReferenceType 0x7fb11c8413c0 'const struct std::basic_string struct std::char_traits, class std::allocator >::__rep &'
>   `-QualType 0x7fb11cac3361 'const struct std::basic_string std::char_traits, class std::allocator >::__rep' const
> `-RecordType 0x7fb11cac3360 'struct std::basic_string std::char_traits, class std::allocator >::__rep'
>   `-CXXRecord 0x7fb11cac32b8 '__rep'
> ```
> 
> that `llvm::cast(GetQualType(type).getTypePtr())` was 
> intended to obtain:
> 
> ```
> LValueReferenceType 0x7fb11c829630 'const struct std::basic_string struct std::char_traits, class std::allocator >::__rep &'
> `-QualType 0x7fb11cac3361 'const struct std::basic_string std::char_traits, class std::allocator >::__rep' const
>   `-RecordType 0x7fb11cac3360 'struct std::basic_string std::char_traits, class std::allocator >::__rep'
> `-CXXRecord 0x7fb11cac32b8 '__rep'
> ```
> 
> which is what `GetLValueReferenceType(type)` does.
> 
> 
That is the right intention of the original code, but `GetLValueReferenceType` 
is just the inverse of what should happen. It takes a non-reference type and 
returns the reference type for it (`int` -> `int &`). I added some dump calls 
to the code which might explain what's going on:

```
lang=c++
  case clang::Type::LValueReference:
  case clang::Type::RValueReference:
if (idx_is_valid) { 
  CompilerType pointee_clang_type;  

  if (parent_type_class == clang::Type::LValueReference) {  
llvm::errs() << "type:\n";  
GetQualType(type).dump();   
CompilerType tmp = GetLValueReferenceType(type);
llvm::errs() << "tmp (after GetLValueReferenceType):\n";
   
tmp.dump(); 
pointee_clang_type = tmp.GetPointeeType();  
llvm::errs() << "pointee\n";