[libunwind] r292721 - DWARF: convert error logs to _LIBUNWIND_LOG

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 21 08:22:55 PST 2017


Author: compnerd
Date: Sat Jan 21 10:22:55 2017
New Revision: 292721

URL: http://llvm.org/viewvc/llvm-project?rev=292721&view=rev
Log:
DWARF: convert error logs to _LIBUNWIND_LOG

Use the `_LIBUNWIND_LOG` macro instead of the explicit `fprintf` call.
NFC.

Modified:
    libunwind/trunk/src/DwarfParser.hpp
    libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=292721&r1=292720&r2=292721&view=diff
==============================================================================
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Sat Jan 21 10:22:55 2017
@@ -421,8 +421,7 @@ bool CFI_Parser<A>::parseInstructions(A
       offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)
                                                   * cieInfo.dataAlignFactor;
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_offset_extended DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_offset_extended, reg too big");
         return false;
       }
       results->savedRegisters[reg].location = kRegisterInCFA;
@@ -436,9 +435,7 @@ bool CFI_Parser<A>::parseInstructions(A
       reg = addressSpace.getULEB128(p, instructionsEnd);
       ;
       if (reg > kMaxRegisterNumber) {
-        fprintf(
-            stderr,
-            "malformed DW_CFA_restore_extended DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_restore_extended, reg too big");
         return false;
       }
       results->savedRegisters[reg] = initialState.savedRegisters[reg];
@@ -448,8 +445,7 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_undefined:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_undefined DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_undefined, reg too big");
         return false;
       }
       results->savedRegisters[reg].location = kRegisterUnused;
@@ -459,8 +455,7 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_same_value:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_same_value DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_same_value, reg too big");
         return false;
       }
       // <rdar://problem/8456377> DW_CFA_same_value unsupported
@@ -477,13 +472,11 @@ bool CFI_Parser<A>::parseInstructions(A
       reg = addressSpace.getULEB128(p, instructionsEnd);
       reg2 = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_register DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg too big");
         return false;
       }
       if (reg2 > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_register DWARF unwind, reg2 too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_register, reg2 too big");
         return false;
       }
       results->savedRegisters[reg].location = kRegisterInRegister;
@@ -525,7 +518,7 @@ bool CFI_Parser<A>::parseInstructions(A
       reg = addressSpace.getULEB128(p, instructionsEnd);
       offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr, "malformed DW_CFA_def_cfa DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa, reg too big");
         return false;
       }
       results->cfaRegister = (uint32_t)reg;
@@ -537,9 +530,7 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_def_cfa_register:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(
-            stderr,
-            "malformed DW_CFA_def_cfa_register DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa_register, reg too big");
         return false;
       }
       results->cfaRegister = (uint32_t)reg;
@@ -567,8 +558,7 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_expression:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_expression DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_expression, reg too big");
         return false;
       }
       results->savedRegisters[reg].location = kRegisterAtExpression;
@@ -583,9 +573,8 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_offset_extended_sf:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(
-            stderr,
-            "malformed DW_CFA_offset_extended_sf DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG(
+            "malformed DWARF DW_CFA_offset_extended_sf, reg too big");
         return false;
       }
       offset =
@@ -602,8 +591,7 @@ bool CFI_Parser<A>::parseInstructions(A
       offset =
           addressSpace.getSLEB128(p, instructionsEnd) * cieInfo.dataAlignFactor;
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_def_cfa_sf DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_def_cfa_sf, reg too big");
         return false;
       }
       results->cfaRegister = (uint32_t)reg;
@@ -635,8 +623,7 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_val_offset_sf:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_val_offset_sf DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_val_offset_sf, reg too big");
         return false;
       }
       offset =
@@ -651,8 +638,7 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_val_expression:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr,
-                "malformed DW_CFA_val_expression DWARF unwind, reg too big\n");
+        _LIBUNWIND_LOG("malformed DWARF DW_CFA_val_expression, reg too big");
         return false;
       }
       results->savedRegisters[reg].location = kRegisterIsExpression;
@@ -673,8 +659,8 @@ bool CFI_Parser<A>::parseInstructions(A
     case DW_CFA_GNU_negative_offset_extended:
       reg = addressSpace.getULEB128(p, instructionsEnd);
       if (reg > kMaxRegisterNumber) {
-        fprintf(stderr, "malformed DW_CFA_GNU_negative_offset_extended DWARF "
-                        "unwind, reg too big\n");
+        _LIBUNWIND_LOG(
+            "malformed DWARF DW_CFA_GNU_negative_offset_extended, reg too big");
         return false;
       }
       offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)

Modified: libunwind/trunk/src/config.h
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=292721&r1=292720&r2=292721&view=diff
==============================================================================
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Sat Jan 21 10:22:55 2017
@@ -87,7 +87,7 @@
   } while (0)
 
 #define _LIBUNWIND_LOG(msg, ...)                                               \
-  fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+  fprintf(stderr, "libunwind: " msg "\n", ##__VA_ARGS__)
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds




More information about the cfe-commits mailing list