Re: [Lldb-commits] Patch for fixing FDE indexing when scan debug_info section

2017-05-25 Thread Abid, Hafiz via lldb-commits
?I will commit on your behalf.


Thanks,

Abid


From: Tatyana Krasnukha 
Sent: Wednesday, May 24, 2017 6:30 PM
To: Abid, Hafiz; lldb-commits@lists.llvm.org
Subject: RE: [Lldb-commits] Patch for fixing FDE indexing when scan debug_info 
section

Formatting is done.
Created D33504, and it is accepted now, but what should I do next (I haven't 
commit access)?

Thanks,
Tatyana

From: Abid, Hafiz [mailto:hafiz_a...@mentor.com]
Sent: Wednesday, 24 May, 2017 12:37 PM
To: Tatyana Krasnukha ; 
lldb-commits@lists.llvm.org
Subject: Re: [Lldb-commits] Patch for fixing FDE indexing when scan debug_info 
section


Please put it as review in Phabricator so others can comment too. I am 
wondering how we can test this behaviour.

One can use -fno-asynchronous-unwind-tables with clang to disable generation of 
.eh_frame but the startup code

still brings in that section.



You also need to run clang-format to make sure formatting is right and I see 
some strange characters in the patch file.



> +  // Try to find .debug_frame section even if .eh_frame doesn't exist.

s/even if/if/



Thanks,

Abid


From: Tatyana Krasnukha 
mailto:tatyana.krasnu...@synopsys.com>>
Sent: Tuesday, May 23, 2017 6:20 PM
To: Abid, Hafiz; lldb-commits@lists.llvm.org
Subject: RE: [Lldb-commits] Patch for fixing FDE indexing when scan debug_info 
section

Done. I have also added a little change which allow to use debug_info section 
when eh_frame is absent. This case really can take place on some platforms.

Thanks,
Tatyana

From: Abid, Hafiz [mailto:hafiz_a...@mentor.com]
Sent: Tuesday, 23 May, 2017 3:31 PM
To: Tatyana Krasnukha 
mailto:tatyana.krasnu...@synopsys.com>>; 
lldb-commits@lists.llvm.org
Subject: Re: [Lldb-commits] Patch for fixing FDE indexing when scan debug_info 
section

It looks ok to me. Please put the differences of .eh_frame and
.debug_frame that you described below in code comments too.?

Thanks,
Abid




From: lldb-commits 
mailto:lldb-commits-boun...@lists.llvm.org>>
 on behalf of Tatyana Krasnukha via lldb-commits 
mailto:lldb-commits@lists.llvm.org>>
Sent: Thursday, May 18, 2017 9:37 PM
To: lldb-commits@lists.llvm.org
Subject: [Lldb-commits] Patch for fixing FDE indexing when scan debug_info 
section

Fix FDE indexing while scan debug_info section.

There are some differences between eh_frame and debug_frame formats that are 
not considered by DWARFCallFrameInfo::GetFDEIndex.
An FDE entry contains CIE_pointer in debug_frame in same place as cie_id in 
eh_frame. As described in dwarf 
standard
 (section 6.4.1),
CIE_pointer is an "offset into the .debug_frame section". So, variable 
cie_offset should be equal cie_id for debug_frame.
FDE entries with zeroth CIE pointer (which is actually placed in cie_id 
variable) shouldn't be ignored also.

I had same issue as described here 
http://lists.llvm.org/pipermail/lldb-dev/2014-October/005520.html
 , and these changes have fixed it for me (with "m_is_eh_frame" set to false, 
of course).

Tatyana Krasnukha
Software Engineer, Sr. I, Solutions Group, Synopsys Inc.
w +7.812.408.7463 | m +7 981 757-4491 | 
taty...@synopsys.com

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


[Lldb-commits] [PATCH] D33283: RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false

2017-05-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Thanks for the explanation. I'll continue the discussion about the conditional 
breakpoint thingy on bug #33164, which I've just filed.


https://reviews.llvm.org/D33283



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


[Lldb-commits] [PATCH] D32930: New framework for lldb client-server communication tests.

2017-05-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Getting really close now. However, the debug trap issue is still not resolved. 
And we still have to figure out how to make sure the tests don't blow up on 
platforms that don't support debugging via lldb-server (i.e., anything except 
linux, android, netbsd). One option would be to just disable the inclusion of 
the whole subfolder at cmake level. Another is to stop gtest from running them 
by prefixing their names with DISABLED_. The usual solution for that is to 
define a helper macro like

  #if defined(__linux__) || defined(__NetBSD__)
  #define LLGS_TEST(x) x
  #else
  #define LLGS_TEST(x) DISABLED_ ## x
  #endif

I'd tend towards the cmake option.




Comment at: unittests/tools/lldb-server/inferior/thread_inferior.cpp:32
+
+  LLVM_BUILTIN_DEBUGTRAP;
+  delay.store(false);

The debug trap issue is not resolved yet, as it evaluates to nothing on gcc. I 
believe the consensus was to go with null pointer dereference, at least for 
now. I am not sure how good of an idea is to use llvm headers in the test 
inferiors, but we can use LLVM_BUILTIN_TRAP macro for that purpose, at least 
until it starts causing us problems.



