[Lldb-commits] [lldb] r140115 - in /lldb/trunk: include/lldb/Core/Error.h source/Commands/CommandObjectTarget.cpp source/Core/ModuleList.cpp source/Core/UserSettingsController.cpp source/Core/ValueObject.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/DWARFExpression.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Target/StackFrame.cpp source/Target/Target.cpp

Jason Molenda jmolenda at apple.com
Mon Sep 19 17:26:08 PDT 2011


Author: jmolenda
Date: Mon Sep 19 19:26:08 2011
New Revision: 140115

URL: http://llvm.org/viewvc/llvm-project?rev=140115&view=rev
Log:
Change Error::SetErrorStringWithFormat() prototype to use an
__attribute__ format so the compiler knows that this method takes
printf style formatter arguments and checks that it's being used
correctly.  Fix a couple dozen incorrect SetErrorStringWithFormat()
calls throughout the sources.

Modified:
    lldb/trunk/include/lldb/Core/Error.h
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Core/ModuleList.cpp
    lldb/trunk/source/Core/UserSettingsController.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/DWARFExpression.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
    lldb/trunk/source/Target/StackFrame.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Core/Error.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Error.h?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Error.h (original)
+++ lldb/trunk/include/lldb/Core/Error.h Mon Sep 19 19:26:08 2011
@@ -266,7 +266,7 @@
     ///     A printf style format string
     //------------------------------------------------------------------
     int
-    SetErrorStringWithFormat (const char *format, ...);
+    SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
 
     int
     SetErrorStringWithVarArg (const char *format, va_list args);

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Sep 19 19:26:08 2011
@@ -3429,7 +3429,7 @@
                     m_one_liner = option_arg;
                 break;
                 default:
-                    error.SetErrorStringWithFormat ("Unrecognized option %c.");
+                    error.SetErrorStringWithFormat ("Unrecognized option %c.", short_option);
                 break;
             }
             return error;

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Mon Sep 19 19:26:08 2011
@@ -865,7 +865,7 @@
                 if (arch.IsValid())
                 {
                     if (uuid_cstr[0])
-                        error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s.\n", path, arch.GetArchitectureName(), uuid_cstr[0]);
+                        error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s.\n", path, arch.GetArchitectureName(), uuid_cstr);
                     else
                         error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.\n", path, arch.GetArchitectureName());
                 }
@@ -941,9 +941,9 @@
                         uuid_cstr[0] = '\0';
 
                     if (uuid_cstr[0])
-                        error.SetErrorStringWithFormat("Cannot locate a module for UUID '%s'.\n", uuid_cstr[0]);
+                        error.SetErrorStringWithFormat("Cannot locate a module for UUID '%s'.\n", uuid_cstr);
                     else
-                        error.SetErrorStringWithFormat("Cannot locate a module.\n", path, arch.GetArchitectureName());
+                        error.SetErrorStringWithFormat("Cannot locate a module.\n");
                 }
             }
         }

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Mon Sep 19 19:26:08 2011
@@ -2134,9 +2134,9 @@
             
             
             if (value_cstr == NULL)
-                err.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n", value_cstr);
+                err.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n");
             else if (value_cstr[0] == '\0')
