[Lldb-commits] [PATCH] Let lldb dump line tables for DWARF v3

2014-04-08 Thread Matthew Gardiner

Hi people,

I have been looking into the support for ARM binary images by lldb. One 
of the ARM tool chains I use produces .debug_line tables as specified by 
DWARF v3. With lldb and llvm-dwarfdump built from the top of the tree, I 
observed that the dwarfdump tool dumps the line table, but lldb does 
not. After some investigation I discovered that the dump tool is built 
against llvm/lib/DebugInfo/DWARFDebugLine.cpp, whereas lldb uses 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp.


It turned out that the source used by lldb has a subtle difference in 
flow-control with regards the treatment of the line table's prologue 
version number compared to that of the llvm source. After duplication of 
this flow-control, it is possible for lldb to print the line-table built 
according to DWARF standards above and beyond v2.


Could somebody submit the following patch to the lldb tree which fixes 
this issue?


Index: source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp  (revision 205611)
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp  (working copy)
@@ -418,7 +418,7 @@
 const char * s;
 prologue-total_length  = 
debug_line_data.GetDWARFInitialLength(offset_ptr);

 prologue-version   = debug_line_data.GetU16(offset_ptr);
-if (prologue-version != 2)
+if (prologue-version  2)
   return false;

 prologue-prologue_length   = 
debug_line_data.GetDWARFOffset(offset_ptr);

@@ -486,7 +486,7 @@
 (void)debug_line_data.GetDWARFInitialLength(offset);
 const char * s;
 uint32_t version = debug_line_data.GetU16(offset);
-if (version != 2)
+if (version  2)
   return false;

 const dw_offset_t end_prologue_offset = 
debug_line_data.GetDWARFOffset(offset) + offset;



thank you
Matthew Gardiner


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Keep up to date with CSR on our 
technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people, YouTube, 
www.youtube.com/user/CSRplc, Facebook, 
www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at 
www.twitter.com/CSR_plc.
New for 2014, you can now access the wide range of products powered by aptX at 
www.aptx.com.
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp	(revision 205611)
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp	(working copy)
@@ -418,7 +418,7 @@
 const char * s;
 prologue-total_length  = debug_line_data.GetDWARFInitialLength(offset_ptr);
 prologue-version   = debug_line_data.GetU16(offset_ptr);
-if (prologue-version != 2)
+if (prologue-version  2)
   return false;
 
 prologue-prologue_length   = debug_line_data.GetDWARFOffset(offset_ptr);
@@ -486,7 +486,7 @@
 (void)debug_line_data.GetDWARFInitialLength(offset);
 const char * s;
 uint32_t version = debug_line_data.GetU16(offset);
-if (version != 2)
+if (version  2)
   return false;
 
 const dw_offset_t end_prologue_offset = debug_line_data.GetDWARFOffset(offset) + offset;
___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] Let lldb dump line tables for DWARF v3

2014-04-08 Thread Ed Maste
On 8 April 2014 05:54, Matthew Gardiner m...@csr.com wrote:
 Hi people,

 I have been looking into the support for ARM binary images by lldb. One of
 the ARM tool chains I use produces .debug_line tables as specified by DWARF
 v3. With lldb and llvm-dwarfdump built from the top of the tree, I observed
 that the dwarfdump tool dumps the line table, but lldb does not. After some
 investigation I discovered that the dump tool is built against
 llvm/lib/DebugInfo/DWARFDebugLine.cpp, whereas lldb uses
 lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp.

Correct.  The DWARF debug classes originated within LLDB, and were
later reused in LLVM without moving LLDB over to use the new copy.

 It turned out that the source used by lldb has a subtle difference in
 flow-control with regards the treatment of the line table's prologue version
 number compared to that of the llvm source. After duplication of this
 flow-control, it is possible for lldb to print the line-table built
 according to DWARF standards above and beyond v2.

It's not quite that straightforward though, because the LLVM version
has cases for version = 4, which has an additional field in the
prologue header format.  I'll change the test to  2 ||  3 for now.
___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r205769 - Improve demangler to compile with MSVC.

2014-04-08 Thread Virgile Bello
Author: xen2
Date: Tue Apr  8 09:46:44 2014
New Revision: 205769

URL: http://llvm.org/viewvc/llvm-project?rev=205769view=rev
Log:
Improve demangler to compile with MSVC.

Modified:
lldb/trunk/source/Core/Mangled.cpp

Modified: lldb/trunk/source/Core/Mangled.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=205769r1=205768r2=205769view=diff
==
--- lldb/trunk/source/Core/Mangled.cpp (original)
+++ lldb/trunk/source/Core/Mangled.cpp Tue Apr  8 09:46:44 2014
@@ -11,7 +11,13 @@
 // FreeBSD9-STABLE requires this to know about size_t in cxxabi.h
 #include cstddef
 #if defined(_MSC_VER) 
