[Lldb-commits] [lldb] r213294 - In Process::LoadImage, if dlopen returns 0x0 fetch the error with dlerror and report

Jim Ingham jingham at apple.com
Thu Jul 17 11:55:25 PDT 2014


Author: jingham
Date: Thu Jul 17 13:55:25 2014
New Revision: 213294

URL: http://llvm.org/viewvc/llvm-project?rev=213294&view=rev
Log:
In Process::LoadImage, if dlopen returns 0x0 fetch the error with dlerror and report 
that in the returned Error.

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

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=213294&r1=213293&r2=213294&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Jul 17 13:55:25 2014
@@ -1550,6 +1550,31 @@ Process::LoadImage (const FileSpec &imag
                                 m_image_tokens.push_back (image_ptr);
                                 return image_token;
                             }
+                            else if (image_ptr == 0)
+                            {
+                                prefix = "extern \"C\" const char *dlerror(void);\n";
+                                expr.Clear();
+                                expr.PutCString("dlerror()");
+                                ClangUserExpression::Evaluate (exe_ctx,
+                                                               expr_options,
+                                                               expr.GetData(),
+                                                               prefix,
+                                                               result_valobj_sp,
+                                                               expr_error);
+                                if (result_valobj_sp && error.Success())
+                                {
+                                    if (result_valobj_sp->IsCStringContainer(true))
+                                    {
+                                        lldb::DataBufferSP buf_sp (new DataBufferHeap());
+                                        size_t num_chars = result_valobj_sp->ReadPointedString (buf_sp, error);
+                                        if (error.Success() && num_chars > 0)
+                                        {
+                                            error.Clear();
+                                            error.SetErrorStringWithFormat("dlopen failed: %s", buf_sp->GetBytes());
+                                        }
+                                    }
+                                }
+                            }
                         }
                     }
                 }





More information about the lldb-commits mailing list