-                err.SetErrorStringWithFormat ("invalid boolean string value (empty)\n", value_cstr);
+                err.SetErrorStringWithFormat ("invalid boolean string value (empty)\n");
             else
             {
                 bool new_value = Args::StringToBoolean (value_cstr, false, &success);
@@ -2180,9 +2180,9 @@
             error = option_value.SetValueFromCString(value);
             
             if (value == NULL)
-                error.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n", value);
+                error.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n");
             else if (value[0] == '\0')
-                error.SetErrorStringWithFormat ("invalid boolean string value (empty)\n", value);
+                error.SetErrorStringWithFormat ("invalid boolean string value (empty)\n");
             else
             {
                 bool new_value = Args::StringToBoolean (value, false, &success);

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Sep 19 19:26:08 2011
@@ -1053,7 +1053,7 @@
                                 m_value_str.swap(sstr.GetString());
                             else
                             {
-                                m_error.SetErrorStringWithFormat ("unsufficient data for value (only %u of %u bytes available)", 
+                                m_error.SetErrorStringWithFormat ("unsufficient data for value (only %lu of %lu bytes available)", 
                                                                   m_data.GetByteSize(),
                                                                   GetByteSize());
                                 m_value_str.clear();

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Sep 19 19:26:08 2011
@@ -1854,7 +1854,7 @@
         Error write_error (reg_ctx.WriteRegisterValueToMemory(&reg_info, addr, register_byte_size, reg_value));
         if (write_error.Fail())
         {
-            err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", write_error.AsCString());
+            err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", reg_info.name, write_error.AsCString());
             return false;
         }
     }

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Mon Sep 19 19:26:08 2011
@@ -2395,7 +2395,7 @@
                 if (member_bit_incr % 8)
                 {
                     if (error_ptr)
-                        error_ptr->SetErrorStringWithFormat("Array increment is not byte aligned", index, size);
+                        error_ptr->SetErrorStringWithFormat("Array increment is not byte aligned");
                     return false;
                 }
                 int64_t member_offset = (int64_t)(member_bit_incr / 8) * index;

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Sep 19 19:26:08 2011
@@ -96,7 +96,7 @@
             if (resolved_exe_file.Exists())
                 error.Clear();
             else
-                error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.");
+                error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_exe_file.GetFilename().AsCString(""));
         }
     }
     

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Mon Sep 19 19:26:08 2011
@@ -745,7 +745,7 @@
                                         else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
                                         {
                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                            error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", 
+                                            error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 
                                                                             child_index, 
                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                             var_expr_path_strm.GetString().c_str());
@@ -756,7 +756,7 @@
                                             if (!child_valobj_sp)
                                             {
                                                 valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                                error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", 
+                                                error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 
                                                                                 child_index, 
                                                                                 valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                                 var_expr_path_strm.GetString().c_str());
@@ -769,7 +769,7 @@
                                         if (!child_valobj_sp)
                                         {
                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                            error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"", 
+                                            error.SetErrorStringWithFormat ("failed to use pointer as array for index %ld for \"(%s) %s\"", 
                                                                             child_index, 
                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                             var_expr_path_strm.GetString().c_str());
@@ -784,7 +784,7 @@
                                     if (!child_valobj_sp)
                                     {
                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                        error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", 
+                                        error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 
                                                                         child_index, 
                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                         var_expr_path_strm.GetString().c_str());
@@ -797,7 +797,7 @@
                                     if (!child_valobj_sp)
                                     {
                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                        error.SetErrorStringWithFormat ("bitfield range %i-%i is not valid for \"(%s) %s\"", 
+                                        error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"", 
                                                                         child_index, child_index, 
                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                         var_expr_path_strm.GetString().c_str());
@@ -818,7 +818,7 @@
                                     else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */)
                                     {
                                         valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                        error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", 
+                                        error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 
                                                                         child_index, 
                                                                         valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                         var_expr_path_strm.GetString().c_str());
@@ -829,7 +829,7 @@
                                         if (!child_valobj_sp)
                                         {
                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                            error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", 
+                                            error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", 
                                                                             child_index, 
                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                             var_expr_path_strm.GetString().c_str());
@@ -930,7 +930,7 @@
                                         if (!child_valobj_sp)
                                         {
                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);
-                                            error.SetErrorStringWithFormat ("bitfield range %i-%i is not valid for \"(%s) %s\"", 
+                                            error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"", 
                                                                             child_index, final_index, 
                                                                             valobj_sp->GetTypeName().AsCString("<invalid type>"),
                                                                             var_expr_path_strm.GetString().c_str());

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140115&r1=140114&r2=140115&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Sep 19 19:26:08 2011
@@ -769,7 +769,8 @@
             if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec())
                 error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded.\n", 
                                                resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString(), 
-                                               resolved_addr.GetFileAddress());
+                                               resolved_addr.GetFileAddress(),
+                                               resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString());
             else
                 error.SetErrorStringWithFormat("0x%llx can't be resolved.\n", resolved_addr.GetFileAddress());
         }





More information about the lldb-commits mailing list