-// Cannot enable the builtin demangler on msvc as it does not support the 
cpp11 within the implementation.
+#define LLDB_USE_BUILTIN_DEMANGLER
+// MSVC doesn't support constexpr, alignas, __attribute__ and noexcept yet
+#define constexpr
+#define alignas(X)
+#define __attribute__(X)
+#define noexcept
+#define snprintf _snprintf
 #elif defined (__FreeBSD__)
 #define LLDB_USE_BUILTIN_DEMANGLER
 #else
@@ -173,30 +179,30 @@ struct float_datafloat
 {
 static const size_t mangled_size = 8;
 static const size_t max_demangled_size = 24;
-static constexpr const char* spec = %af;
+static constexpr const char* spec;
 };
 
-constexpr const char* float_datafloat::spec;
+constexpr const char* float_datafloat::spec = %af;
 
 template 
 struct float_datadouble
 {
 static const size_t mangled_size = 16;
 static const size_t max_demangled_size = 32;
-static constexpr const char* spec = %a;
+static constexpr const char* spec;
 };
 
-constexpr const char* float_datadouble::spec;
+constexpr const char* float_datadouble::spec = %a;
 
 template 
 struct float_datalong double
 {
 static const size_t mangled_size = 20;  // May need to be adjusted to 16 
or 24 on other platforms
 static const size_t max_demangled_size = 40;
-static constexpr const char* spec = %LaL;
+static constexpr const char* spec;
 };
 
-constexpr const char* float_datalong double::spec;
+constexpr const char* float_datalong double::spec = %LaL;
 
 template class Float, class C
 const char*


___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r205770 - Added i686 architecture (ArchSpec::Core::eCore_x86_32_i686).

2014-04-08 Thread Virgile Bello
Author: xen2
Date: Tue Apr  8 09:48:48 2014
New Revision: 205770

URL: http://llvm.org/viewvc/llvm-project?rev=205770view=rev
Log:
Added i686 architecture (ArchSpec::Core::eCore_x86_32_i686).

Modified:
lldb/trunk/include/lldb/Core/ArchSpec.h
lldb/trunk/source/Core/ArchSpec.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=205770r1=205769r2=205770view=diff
==
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Tue Apr  8 09:48:48 2014
@@ -91,6 +91,7 @@ public:
 eCore_x86_32_i386,
 eCore_x86_32_i486,
 eCore_x86_32_i486sx,
+eCore_x86_32_i686,
 
 eCore_x86_64_x86_64,
 eCore_x86_64_x86_64h, // Haswell enabled x86_64
@@ -124,7 +125,7 @@ public:
 kCore_ppc64_last= eCore_ppc64_ppc970_64,
 
 kCore_x86_32_first  = eCore_x86_32_i386,
-kCore_x86_32_last   = eCore_x86_32_i486sx,
+kCore_x86_32_last   = eCore_x86_32_i686,
 
 kCore_hexagon_first  = eCore_hexagon_generic,
 kCore_hexagon_last   = eCore_hexagon_hexagonv5

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=205770r1=205769r2=205770view=diff
==
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Tue Apr  8 09:48:48 2014
@@ -103,6 +103,7 @@ static const CoreDefinition g_core_defin
 { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86, 
ArchSpec::eCore_x86_32_i386, i386  },
 { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86, 
ArchSpec::eCore_x86_32_i486, i486  },
 { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86, 
ArchSpec::eCore_x86_32_i486sx  , i486sx},
+{ eByteOrderLittle, 4, 1, 15, llvm::Triple::x86, 
ArchSpec::eCore_x86_32_i686, i686  },
 
 { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , 
ArchSpec::eCore_x86_64_x86_64  , x86_64},
 { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , 
ArchSpec::eCore_x86_64_x86_64h , x86_64h   },


___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r205769 - Improve demangler to compile with MSVC.

2014-04-08 Thread Ed Maste
On 8 April 2014 10:46, Virgile Bello virgile.be...@gmail.com wrote:
 Author: xen2
 Date: Tue Apr  8 09:46:44 2014
 New Revision: 205769

 URL: http://llvm.org/viewvc/llvm-project?rev=205769view=rev
 Log:
 Improve demangler to compile with MSVC.

I reverted this as it breaks the build on FreeBSD:
error: declaration of constexpr static data member 'spec' requires an
initializer

I'm not sure if there's going to be an easy solution other than some
#ifdef hackery, unfortunately.
___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r205782 - Fix the GetArrayElementType() call so it will not crash when called on a non-array thing

