From c3bf7da9cfa9d820332d141b2aee2b054cf61596 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 21 Jan 2017 16:22:55 +0000 Subject: [PATCH] DWARF: convert error logs to _LIBUNWIND_LOG Use the `_LIBUNWIND_LOG` macro instead of the explicit `fprintf` call. NFC. llvm-svn: 292721 --- libunwind/src/DwarfParser.hpp | 46 ++++++++++++----------------------- libunwind/src/config.h | 2 +- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp index 62c047bd380f..2427c63b50f3 100644 --- a/libunwind/src/DwarfParser.hpp +++ b/libunwind/src/DwarfParser.hpp @@ -421,8 +421,7 @@ bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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; } // DW_CFA_same_value unsupported @@ -477,13 +472,11 @@ bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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::parseInstructions(A &addressSpace, pint_t instructions, 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) diff --git a/libunwind/src/config.h b/libunwind/src/config.h index 8a6dff0cb992..fefb44e0a23f 100644 --- a/libunwind/src/config.h +++ b/libunwind/src/config.h @@ -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