[Lldb-commits] [PATCH] 32-bit target support on x86_64 Linux

Greg Clayton gclayton at apple.com
Fri Sep 7 10:51:07 PDT 2012


Andrew:

This patch looks ok except this part:

Index: include/lldb/Core/ArchSpec.h
===================================================================
--- include/lldb/Core/ArchSpec.h	(revision 163394)
+++ include/lldb/Core/ArchSpec.h	(working copy)
@@ -210,7 +210,10 @@
     bool
     TripleVendorWasSpecified() const
     {
-        return !m_triple.getVendorName().empty();
+        llvm::StringRef vendor = m_triple.getVendorName();
+        if (vendor.empty())
+            return false;
+        return vendor != "unknown";
     }
 
     bool


When you give an llvm::Triple just a raw architecture like "x86_64", it will always return an "unknown" enumeration when asked what its vendor and OS is, but in LLDB we want to know when the user specified "unknown" explicity since we use this when looking for the right plug-in. There currently isn't a "none" enumeration or name that is accepted by the triple. So if the user currently specifies:

(lldb) target create --arch x86_64-unknown-unknown /tmp/a.out

We will know that the user specified "unknown" with:

     bool
     TripleVendorWasSpecified() const
     {
         return !m_triple.getVendorName().empty();
     }

This causes no vendor or OS to be used when debugging and it is handy when you are debugging something on a bare board. It allows us to select the DynamicLoaderStatic to be used which just loads files at the addresses that are contained in the files themselves (absolute addressing).

So the "bool ArchSpec::TripleVendorWasSpecified() const" is really trying to say "did the user type something for the vendor" (which inludes "unknown" as a valid thing the user typed). Does that make sense? 

I committed the other changes though:

% svn commit
Sending        source/Host/common/Host.cpp
Sending        source/Plugins/Platform/Linux/PlatformLinux.cpp
Sending        source/Plugins/Process/Linux/ProcessMonitor.cpp
Transmitting file data ...
Committed revision 163398.

On Sep 6, 2012, at 2:45 PM, "Kaylor, Andrew" <andrew.kaylor at intel.com> wrote:

> The attached patch adds support for debugging 32-bit processes when running a 64-bit lldb on an x86_64 Linux system.
>  
> Making this work required two basic changes:
>  
> 1)      Getting lldb to report that it could debug 32-bit processes
> 2)      Changing an assumption about how ptrace works when debugging cross-platform
>  
> For the first change, I took a conservative approach and only enabled this for x86_64 Linux platforms.  It may be that the change I made in Host.cpp could be extended to other 64-bit Linux platforms, but I’m not familiar enough with the other platforms to know for sure.
>  
> For the second change, the Linux ProcessMonitor class was assuming that ptrace(PTRACE_[PEEK|POKE]DATA…) would read/write a “word” based on the child process word size.  However, the ptrace documentation says that the “word” size read or written is “determined by the OS variant.”  I verified experimentally that when ptracing a 32-bit child from a 64-bit parent a 64-bit word is read or written.
>  
> This patch also modifies ArchSpec.h to recognize that “unknown” indicates an unspecified vendor choice.  Whether or not this comes into play seems to depend on how you build lldb.
>  
> -Andy
> <linux-32-bit-support.patch>_______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits





More information about the lldb-commits mailing list