2014-04-08 Thread Enrico Granata
Author: enrico
Date: Tue Apr  8 13:36:09 2014
New Revision: 205782

URL: http://llvm.org/viewvc/llvm-project?rev=205782view=rev
Log:
Fix the GetArrayElementType() call so it will not crash when called on a 
non-array thing
Also, the stride is now a pointer so one can avoid passing it if it's not 
required


Modified:
lldb/trunk/include/lldb/Symbol/ClangASTType.h
lldb/trunk/source/Symbol/ClangASTType.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=205782r1=205781r2=205782view=diff
==
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Tue Apr  8 13:36:09 2014
@@ -312,7 +312,7 @@ public:
clang::DeclContext *decl_ctx) const;
 
 ClangASTType
-GetArrayElementType (uint64_t stride) const;
+GetArrayElementType (uint64_t *stride = nullptr) const;
 
 ClangASTType
 GetCanonicalType () const;

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=205782r1=205781r2=205782view=diff
==
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Tue Apr  8 13:36:09 2014
@@ -1638,16 +1638,22 @@ ClangASTType::AddVolatileModifier () con
 }
 
 ClangASTType
-ClangASTType::GetArrayElementType (uint64_t stride) const
+ClangASTType::GetArrayElementType (uint64_t *stride) const
 {
 if (IsValid())
 {
 QualType qual_type(GetCanonicalQualType());
 
-ClangASTType element_type (m_ast, 
qual_type.getTypePtr()-getArrayElementTypeNoTypeQual()-getCanonicalTypeUnqualified());
+const clang::Type *array_elem_type = 
qual_type.getTypePtr()-getArrayElementTypeNoTypeQual();
+
+if (!array_elem_type)
+return ClangASTType();
+
+ClangASTType element_type (m_ast, 
array_elem_type-getCanonicalTypeUnqualified());
 
 // TODO: the real stride will be = this value.. find the real one!
-stride = element_type.GetByteSize();
+if (stride)
+*stride = element_type.GetByteSize();
 
 return element_type;
 


___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r205790 - This function should be const.

2014-04-08 Thread Jim Ingham
Author: jingham
Date: Tue Apr  8 15:24:45 2014
New Revision: 205790

URL: http://llvm.org/viewvc/llvm-project?rev=205790view=rev
Log:
This function should be const.

Modified:
lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
lldb/trunk/source/Breakpoint/BreakpointOptions.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=205790r1=205789r2=205790view=diff
==
--- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Tue Apr  8 15:24:45 
2014
@@ -145,7 +145,8 @@ public:
 /// @return
 /// The synchronicity of our callback.
 //--
-bool IsCallbackSynchronous () {
+bool IsCallbackSynchronous () const
+{
 return m_callback_is_synchronous;
 }
 
@@ -280,7 +281,7 @@ public:
 /// Returns true if the breakpoint option has a callback set.
 //--
 bool
-HasCallback();
+HasCallback() const;
 
 //--
 /// This is the default empty callback.

Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=205790r1=205789r2=205790view=diff
==
--- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Tue Apr  8 15:24:45 2014
@@ -154,7 +154,7 @@ BreakpointOptions::InvokeCallback (Stopp
 }
 
 bool
-BreakpointOptions::HasCallback ()
+BreakpointOptions::HasCallback () const
 {
 return m_callback != BreakpointOptions::NullCallback;
 }


___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r205803 - Fix the behavior when hand-calling a function times out on one thread,

2014-04-08 Thread Jim Ingham
Author: jingham
Date: Tue Apr  8 16:33:21 2014
New Revision: 205803

URL: http://llvm.org/viewvc/llvm-project?rev=205803view=rev
Log:
Fix the behavior when hand-calling a function times out on one thread,
but by the time we go to halt, it has already stopped by hitting the 
function end breakpoint.  That wasn't being shown to the threads so the
Function call thread plan didn't know its job was done.

rdar://problem/16515785

Modified:
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/ThreadList.cpp
lldb/trunk/source/Target/ThreadPlanCallFunction.cpp

Modified: lldb/trunk/source/Target/Process.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=205803r1=205802r2=205803view=diff
==
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Apr  8 16:33:21 2014
@@ -3901,6 +3901,9 @@ Process::ShouldBroadcastEvent (Event *ev
 log-Printf (Process::ShouldBroadcastEvent (%p) stopped 
due to an interrupt, state: %s,
  static_castvoid*(event_ptr),
  StateAsCString(state));
+// Even though we know we are going to stop, we should let the 
threads have a look at the stop,
+// so they can properly set their state.
+m_thread_list.ShouldStop (event_ptr);
 return_value = true;
 }
 else
@@ -4381,8 +4384,14 @@ Process::ProcessEventData::DoOnRemoval (
 return;
 
 m_process_sp-SetPublicState (m_state, 
Process::ProcessEventData::GetRestartedFromEvent(event_ptr));
-
-// If we're stopped and haven't restarted, then do the breakpoint commands 
here:
+
+// If this is a halt event, even if the halt stopped with some reason 
other than a plain interrupt (e.g. we had
+// already stopped for a breakpoint when the halt request came through) 
don't do the StopInfo actions, as they may
+// end up restarting the process.
+if (m_interrupted)
+return;
+
+// If we're stopped and haven't restarted, then do the StopInfo actions 
here:
 if (m_state == eStateStopped  ! m_restarted)
 {
 ThreadList curr_thread_list = m_process_sp-GetThreadList();
@@ -5253,7 +5262,17 @@ Process::RunThreadPlan (ExecutionContext
 
 // This while loop must exit out the bottom, there's cleanup that we 
need to do when we are done.
 // So don't call return anywhere within it.
-
+
+#ifdef LLDB_RUN_THREAD_HALT_WITH_EVENT
+// It's pretty much impossible to write test cases for things like:
+// One thread timeout expires, I go to halt, but the process already 
stopped
+// on the function call stop breakpoint.  Turning on this define will 
make us not
+// fetch the first event till after the halt.  So if you run a quick 
function, it will have
+// completed, and the completion event will be waiting, when you 
interrupt for halt.
+// The expression evaluation should still succeed.
+bool miss_first_event = true;
+#endif
+
 while (1)
 {
 // We usually want to resume the process if we get to the top of 
the loop.
@@ -5383,7 +5402,17 @@ Process::RunThreadPlan (ExecutionContext
 log-Printf (Process::RunThreadPlan(): about to wait 
forever.);
 }
 }
-
+
+#ifdef LLDB_RUN_THREAD_HALT_WITH_EVENT
+// See comment above...
+if (miss_first_event)
+{
+usleep(1000);
+miss_first_event = false;
+got_event = false;
+}
+else
+#endif
 got_event = listener.WaitForEvent (timeout_ptr, event_sp);
 
 if (got_event)

Modified: lldb/trunk/source/Target/ThreadList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=205803r1=205802r2=205803view=diff
==
--- lldb/trunk/source/Target/ThreadList.cpp (original)
+++ lldb/trunk/source/Target/ThreadList.cpp Tue Apr  8 16:33:21 2014
@@ -262,7 +262,7 @@ ThreadList::ShouldStop (Event *event_ptr
 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
 
 // The ShouldStop method of the threads can do a whole lot of work,
-// running breakpoint commands  conditions, etc.  So we don't want
+// figuring out whether the thread plan conditions are met.  So we don't 
want
 // to keep the ThreadList locked the whole time we are doing this.
 // FIXME: It is possible that running code could cause new threads
 // to be created.  If that happens we will miss asking them whether
@@ -287,7 +287,16 @@ ThreadList::ShouldStop (Event *event_ptr
 }
 
 bool did_anybody_stop_for_a_reason = false;
+  

Re: [Lldb-commits] [PATCH] Revert r205480 and rename enums defined in llvm/Support/MachO.h

2014-04-08 Thread jingham
That looks okay to me, please commit.

Jim

On Apr 8, 2014, at 3:20 PM, Akira Hatanaka ahata...@gmail.com wrote:

 This patch reverts the workaround introduced in r205480 that was required to 
 avoid collision between enums defined in llvm/Support/MachO.h and macros 
 defined in system header files. The patch should be applied along with the 
 patch posted here that renames enums in MachO.h:
 
 http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140407/212243.html
 
 Please review.
 machoenum-rename-lldb1.patch___
 lldb-commits mailing list
 lldb-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r205825 - Fixed a problem where IRForTarget wasn't ignoring

2014-04-08 Thread Sean Callanan
Author: spyffe
Date: Tue Apr  8 19:59:41 2014
New Revision: 205825

URL: http://llvm.org/viewvc/llvm-project?rev=205825view=rev
Log:
Fixed a problem where IRForTarget wasn't ignoring
dbg_value intrinsics appropriately.

rdar://problem/16504649

Modified:
lldb/trunk/source/Expression/IRForTarget.cpp

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=205825r1=205824r2=205825view=diff
==
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Apr  8 19:59:41 2014
@@ -196,6 +196,7 @@ IRForTarget::GetFunctionAddress (llvm::F
 }
 break;
 case Intrinsic::dbg_declare:
+case Intrinsic::dbg_value:
 return LookupResult::Ignore;
 }
 


___
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits