From 9d8f8b558d0ab0ff791c908bab56319b818fb4ce Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 3 Mar 2018 01:31:31 +0000 Subject: [PATCH] binutils opcodes error messages This patch is aimed at making binutils/opcodes files comply with the GNU coding standard regarding error messages, that is, they should start with the program name followed by a colon, then a lower case message. Accomplished by calling opcodes_error_handler to output the program name (and final '\n'), rather than calling fprintf. * desc-cpu.scm (opcodes_error_handler): Define. (@arch@_cgen_rebuild_tables): Use opcodes_error_handler. (@arch@_cgen_cpu_open): Likewise. * opc-asmdis.scm (@arch@_cgen_parse_operand): Likewise. (@arch@_cgen_print_operand): Likewise. * opc-ibld.scm (@arch@_cgen_get_int_operand): Likewise. (@arch@_cgen_get_vma_operand): Likewise. (@arch@_cgen_set_int_operand): Likewise. (@arch@_cgen_set_vma_operand): Likewise. (@arch@_cgen_insert_operand): Likewise. (@arch@_cgen_extract_operand): Likewise. * utils.scm: Update emitted copyright dates. --- ChangeLog | 15 +++++++++++++++ desc-cpu.scm | 23 ++++++++++++++++++----- opc-asmdis.scm | 11 +++++++---- opc-ibld.scm | 30 ++++++++++++++++++------------ utils.scm | 4 ++-- 5 files changed, 60 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4741f3b..4f22b47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2018-03-03 Alan Modra + + * desc-cpu.scm (opcodes_error_handler): Define. + (@arch@_cgen_rebuild_tables): Use opcodes_error_handler. + (@arch@_cgen_cpu_open): Likewise. + * opc-asmdis.scm (@arch@_cgen_parse_operand): Likewise. + (@arch@_cgen_print_operand): Likewise. + * opc-ibld.scm (@arch@_cgen_get_int_operand): Likewise. + (@arch@_cgen_get_vma_operand): Likewise. + (@arch@_cgen_set_int_operand): Likewise. + (@arch@_cgen_set_vma_operand): Likewise. + (@arch@_cgen_insert_operand): Likewise. + (@arch@_cgen_extract_operand): Likewise. + * utils.scm: Update emitted copyright dates. + 2017-04-13 Alan Modra PR 20946 diff --git a/desc-cpu.scm b/desc-cpu.scm index d67cb12..b24c9f2 100644 --- a/desc-cpu.scm +++ b/desc-cpu.scm @@ -588,6 +588,11 @@ static const CGEN_IBASE @arch@_cgen_insn_table[MAX_INSNS] = (define (/gen-cpu-open) (string-append "\ +#ifndef opcodes_error_handler +#define opcodes_error_handler(...) \\ + fprintf (stderr, __VA_ARGS__); fputc ('\\n', stderr) +#endif + static const CGEN_MACH * lookup_mach_via_bfd_name (const CGEN_MACH *, const char *); static void build_hw_table (CGEN_CPU_TABLE *); static void build_ifield_table (CGEN_CPU_TABLE *); @@ -748,8 +753,11 @@ static void { if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize) { - fprintf (stderr, \"@arch@_cgen_rebuild_tables: conflicting insn-chunk-bitsize values: `%d' vs. `%d'\\n\", - cd->insn_chunk_bitsize, mach->insn_chunk_bitsize); + opcodes_error_handler + (/* xgettext:c-format */ + _(\"internal error: @arch@_cgen_rebuild_tables: \" + \"conflicting insn-chunk-bitsize values: `%d' vs. `%d'\"), + cd->insn_chunk_bitsize, mach->insn_chunk_bitsize); abort (); } @@ -828,8 +836,11 @@ CGEN_CPU_DESC endian = va_arg (ap, enum cgen_endian); break; default : - fprintf (stderr, \"@arch@_cgen_cpu_open: unsupported argument `%d'\\n\", - arg_type); + opcodes_error_handler + (/* xgettext:c-format */ + _(\"internal error: @arch@_cgen_cpu_open: \" + \"unsupported argument `%d'\"), + arg_type); abort (); /* ??? return NULL? */ } arg_type = va_arg (ap, enum cgen_cpu_open_arg); @@ -844,7 +855,9 @@ CGEN_CPU_DESC if (endian == CGEN_ENDIAN_UNKNOWN) { /* ??? If target has only one, could have a default. */ - fprintf (stderr, \"@arch@_cgen_cpu_open: no endianness specified\\n\"); + opcodes_error_handler + (/* xgettext:c-format */ + _(\"internal error: @arch@_cgen_cpu_open: no endianness specified\")); abort (); } diff --git a/opc-asmdis.scm b/opc-asmdis.scm index 0ff01e1..6bdd44c 100644 --- a/opc-asmdis.scm +++ b/opc-asmdis.scm @@ -41,7 +41,9 @@ const char * " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while parsing.\\n\"), opindex); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while parsing\"), + opindex); abort (); } @@ -136,9 +138,10 @@ void " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while printing insn.\\n\"), - opindex); - abort (); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while printing insn\"), + opindex); + abort (); } }\n\n") ) diff --git a/opc-ibld.scm b/opc-ibld.scm index b2e637d..2390292 100644 --- a/opc-ibld.scm +++ b/opc-ibld.scm @@ -30,8 +30,9 @@ int " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while getting int operand.\\n\"), - opindex); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while getting int operand\"), + opindex); abort (); } @@ -52,8 +53,9 @@ bfd_vma " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while getting vma operand.\\n\"), - opindex); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while getting vma operand\"), + opindex); abort (); } @@ -87,8 +89,9 @@ void " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while setting int operand.\\n\"), - opindex); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while setting int operand\"), + opindex); abort (); } } @@ -106,8 +109,9 @@ void " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while setting vma operand.\\n\"), - opindex); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while setting vma operand\"), + opindex); abort (); } } @@ -197,8 +201,9 @@ const char * " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while building insn.\\n\"), - opindex); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while building insn\"), + opindex); abort (); } @@ -247,8 +252,9 @@ int " default : /* xgettext:c-format */ - fprintf (stderr, _(\"Unrecognized field %d while decoding insn.\\n\"), - opindex); + opcodes_error_handler + (_(\"internal error: unrecognized field %d while decoding insn\"), + opindex); abort (); } diff --git a/utils.scm b/utils.scm index ebad6b2..5d3578b 100644 --- a/utils.scm +++ b/utils.scm @@ -1310,7 +1310,7 @@ (cons "\ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 1996-2017 Free Software Foundation, Inc. +Copyright (C) 1996-2018 Free Software Foundation, Inc. " "\ This file is free software; you can redistribute it and/or modify @@ -1335,7 +1335,7 @@ Copyright (C) 1996-2017 Free Software Foundation, Inc. (cons "\ THIS FILE IS MACHINE GENERATED WITH CGEN. -Copyright (C) 2000-2017 Red Hat, Inc. +Copyright (C) 2000-2018 Red Hat, Inc. " "\ ")) -- 2.43.5