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

Zachary Turner zturner at google.com
Thu Jul 17 14:41:48 PDT 2014


Hi Jim, this seems to have broken the build.  Doesn't seem Windows-specific
either.  Was there a piece missing from your checkin?

Here's a patch that (maybe?) addresses this, but I'm not familiar with this
codepath so I'm not sure how to exercise it and test.

If I don't hear back in an hour or so I may see about reverting it, since
I'm not sure if the attached fix is correct.


On Thu, Jul 17, 2014 at 11:55 AM, Jim Ingham <jingham at apple.com> wrote:

> 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());
> +                                        }
> +                                    }
> +                                }
> +                            }
>                          }
>                      }
>                  }
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140717/5e179451/attachment.html>
-------------- next part --------------
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 44ba741..cebe440 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -23,7 +23,6 @@
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/State.h"
-#include "lldb/Core/StreamBuffer.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Expression/ClangUserExpression.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -1566,12 +1565,12 @@ Process::LoadImage (const FileSpec &image_spec, Error &error)
                                 {
                                     if (result_valobj_sp->IsCStringContainer(true))
                                     {
-                                        StreamBuffer<1024> buffer;
-                                        size_t num_chars = result_valobj_sp->ReadPointedString (buffer, error);
+                                        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", buffer.GetData());
+                                            error.SetErrorStringWithFormat("dlopen failed: %s", buf_sp->GetBytes());
                                         }
                                     }
                                 }


More information about the lldb-commits mailing list