Comment at: unittests/tools/lldb-server/tests/TestClient.cpp:240
+  struct stat info;
+  if (stat(log_directory, &info) != 0 || !(info.st_mode & S_IFDIR)) {
+GTEST_LOG_(WARNING) << "Cannot access log directory: " << log_directory;

this is very posix-y. Please use `llvm::sys::fs::is_directory` instead. (I may 
not have gotten the namespace right).


https://reviews.llvm.org/D32930



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


[Lldb-commits] [PATCH] D32149: Correct handling NetBSD core(5) files with threads

2017-05-25 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Affirmative. Tests should go in together with the feature they are testing.


Repository:
  rL LLVM

https://reviews.llvm.org/D32149



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


[Lldb-commits] [lldb] r303847 - Fix FDE indexing while scan debug_info section.

2017-05-25 Thread Hafiz Abid Qadeer via lldb-commits
Author: abidh
Date: Thu May 25 05:21:29 2017
New Revision: 303847

URL: http://llvm.org/viewvc/llvm-project?rev=303847&view=rev
Log:
Fix FDE indexing while scan debug_info section.

There are some differences between eh_frame and debug_frame formats that
are not considered by DWARFCallFrameInfo::GetFDEIndex. An FDE entry
contains CIE_pointer in debug_frame in same place as cie_id in eh_frame.
As described in dwarf standard (section 6.4.1), CIE_pointer is an
"offset into the .debug_frame section". So, variable cie_offset should
be equal cie_id for debug_frame.

FDE entries with zeroth CIE pointer (which is actually placed in cie_id
variable) shouldn't be ignored also.

I have also added a little change which allow to use debug_info section
when eh_frame is absent. This case really can take place on some platforms.

Patch from tatyana-krasnukha.
https://reviews.llvm.org/D33504


Modified:
lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp
lldb/trunk/source/Symbol/UnwindTable.cpp

Modified: lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp?rev=303847&r1=303846&r2=303847&view=diff
==
--- lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp (original)
+++ lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp Thu May 25 05:21:29 2017
@@ -461,11 +461,25 @@ void DWARFCallFrameInfo::GetFDEIndex() {
   m_fde_index_initialized = true;
   return;
 }
+
+// An FDE entry contains CIE_pointer in debug_frame in same place as cie_id
+// in eh_frame. CIE_pointer is an offset into the .debug_frame section.
+// So, variable cie_offset should be equal cie_id for debug_frame.
+// FDE entries with cie_id == 0 shouldn't be ignored for it.
+if ((cie_id == 0 && m_is_eh_frame) || cie_id == UINT32_MAX || len == 0) {
+  m_cie_map[current_entry] = ParseCIE(current_entry);
+  offset = next_entry;
+  continue;
+}
+
+if (!m_is_eh_frame)
+  cie_offset = cie_id;
+
 if (cie_offset > m_cfi_data.GetByteSize()) {
-  Host::SystemLog(
-  Host::eSystemLogError,
-  "error: Invalid cie offset of 0x%x found in cie/fde at 0x%x\n",
-  cie_offset, current_entry);
+  Host::SystemLog(Host::eSystemLogError,
+  "error: Invalid cie offset of 0x%x "
+  "found in cie/fde at 0x%x\n",
+  cie_offset, current_entry);
   // Don't trust anything in this eh_frame section if we find blatantly
   // invalid data.
   m_fde_index.Clear();
@@ -473,12 +487,6 @@ void DWARFCallFrameInfo::GetFDEIndex() {
   return;
 }
 
-if (cie_id == 0 || cie_id == UINT32_MAX || len == 0) {
-  m_cie_map[current_entry] = ParseCIE(current_entry);
-  offset = next_entry;
-  continue;
-}
-
 const CIE *cie = GetCIE(cie_offset);
 if (cie) {
   const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress();
@@ -531,7 +539,8 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan
 cie_offset = m_cfi_data.GetU32(&offset);
   }
 
-  assert(cie_offset != 0 && cie_offset != UINT32_MAX);
+  // FDE entries with zero cie_offset may occur for debug_frame.
+  assert(!(m_is_eh_frame && 0 == cie_offset) && cie_offset != UINT32_MAX);
 
   // Translate the CIE_id from the eh_frame format, which
   // is relative to the FDE offset, into a __eh_frame section

Modified: lldb/trunk/source/Symbol/UnwindTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=303847&r1=303846&r2=303847&view=diff
==
--- lldb/trunk/source/Symbol/UnwindTable.cpp (original)
+++ lldb/trunk/source/Symbol/UnwindTable.cpp Thu May 25 05:21:29 2017
@@ -51,6 +51,13 @@ void UnwindTable::Initialize() {
 if (sect.get()) {
   m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect,
  eRegisterKindEHFrame, true));
+} else {
+  // Try to find .debug_frame section if .eh_frame doesn't exist.
+  sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
+  if (sect.get()) {
+m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect,
+   eRegisterKindDWARF, false));
+  }
 }
 sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
 if (sect.get()) {


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


[Lldb-commits] [PATCH] D33283: RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false

2017-05-25 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303848: Recommit "RunThreadPlan: Fix halting logic in 
IgnoreBreakpoints = false" (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D33283?vs=100099&id=100221#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33283

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/main.cpp
  lldb/trunk/source/Target/Process.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
@@ -18,26 +18,19 @@
 class UnwindFromExpressionTest(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
+main_spec = lldb.SBFileSpec("main.cpp", False)
 
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-
-@add_test_categories(['pyapi'])
-@expectedFailureAll(oslist=["windows"])
-def test_unwind_expression(self):
-"""Test unwinding from an expression."""
+def build_and_run_to_bkpt(self):
 self.build()
 
 exe = os.path.join(os.getcwd(), "a.out")
 
 target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
 # Create the breakpoint.
-main_spec = lldb.SBFileSpec("main.cpp", False)
 breakpoint = target.BreakpointCreateBySourceRegex(
-"// Set a breakpoint here to get started", main_spec)
+"// Set a breakpoint here to get started", self.main_spec)
 self.assertTrue(breakpoint, VALID_BREAKPOINT)
 
 # Launch the process, and do not stop at the entry point.
@@ -52,24 +45,60 @@
   "instead the actual state is: '%s'" %
   lldbutil.state_type_to_str(process.GetState()))
 
-thread = lldbutil.get_one_thread_stopped_at_breakpoint(
+self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
 process, breakpoint)
 self.assertIsNotNone(
-thread, "Expected one thread to be stopped at the breakpoint")
+self.thread, "Expected one thread to be stopped at the breakpoint")
+
+# Next set a breakpoint in this function, set up Expression options to stop on
+# breakpoint hits, and call the function.
+self.fun_bkpt = self.target().BreakpointCreateBySourceRegex(
+"// Stop inside the function here.", self.main_spec)
+self.assertTrue(self.fun_bkpt, VALID_BREAKPOINT)
+
+
+@no_debug_info_test
+@expectedFailureAll(bugnumber="llvm.org/pr33164")
+def test_conditional_bktp(self):
+"""
+Test conditional breakpoint handling in the IgnoreBreakpoints = False case
+"""
+self.build_and_run_to_bkpt()
+
+self.fun_bkpt.SetCondition("0") # Should not get hit
+options = lldb.SBExpressionOptions()
+options.SetIgnoreBreakpoints(False)
+options.SetUnwindOnError(False)
+
+main_frame = self.thread.GetFrameAtIndex(0)
+val = main_frame.EvaluateExpression("second_function(47)", options)
+self.assertTrue(
+val.GetError().Success(),
+"We did complete the execution.")
+self.assertEquals(47, val.GetValueAsSigned())
 
+
+@add_test_categories(['pyapi'])
+@expectedFailureAll(oslist=["windows"])
+def test_unwind_expression(self):
+"""Test unwinding from an expression."""
+self.build_and_run_to_bkpt()
+
+# Run test with varying one thread timeouts to also test the halting
+# logic in the IgnoreBreakpoints = False case
+self.do_unwind_test(self.thread, self.fun_bkpt, 1000)
+self.do_unwind_test(self.thread, self.fun_bkpt, 10)
+
+def do_unwind_test(self, thread, bkpt, timeout):
 #
 # Use Python API to evaluate expressions while stopped in a stack frame.
 #
 main_frame = thread.GetFrameAtIndex(0)
 
-# Next set a breakpoint in this function, set up Expression options to stop on
-# breakpoint hits, and call the function.
-fun_bkpt = target.BreakpointCreateBySourceRegex(
-"// Stop inside the function here.", main_spec)
-self.assertTrue(fun_bkpt, VALID_BREAKPOINT)
 options = lldb.SBExpressionOptions()
 options.SetIgnoreBreakpoints(False)
 options.SetUnwindOnError(False)
+options.SetOneThreadTimeoutInMicroSeconds(timeout)
 
 val = main_frame.EvaluateExpression("a_function_to_call()", options)
 
@@ -82,7 +111,7 @@
 "And the reason was right.")
 
 thread = lldbutil.get_one_t

[Lldb-commits] [lldb] r303848 - Recommit "RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false"

2017-05-25 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May 25 05:50:06 2017
New Revision: 303848

URL: http://llvm.org/viewvc/llvm-project?rev=303848&view=rev
Log:
Recommit "RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false"

This is a resubmit of r303732, which was reverted due to a regression.

The original patch caused a regression in TestLoadUnload, which has only showed
up when running the remote test suite. The problem there was that we interrupted
the target just as it has hit the rendezvous breakpoint in the dlopen call. This
meant that the stop reason was set to "breakpoint" even though the event would
not have been broadcast if we had not stopped the process. I fix this by
checking StopInfo->ShouldNotify() before stopping.

I also add a new test for the handling of conditional breakpoints in
expressions, which I noticed to be broken (pr33164)

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/main.cpp
lldb/trunk/source/Target/Process.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py?rev=303848&r1=303847&r2=303848&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
 Thu May 25 05:50:06 2017
@@ -18,15 +18,9 @@ from lldbsuite.test import lldbutil
 class UnwindFromExpressionTest(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
+main_spec = lldb.SBFileSpec("main.cpp", False)
 
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-
-@add_test_categories(['pyapi'])
-@expectedFailureAll(oslist=["windows"])
-def test_unwind_expression(self):
-"""Test unwinding from an expression."""
+def build_and_run_to_bkpt(self):
 self.build()
 
 exe = os.path.join(os.getcwd(), "a.out")
@@ -35,9 +29,8 @@ class UnwindFromExpressionTest(TestBase)
 self.assertTrue(target, VALID_TARGET)
 
 # Create the breakpoint.
-main_spec = lldb.SBFileSpec("main.cpp", False)
 breakpoint = target.BreakpointCreateBySourceRegex(
-"// Set a breakpoint here to get started", main_spec)
+"// Set a breakpoint here to get started", self.main_spec)
 self.assertTrue(breakpoint, VALID_BREAKPOINT)
 
 # Launch the process, and do not stop at the entry point.
@@ -52,24 +45,60 @@ class UnwindFromExpressionTest(TestBase)
   "instead the actual state is: '%s'" %
   lldbutil.state_type_to_str(process.GetState()))
 
-thread = lldbutil.get_one_thread_stopped_at_breakpoint(
+self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
 process, breakpoint)
 self.assertIsNotNone(
-thread, "Expected one thread to be stopped at the breakpoint")
+self.thread, "Expected one thread to be stopped at the breakpoint")
+
+# Next set a breakpoint in this function, set up Expression options to 
stop on
+# breakpoint hits, and call the function.
+self.fun_bkpt = self.target().BreakpointCreateBySourceRegex(
+"// Stop inside the function here.", self.main_spec)
+self.assertTrue(self.fun_bkpt, VALID_BREAKPOINT)
+
+
+@no_debug_info_test
+@expectedFailureAll(bugnumber="llvm.org/pr33164")
+def test_conditional_bktp(self):
+"""
+Test conditional breakpoint handling in the IgnoreBreakpoints = False 
case
+"""
+self.build_and_run_to_bkpt()
+
+self.fun_bkpt.SetCondition("0") # Should not get hit
+options = lldb.SBExpressionOptions()
+options.SetIgnoreBreakpoints(False)
+options.SetUnwindOnError(False)
+
+main_frame = self.thread.GetFrameAtIndex(0)
+val = main_frame.EvaluateExpression("second_function(47)", options)
+self.assertTrue(
+val.GetError().Success(),
+"We did complete the execution.")
+self.assertEquals(47, val.GetValueAsSigned())
 
+
+@add_test_categories(['pyapi'])
+@expectedFailureAll(oslist=["windows"])
+def test_unwind_expression(self):
+"""Test unwinding from an expression."""
+self.build_and_run_to_bkpt()
+
+# Run test with varying one thread timeouts to also test the halting
+# logic in the IgnoreBreakpoints = False case
+self.do_unwind_test(self.thread, self.fun_bkpt, 1000)
+self.do_unwind_test(self.thread, self.fun_bk

[Lldb-commits] [lldb] r303854 - Revert "Fix FDE indexing while scan debug_info section."

2017-05-25 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May 25 08:13:12 2017
New Revision: 303854

URL: http://llvm.org/viewvc/llvm-project?rev=303854&view=rev
Log:
Revert "Fix FDE indexing while scan debug_info section."

This reverts commit r303847 as it introduces a number of regressions.
Investigation has showed that we are parsing the CIE entries in the
debug_frame section incorrectly -- we are parsing them the same way as
eh_frame, but the entries in debug_frame have a couple of extra entries
which have not been taken into account.

Modified:
lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp
lldb/trunk/source/Symbol/UnwindTable.cpp

Modified: lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp?rev=303854&r1=303853&r2=303854&view=diff
==
--- lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp (original)
+++ lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp Thu May 25 08:13:12 2017
@@ -461,25 +461,11 @@ void DWARFCallFrameInfo::GetFDEIndex() {
   m_fde_index_initialized = true;
   return;
 }
-
-// An FDE entry contains CIE_pointer in debug_frame in same place as cie_id
-// in eh_frame. CIE_pointer is an offset into the .debug_frame section.
-// So, variable cie_offset should be equal cie_id for debug_frame.
-// FDE entries with cie_id == 0 shouldn't be ignored for it.
-if ((cie_id == 0 && m_is_eh_frame) || cie_id == UINT32_MAX || len == 0) {
-  m_cie_map[current_entry] = ParseCIE(current_entry);
-  offset = next_entry;
-  continue;
-}
-
-if (!m_is_eh_frame)
-  cie_offset = cie_id;
-
 if (cie_offset > m_cfi_data.GetByteSize()) {
-  Host::SystemLog(Host::eSystemLogError,
-  "error: Invalid cie offset of 0x%x "
-  "found in cie/fde at 0x%x\n",
-  cie_offset, current_entry);
+  Host::SystemLog(
+  Host::eSystemLogError,
+  "error: Invalid cie offset of 0x%x found in cie/fde at 0x%x\n",
+  cie_offset, current_entry);
   // Don't trust anything in this eh_frame section if we find blatantly
   // invalid data.
   m_fde_index.Clear();
@@ -487,6 +473,12 @@ void DWARFCallFrameInfo::GetFDEIndex() {
   return;
 }
 
+if (cie_id == 0 || cie_id == UINT32_MAX || len == 0) {
+  m_cie_map[current_entry] = ParseCIE(current_entry);
+  offset = next_entry;
+  continue;
+}
+
 const CIE *cie = GetCIE(cie_offset);
 if (cie) {
   const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress();
@@ -539,8 +531,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan
 cie_offset = m_cfi_data.GetU32(&offset);
   }
 
-  // FDE entries with zero cie_offset may occur for debug_frame.
-  assert(!(m_is_eh_frame && 0 == cie_offset) && cie_offset != UINT32_MAX);
+  assert(cie_offset != 0 && cie_offset != UINT32_MAX);
 
   // Translate the CIE_id from the eh_frame format, which
   // is relative to the FDE offset, into a __eh_frame section

Modified: lldb/trunk/source/Symbol/UnwindTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=303854&r1=303853&r2=303854&view=diff
==
--- lldb/trunk/source/Symbol/UnwindTable.cpp (original)
+++ lldb/trunk/source/Symbol/UnwindTable.cpp Thu May 25 08:13:12 2017
@@ -51,13 +51,6 @@ void UnwindTable::Initialize() {
 if (sect.get()) {
   m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect,
  eRegisterKindEHFrame, true));
-} else {
-  // Try to find .debug_frame section if .eh_frame doesn't exist.
-  sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
-  if (sect.get()) {
-m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect,
-   eRegisterKindDWARF, false));
-  }
 }
 sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
 if (sect.get()) {


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


Re: [Lldb-commits] [PATCH] D33504: Fix FDE indexing while scan debug_info section

2017-05-25 Thread Pavel Labath via lldb-commits
+lldb-commits

Yes, that is certainly a viable approach. If there is a subset of
dwarf that we are capable of parsing correctly then it would be great
to enable that.

On 25 May 2017 at 16:46, Tatyana Krasnukha
 wrote:
> This binary uses DWARF 4, that introduces two additional fields in CIE - 
> address_size and segment_size just after augmentation field. That’s why 
> values are parsed  incorrectly.
> May be we should discard unwind plan if there is unsupported dwarf version 
> for now?
>
> Thanks,
> Tatyana
>
> -Original Message-
> From: Pavel Labath [mailto:lab...@google.com]
> Sent: Thursday, 25 May, 2017 5:45 PM
> To: tatyana.krasnu...@synopsys.com
> Subject: Re: [PATCH] D33504: Fix FDE indexing while scan debug_info section
>
> Hey, try the attached binary for size.
>
> It was generated from the source file in 
> lldb/test/testcases/functionalities/breakpoint/breakpoint_conditions/main.c,
> while targetting android arm64.
>
> You should be able to create a test binary for yourself locally (assuming 
> you're on linux) like this:
> $ cat a.c
> int a(char *x) { return *x; }
>
> int f() {
>   return a(0);
> }
>
> int g() {
>   return 1+f();
> }
>
> int _start() { return 2+g(); }
>
> $ clang -fno-exceptions -fno-unwind-tables -g a.c -nostdlib
>
> If you debug the binary with and stop in the ParseCIE function, you will see 
> that it parses the entry incorrectly:
> Process 39688 stopped
> * thread #1, name = 'lldb', stop reason = step over
> frame #0: 0x7074bb53
> liblldb.so.5`lldb_private::DWARFCallFrameInfo::ParseCIE(this=0x00613280,
> cie_offset=0) at DWARFCallFrameInfo.cpp:303
>300cie_sp->data_align = (int32_t)m_cfi_data.GetSLEB128(&offset);
>301cie_sp->return_addr_reg_num = m_cfi_data.GetU8(&offset);
>302
> -> 303if (cie_sp->augmentation[0]) {
>304  // Get the length of the eh_frame augmentation data
>305  // which starts with a ULEB128 length in bytes
>306  const size_t aug_data_len = 
> (size_t)m_cfi_data.GetULEB128(&offset);
>
> (lldb) fr var cie_sp._M_ptr[0]
> (lldb_private::DWARFCallFrameInfo::CIE) cie_sp._M_ptr[0] = {
>   cie_offset = 0
>   version = '\x04'
>   augmentation = ""
>   code_align = 8 <== wrong
>   data_align = 0 <== wrong
>   return_addr_reg_num = 1 <= wrong
>   inst_offset = 0
>   inst_length = 0
>   ptr_encoding = '\0'
>   lsda_addr_encoding = '\xff'
>   personality_loc = 18446744073709551615
>   initial_row = {
> m_offset = 0
> m_cfa_value = {
>   m_type = unspecified
>   m_value = {
> reg = (reg_num = 0, offset = 0)
> expr = (opcodes = 0x, length = 0)
>   }
> }
> m_register_locations = size=0 {}
>   }
> }
>
> Correct parsing can be seen by running
> $ llvm-dwarfdump a.out
> .
> .debug_frame contents:
>
>  0014  CIE
>   Version:   4
>   Augmentation:  ""
>   Address size:  8  <=== this shows up in code_align
>   Segment desc size: 0 <=== this shows up in data_align
>   Code alignment factor: 1 <=== this shows up in return_addr_reg_num
>   Data alignment factor: -8
>   Return address column: 16
>
>   DW_CFA_def_cfa: reg7 +8
>   DW_CFA_offset: reg16 -8
>   DW_CFA_nop:
>   DW_CFA_nop:
>   DW_CFA_nop:
>   DW_CFA_nop:
>
> 0018 001c  FDE cie= pc=004000b0...004000c1
>   DW_CFA_advance_loc: 1
>   DW_CFA_def_cfa_offset: +16
>   DW_CFA_offset: reg6 -16
>   DW_CFA_advance_loc: 3
>   DW_CFA_def_cfa_register: reg6
> 
>
>
> Interestingly, in the x86_64 linux case, lldb still manages to unwind 
> correctly despite the bad parsing.
>
>
>
>
> On 25 May 2017 at 14:40, Tatyana Krasnukha via Phabricator 
>  wrote:
>> tatyana-krasnukha added a comment.
>>
>> Yes, give those binaries, please.
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_
>> D33504&d=DwIBaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4
>> vlymPiSt0Wl0jegw&m=Ze6ANiK7goV6lSPJcY8QglIJ_tZC0gXeUuqpQ8n4K40&s=1vfSh
>> WELC8pd8-DQmAeW3QJDQgdMAJvn905_U-jVphM&e=
>>
>>
>>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r303907 - Fix bug #28898

2017-05-25 Thread Kamil Rytarowski via lldb-commits
Author: kamil
Date: Thu May 25 15:12:30 2017
New Revision: 303907

URL: http://llvm.org/viewvc/llvm-project?rev=303907&view=rev
Log:
Fix bug #28898
lldb: libedit produces garbled, unusable input on Linux

Apply patch from Christos Zoulas, upstream libedit developer.
It has been tested on NetBSD/amd64.

New code supports combination of wide libedit and disabled
LLDB_EDITLINE_USE_WCHAR, which was the popular case on Linux
systems.

Modified:
lldb/trunk/include/lldb/Host/Editline.h
lldb/trunk/source/Host/common/Editline.cpp

Modified: lldb/trunk/include/lldb/Host/Editline.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=303907&r1=303906&r2=303907&view=diff
==
--- lldb/trunk/include/lldb/Host/Editline.h (original)
+++ lldb/trunk/include/lldb/Host/Editline.h Thu May 25 15:12:30 2017
@@ -82,8 +82,14 @@ using EditLineStringStreamType = std::st
 using EditLineCharType = char;
 #endif
 
+#ifdef EL_CLIENTDATA   /* editline with wide support + wide char read function 
*/
+using EditLineGetCharType = wchar_t;
+#else
+using EditLineGetCharType = char;
+#endif
+
 typedef int (*EditlineGetCharCallbackType)(::EditLine *editline,
-   EditLineCharType *c);
+   EditLineGetCharType *c);
 typedef unsigned char (*EditlineCommandCallbackType)(::EditLine *editline,
  int ch);
 typedef const char *(*EditlinePromptCallbackType)(::EditLine *editline);
@@ -270,7 +276,7 @@ private:
 
   /// Character reading implementation for EditLine that supports our 
multi-line
   /// editing trickery.
-  int GetCharacter(EditLineCharType *c);
+  int GetCharacter(EditLineGetCharType *c);
 
   /// Prompt implementation for EditLine.
   const char *Prompt();
@@ -323,7 +329,7 @@ private:
   /// single or multi-line editing.
   void ConfigureEditor(bool multiline);
 
-  bool CompleteCharacter(char ch, EditLineCharType &out);
+  bool CompleteCharacter(char ch, EditLineGetCharType &out);
 
 private:
 #if LLDB_EDITLINE_USE_WCHAR

Modified: lldb/trunk/source/Host/common/Editline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=303907&r1=303906&r2=303907&view=diff
==
--- lldb/trunk/source/Host/common/Editline.cpp (original)
+++ lldb/trunk/source/Host/common/Editline.cpp Thu May 25 15:12:30 2017
@@ -474,7 +474,7 @@ unsigned char Editline::RecallHistory(bo
   return CC_NEWLINE;
 }
 
-int Editline::GetCharacter(EditLineCharType *c) {
+int Editline::GetCharacter(EditLineGetCharType *c) {
   const LineInfoW *info = el_wline(m_editline);
 
   // Paint a faint version of the desired prompt over the version libedit draws
@@ -969,7 +969,7 @@ void Editline::ConfigureEditor(bool mult
  }));
 
   el_wset(m_editline, EL_GETCFN, (EditlineGetCharCallbackType)([](
- EditLine *editline, EditLineCharType *c) {
+ EditLine *editline, EditLineGetCharType 
*c) {
 return Editline::InstanceFor(editline)->GetCharacter(c);
   }));
 
@@ -1360,12 +1360,12 @@ void Editline::PrintAsync(Stream *stream
   }
 }
 
-bool Editline::CompleteCharacter(char ch, EditLineCharType &out) {
+bool Editline::CompleteCharacter(char ch, EditLineGetCharType &out) {
 #if !LLDB_EDITLINE_USE_WCHAR
   if (ch == (char)EOF)
 return false;
 
-  out = ch;
+  out = (unsigned char)ch;
   return true;
 #else
   std::codecvt_utf8 cvt;


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


[Lldb-commits] [PATCH] D32930: New framework for lldb client-server communication tests.

2017-05-25 Thread Jason Majors via Phabricator via lldb-commits
jmajors updated this revision to Diff 100287.
jmajors added a comment.

Make inferior break more portable.
Restrict tests to running on Linux, BSD, or Android systems.


https://reviews.llvm.org/D32930

Files:
  unittests/CMakeLists.txt
  unittests/tools/CMakeLists.txt
  unittests/tools/lldb-server/CMakeLists.txt
  unittests/tools/lldb-server/inferior/thread_inferior.cpp
  unittests/tools/lldb-server/tests/CMakeLists.txt
  unittests/tools/lldb-server/tests/MessageObjects.cpp
  unittests/tools/lldb-server/tests/MessageObjects.h
  unittests/tools/lldb-server/tests/TestClient.cpp
  unittests/tools/lldb-server/tests/TestClient.h
  unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp

Index: unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp
===
--- /dev/null
+++ unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp
@@ -0,0 +1,58 @@
+//===-- ThreadsInJstopinfoTest.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestClient.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llgs_tests;
+
+class ThreadsInJstopinfoTest : public ::testing::Test {
+protected:
+  virtual void SetUp() { TestClient::Initialize(); }
+};
+
+TEST_F(ThreadsInJstopinfoTest, TestStopReplyContainsThreadPcsLlgs) {
+  std::vector inferior_args;
+  // This inferior spawns N threads, then forces a break.
+  inferior_args.push_back(THREAD_INFERIOR);
+  inferior_args.push_back("4");
+
+  auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
+
+  TestClient client(test_info->name(), test_info->test_case_name());
+  ASSERT_TRUE(client.StartDebugger());
+  ASSERT_TRUE(client.SetInferior(inferior_args));
+  ASSERT_TRUE(client.ListThreadsInStopReply());
+  ASSERT_TRUE(client.ContinueAll());
+  unsigned int pc_reg = client.GetPcRegisterId();
+  ASSERT_NE(pc_reg, UINT_MAX);
+
+  auto jthreads_info = client.GetJThreadsInfo();
+  ASSERT_TRUE(jthreads_info);
+
+  auto stop_reply = client.GetLatestStopReply();
+  auto stop_reply_pcs = stop_reply.GetThreadPcs();
+  auto thread_infos = jthreads_info->GetThreadInfos();
+  ASSERT_EQ(stop_reply_pcs.size(), thread_infos.size())
+  << "Thread count mismatch.";
+
+  for (auto stop_reply_pc : stop_reply_pcs) {
+unsigned long tid = stop_reply_pc.first;
+ASSERT_TRUE(thread_infos.find(tid) != thread_infos.end())
+<< "Thread ID: " << tid << " not in JThreadsInfo.";
+uint64_t pc_value;
+ASSERT_TRUE(thread_infos[tid].ReadRegisterAsUint64(pc_reg, pc_value))
+<< "Failure reading ThreadInfo register " << pc_reg;
+ASSERT_EQ(stop_reply_pcs[tid], pc_value)
+<< "Mismatched PC for thread: " << tid;
+  }
+
+  ASSERT_TRUE(client.StopDebugger());
+}
Index: unittests/tools/lldb-server/tests/TestClient.h
===
--- /dev/null
+++ unittests/tools/lldb-server/tests/TestClient.h
@@ -0,0 +1,61 @@
+//===-- TestClient.h *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MessageObjects.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Target/ProcessLaunchInfo.h"
+#include "llvm/ADT/Optional.h"
+#include 
+#include 
+
+namespace llgs_tests {
+// TODO: Make the test client an abstract base class, with different children
+// for different types of connections: llgs v. debugserver
+class TestClient
+: public lldb_private::process_gdb_remote::GDBRemoteCommunicationClient {
+public:
+  static void Initialize();
+  TestClient(const std::string &test_name, const std::string &test_case_name);
+  virtual ~TestClient();
+  LLVM_NODISCARD bool StartDebugger();
+  LLVM_NODISCARD bool StopDebugger();
+  LLVM_NODISCARD bool SetInferior(llvm::ArrayRef inferior_args);
+  LLVM_NODISCARD bool ListThreadsInStopReply();
+  LLVM_NODISCARD bool SetBreakpoint(unsigned long address);
+  LLVM_NODISCARD bool ContinueAll();
+  LLVM_NODISCARD bool ContinueThread(unsigned long thread_id);
+  const ProcessInfo &GetProcessInfo();
+  llvm::Optional GetJThreadsInfo();
+  const StopReply &GetLatestStopReply();
+  LLVM_NODISCARD bool SendMessage(llvm::StringRef message);
+  LLVM_NODISCARD bool SendMessage(llvm::StringRef message,
+  std::string &response_string);
+  LLVM_NODISCARD bool SendMessage(llvm::StringRef message,
+  std::string &response_string,
+

[Lldb-commits] [PATCH] D32930: New framework for lldb client-server communication tests.

2017-05-25 Thread Jason Majors via Phabricator via lldb-commits
jmajors updated this revision to Diff 100288.
jmajors marked an inline comment as done.
jmajors added a comment.

Made directory test more portable.


https://reviews.llvm.org/D32930

Files:
  unittests/CMakeLists.txt
  unittests/tools/CMakeLists.txt
  unittests/tools/lldb-server/CMakeLists.txt
  unittests/tools/lldb-server/inferior/thread_inferior.cpp
  unittests/tools/lldb-server/tests/CMakeLists.txt
  unittests/tools/lldb-server/tests/MessageObjects.cpp
  unittests/tools/lldb-server/tests/MessageObjects.h
  unittests/tools/lldb-server/tests/TestClient.cpp
  unittests/tools/lldb-server/tests/TestClient.h
  unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp

Index: unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp
===
--- /dev/null
+++ unittests/tools/lldb-server/tests/ThreadIdsInJstopinfoTest.cpp
@@ -0,0 +1,58 @@
+//===-- ThreadsInJstopinfoTest.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestClient.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llgs_tests;
+
+class ThreadsInJstopinfoTest : public ::testing::Test {
+protected:
+  virtual void SetUp() { TestClient::Initialize(); }
+};
+
+TEST_F(ThreadsInJstopinfoTest, TestStopReplyContainsThreadPcsLlgs) {
+  std::vector inferior_args;
+  // This inferior spawns N threads, then forces a break.
+  inferior_args.push_back(THREAD_INFERIOR);
+  inferior_args.push_back("4");
+
+  auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
+
+  TestClient client(test_info->name(), test_info->test_case_name());
+  ASSERT_TRUE(client.StartDebugger());
+  ASSERT_TRUE(client.SetInferior(inferior_args));
+  ASSERT_TRUE(client.ListThreadsInStopReply());
+  ASSERT_TRUE(client.ContinueAll());
+  unsigned int pc_reg = client.GetPcRegisterId();
+  ASSERT_NE(pc_reg, UINT_MAX);
+
+  auto jthreads_info = client.GetJThreadsInfo();
+  ASSERT_TRUE(jthreads_info);
+
+  auto stop_reply = client.GetLatestStopReply();
+  auto stop_reply_pcs = stop_reply.GetThreadPcs();
+  auto thread_infos = jthreads_info->GetThreadInfos();
+  ASSERT_EQ(stop_reply_pcs.size(), thread_infos.size())
+  << "Thread count mismatch.";
+
+  for (auto stop_reply_pc : stop_reply_pcs) {
+unsigned long tid = stop_reply_pc.first;
+ASSERT_TRUE(thread_infos.find(tid) != thread_infos.end())
+<< "Thread ID: " << tid << " not in JThreadsInfo.";
+uint64_t pc_value;
+ASSERT_TRUE(thread_infos[tid].ReadRegisterAsUint64(pc_reg, pc_value))
+<< "Failure reading ThreadInfo register " << pc_reg;
+ASSERT_EQ(stop_reply_pcs[tid], pc_value)
+<< "Mismatched PC for thread: " << tid;
+  }
+
+  ASSERT_TRUE(client.StopDebugger());
+}
Index: unittests/tools/lldb-server/tests/TestClient.h
===
--- /dev/null
+++ unittests/tools/lldb-server/tests/TestClient.h
@@ -0,0 +1,61 @@
+//===-- TestClient.h *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MessageObjects.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Target/ProcessLaunchInfo.h"
+#include "llvm/ADT/Optional.h"
+#include 
+#include 
+
+namespace llgs_tests {
+// TODO: Make the test client an abstract base class, with different children
+// for different types of connections: llgs v. debugserver
+class TestClient
+: public lldb_private::process_gdb_remote::GDBRemoteCommunicationClient {
+public:
+  static void Initialize();
+  TestClient(const std::string &test_name, const std::string &test_case_name);
+  virtual ~TestClient();
+  LLVM_NODISCARD bool StartDebugger();
+  LLVM_NODISCARD bool StopDebugger();
+  LLVM_NODISCARD bool SetInferior(llvm::ArrayRef inferior_args);
+  LLVM_NODISCARD bool ListThreadsInStopReply();
+  LLVM_NODISCARD bool SetBreakpoint(unsigned long address);
+  LLVM_NODISCARD bool ContinueAll();
+  LLVM_NODISCARD bool ContinueThread(unsigned long thread_id);
+  const ProcessInfo &GetProcessInfo();
+  llvm::Optional GetJThreadsInfo();
+  const StopReply &GetLatestStopReply();
+  LLVM_NODISCARD bool SendMessage(llvm::StringRef message);
+  LLVM_NODISCARD bool SendMessage(llvm::StringRef message,
+  std::string &response_string);
+  LLVM_NODISCARD bool SendMessage(llvm::StringRef message,
+  std::string &response_string,
+   

Re: [Lldb-commits] [PATCH] D33504: Fix FDE indexing while scan debug_info section

2017-05-25 Thread Robinson, Paul via lldb-commits
IANA lldb developer, but I should think lldb would want to understand a 
DWARF 4 .debug_frame section.  (And it didn't change in DWARF 5, either!)
--paulr

> -Original Message-
> From: lldb-commits [mailto:lldb-commits-boun...@lists.llvm.org] On Behalf
> Of Pavel Labath via lldb-commits
> Sent: Thursday, May 25, 2017 9:17 AM
> To: Tatyana Krasnukha
> Cc: lldb-commits@lists.llvm.org
> Subject: Re: [Lldb-commits] [PATCH] D33504: Fix FDE indexing while scan
> debug_info section
> 
> +lldb-commits
> 
> Yes, that is certainly a viable approach. If there is a subset of
> dwarf that we are capable of parsing correctly then it would be great
> to enable that.
> 
> On 25 May 2017 at 16:46, Tatyana Krasnukha
>  wrote:
> > This binary uses DWARF 4, that introduces two additional fields in CIE -
> address_size and segment_size just after augmentation field. That’s why
> values are parsed  incorrectly.
> > May be we should discard unwind plan if there is unsupported dwarf
> version for now?
> >
> > Thanks,
> > Tatyana
> >
> > -Original Message-
> > From: Pavel Labath [mailto:lab...@google.com]
> > Sent: Thursday, 25 May, 2017 5:45 PM
> > To: tatyana.krasnu...@synopsys.com
> > Subject: Re: [PATCH] D33504: Fix FDE indexing while scan debug_info
> section
> >
> > Hey, try the attached binary for size.
> >
> > It was generated from the source file in
> lldb/test/testcases/functionalities/breakpoint/breakpoint_conditions/main.
> c,
> > while targetting android arm64.
> >
> > You should be able to create a test binary for yourself locally
> (assuming you're on linux) like this:
> > $ cat a.c
> > int a(char *x) { return *x; }
> >
> > int f() {
> >   return a(0);
> > }
> >
> > int g() {
> >   return 1+f();
> > }
> >
> > int _start() { return 2+g(); }
> >
> > $ clang -fno-exceptions -fno-unwind-tables -g a.c -nostdlib
> >
> > If you debug the binary with and stop in the ParseCIE function, you will
> see that it parses the entry incorrectly:
> > Process 39688 stopped
> > * thread #1, name = 'lldb', stop reason = step over
> > frame #0: 0x7074bb53
> >
> liblldb.so.5`lldb_private::DWARFCallFrameInfo::ParseCIE(this=0x006
> 13280,
> > cie_offset=0) at DWARFCallFrameInfo.cpp:303
> >300cie_sp->data_align = (int32_t)m_cfi_data.GetSLEB128(&offset);
> >301cie_sp->return_addr_reg_num = m_cfi_data.GetU8(&offset);
> >302
> > -> 303if (cie_sp->augmentation[0]) {
> >304  // Get the length of the eh_frame augmentation data
> >305  // which starts with a ULEB128 length in bytes
> >306  const size_t aug_data_len =
> (size_t)m_cfi_data.GetULEB128(&offset);
> >
> > (lldb) fr var cie_sp._M_ptr[0]
> > (lldb_private::DWARFCallFrameInfo::CIE) cie_sp._M_ptr[0] = {
> >   cie_offset = 0
> >   version = '\x04'
> >   augmentation = ""
> >   code_align = 8 <== wrong
> >   data_align = 0 <== wrong
> >   return_addr_reg_num = 1 <= wrong
> >   inst_offset = 0
> >   inst_length = 0
> >   ptr_encoding = '\0'
> >   lsda_addr_encoding = '\xff'
> >   personality_loc = 18446744073709551615
> >   initial_row = {
> > m_offset = 0
> > m_cfa_value = {
> >   m_type = unspecified
> >   m_value = {
> > reg = (reg_num = 0, offset = 0)
> > expr = (opcodes = 0x, length = 0)
> >   }
> > }
> > m_register_locations = size=0 {}
> >   }
> > }
> >
> > Correct parsing can be seen by running
> > $ llvm-dwarfdump a.out
> > .
> > .debug_frame contents:
> >
> >  0014  CIE
> >   Version:   4
> >   Augmentation:  ""
> >   Address size:  8  <=== this shows up in code_align
> >   Segment desc size: 0 <=== this shows up in data_align
> >   Code alignment factor: 1 <=== this shows up in return_addr_reg_num
> >   Data alignment factor: -8
> >   Return address column: 16
> >
> >   DW_CFA_def_cfa: reg7 +8
> >   DW_CFA_offset: reg16 -8
> >   DW_CFA_nop:
> >   DW_CFA_nop:
> >   DW_CFA_nop:
> >   DW_CFA_nop:
> >
> > 0018 001c  FDE cie= pc=004000b0...004000c1
> >   DW_CFA_advance_loc: 1
> >   DW_CFA_def_cfa_offset: +16
> >   DW_CFA_offset: reg6 -16
> >   DW_CFA_advance_loc: 3
> >   DW_CFA_def_cfa_register: reg6
> > 
> >
> >
> > Interestingly, in the x86_64 linux case, lldb still manages to unwind
> correctly despite the bad parsing.
> >
> >
> >
> >
> > On 25 May 2017 at 14:40, Tatyana Krasnukha via Phabricator
>  wrote:
> >> tatyana-krasnukha added a comment.
> >>
> >> Yes, give those binaries, please.
> >>
> >>
> >> Repository:
> >>   rL LLVM
> >>
> >> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_
> >> D33504&d=DwIBaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4
> >> vlymPiSt0Wl0jegw&m=Ze6ANiK7goV6lSPJcY8QglIJ_tZC0gXeUuqpQ8n4K40&s=1vfSh
> >> WELC8pd8-DQmAeW3QJDQgdMAJvn905_U-jVphM&e=
> >>
> >>
> >>
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/c

[Lldb-commits] [lldb] r303965 - FreeBSD ProcessMonitor: map TRAP_CAP to a trace trap

2017-05-25 Thread Ed Maste via lldb-commits
Author: emaste
Date: Thu May 25 22:15:46 2017
New Revision: 303965

URL: http://llvm.org/viewvc/llvm-project?rev=303965&view=rev
Log:
FreeBSD ProcessMonitor: map TRAP_CAP to a trace trap

In the absense of a more specific handler for TRAP_CAP (generated by
ENOTCAPABLE or ECAPMODE while in capability mode) treat it as a trace
trap. Obtained from FreeBSD r318884.

We should later add an option to have LLDB control the trapcap procctl 
(as with ASLR), as well as report a specific stop reason. For now this
change eliminates an assertion failure from LLDB.

Modified:
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp?rev=303965&r1=303964&r2=303965&view=diff
==
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Thu May 25 
22:15:46 2017
@@ -1132,6 +1132,10 @@ ProcessMessage ProcessMonitor::MonitorSI
 
   case 0:
   case TRAP_TRACE:
+#ifdef TRAP_CAP
+  // Map TRAP_CAP to a trace trap in the absense of a more specific handler.
+  case TRAP_CAP:
+#endif
 if (log)
   log->Printf("ProcessMonitor::%s() received trace event, tid = %" PRIu64
   "  : si_code = %d",


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


[Lldb-commits] [PATCH] D33426: Introduce new command: thread backtrace unique

2017-05-25 Thread Brian Gianforcaro via Phabricator via lldb-commits
bgianfo updated this revision to Diff 100365.
bgianfo added a comment.

Address Pavel's feedback, made the unit test more robust.

This update increases the robustness of the new test I added.
We ensure synchronization, and force the threads into the state
we want them to be in by manually stepping them into place.


https://reviews.llvm.org/D33426

Files:
  include/lldb/Target/Thread.h
  
packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py
  packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp
  source/Commands/CommandObjectThread.cpp
  source/Core/Debugger.cpp
  source/Target/Thread.cpp

Index: source/Target/Thread.cpp
===
--- source/Target/Thread.cpp
+++ source/Target/Thread.cpp
@@ -1912,39 +1912,42 @@
 
 size_t Thread::GetStatus(Stream &strm, uint32_t start_frame,
  uint32_t num_frames, uint32_t num_frames_with_source,
- bool stop_format) {
-  ExecutionContext exe_ctx(shared_from_this());
-  Target *target = exe_ctx.GetTargetPtr();
-  Process *process = exe_ctx.GetProcessPtr();
-  size_t num_frames_shown = 0;
-  strm.Indent();
-  bool is_selected = false;
-  if (process) {
-if (process->GetThreadList().GetSelectedThread().get() == this)
-  is_selected = true;
-  }
-  strm.Printf("%c ", is_selected ? '*' : ' ');
-  if (target && target->GetDebugger().GetUseExternalEditor()) {
-StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame);
-if (frame_sp) {
-  SymbolContext frame_sc(
-  frame_sp->GetSymbolContext(eSymbolContextLineEntry));
-  if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) {
-Host::OpenFileInExternalEditor(frame_sc.line_entry.file,
-   frame_sc.line_entry.line);
+ bool stop_format, bool only_stacks) {
+
+  if (!only_stacks) {
+ExecutionContext exe_ctx(shared_from_this());
+Target *target = exe_ctx.GetTargetPtr();
+Process *process = exe_ctx.GetProcessPtr();
+strm.Indent();
+bool is_selected = false;
+if (process) {
+  if (process->GetThreadList().GetSelectedThread().get() == this)
+is_selected = true;
+}
+strm.Printf("%c ", is_selected ? '*' : ' ');
+if (target && target->GetDebugger().GetUseExternalEditor()) {
+  StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame);
+  if (frame_sp) {
+SymbolContext frame_sc(
+frame_sp->GetSymbolContext(eSymbolContextLineEntry));
+if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) {
+  Host::OpenFileInExternalEditor(frame_sc.line_entry.file,
+ frame_sc.line_entry.line);
+}
   }
 }
-  }
 
-  DumpUsingSettingsFormat(strm, start_frame, stop_format);
+DumpUsingSettingsFormat(strm, start_frame, stop_format);
+  }
 
+  size_t num_frames_shown = 0;
   if (num_frames > 0) {
 strm.IndentMore();
 
 const bool show_frame_info = true;
 
 const char *selected_frame_marker = nullptr;
-if (num_frames == 1 ||
+if (num_frames == 1 || only_stacks ||
 (GetID() != GetProcess()->GetThreadList().GetSelectedThread()->GetID()))
   strm.IndentMore();
 else
Index: source/Core/Debugger.cpp
===
--- source/Core/Debugger.cpp
+++ source/Core/Debugger.cpp
@@ -236,7 +236,7 @@
  "when displaying thread information."},
 {"thread-stop-format", OptionValue::eTypeFormatEntity, true, 0,
  DEFAULT_THREAD_STOP_FORMAT, nullptr, "The default thread format  "
- "string to usewhen displaying thread "
+ "string to use when displaying thread "
  "information as part of the stop display."},
 {"use-external-editor", OptionValue::eTypeBoolean, true, false, nullptr,
  nullptr, "Whether to use an external editor or not."},
Index: source/Commands/CommandObjectThread.cpp
===
--- source/Commands/CommandObjectThread.cpp
+++ source/Commands/CommandObjectThread.cpp
@@ -42,10 +42,40 @@
 using namespace lldb_private;
 
 //-
-// CommandObjectThreadBacktrace
+// CommandObjectIterateOverThreads
 //-
 
 class CommandObjectIterateOverThreads : public CommandObjectParsed {
+
+  class UniqueStack {
+
+  public:
+UniqueStack(std::stack stack_frames, uint32_t thread_index_id)
+  : m_stack_frames(stack_frames) {
+  m_thread_index_ids.push_back(thread_index_id);
+}
+
+void AddThread(uint32_t thread_index_id) {
+  m_thread_index_ids.push_back(thread_index_id);
+}
+
+const std::vector& GetUniqueThr