From patchwork Mon Jan 1 23:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83088 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 791633858287 for ; Mon, 1 Jan 2024 23:24:46 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 6BF8F3858413 for ; Mon, 1 Jan 2024 23:22:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BF8F3858413 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6BF8F3858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151358; cv=none; b=pIwh+ATWqQJiYgyURKKzGM20sk1E/ujxrk8P3df+8W9MHEpuxhB+7OSNSvczhgM8R4tTx3R6Yskd0EgoCjYXlQ37oJOpp+jDQQJ1cjkSXKL8r5cPWUKuOgmsisTJcxKyoq1zSktIoU0VSs+6pdEdhAMugAaXqyQ9uUDJNojgoWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151358; c=relaxed/simple; bh=30M+KfWtStOC1MvCz2YDy5KVyXZJCD/Ouc+o6Ol2QPc=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=rVaEBCWXwA01Qg62N3RfRZjfROzzVp3/z34tohrXTSbu6Cxqu4dJ/hqEQqHcER6VzfMGLhMKTSkRgFogyfXzKSQLu/+Z++tqJVQpsJcc7z5gCeq9ACLWV2Kp7/nsZlg6I4oalQFy5Gt2xtnjhzi72RlNo8N/JmsWpNMDFnbuhuQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 162EF340775; Mon, 1 Jan 2024 23:22:36 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 7/8] sim: ppc: rework igen error to match common Date: Mon, 1 Jan 2024 18:22:18 -0500 Message-ID: <20240101232219.3003-7-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Switch to an ERROR macro and tweak the error signature to match the common igen version in preparation for merging the two implementations. --- sim/ppc/gen-idecode.c | 2 +- sim/ppc/gen-model.c | 4 ++-- sim/ppc/igen.c | 4 ++-- sim/ppc/ld-cache.c | 2 +- sim/ppc/ld-decode.c | 2 +- sim/ppc/ld-insn.c | 14 +++++++------- sim/ppc/lf.c | 2 +- sim/ppc/misc.c | 8 ++++---- sim/ppc/misc.h | 7 +++++-- sim/ppc/table.c | 2 +- 10 files changed, 25 insertions(+), 22 deletions(-) diff --git a/sim/ppc/gen-idecode.c b/sim/ppc/gen-idecode.c index 256ba7586b89..5d2253500594 100644 --- a/sim/ppc/gen-idecode.c +++ b/sim/ppc/gen-idecode.c @@ -1543,6 +1543,6 @@ gen_idecode_c(lf *file, } else { - error("Something is wrong!\n"); + ERROR("Something is wrong!\n"); } } diff --git a/sim/ppc/gen-model.c b/sim/ppc/gen-model.c index a8bcc66e9f14..11a533b2d93a 100644 --- a/sim/ppc/gen-model.c +++ b/sim/ppc/gen-model.c @@ -52,7 +52,7 @@ model_c_or_h_function(insn_table *entry, { if (function->fields[function_type] == NULL || function->fields[function_type][0] == '\0') { - error("Model function type not specified for %s", function->fields[function_name]); + ERROR("Model function type not specified for %s", function->fields[function_name]); } lf_printf(file, "\n"); lf_print_function_type(file, function->fields[function_type], prefix, " "); @@ -203,7 +203,7 @@ model_c_function(insn_table *table, { if (function->fields[function_type] == NULL || function->fields[function_type][0] == '\0') { - error("Model function return type not specified for %s", function->fields[function_name]); + ERROR("Model function return type not specified for %s", function->fields[function_name]); } else { lf_printf(file, "\n"); diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c index 61afa491bb9e..264d8086874a 100644 --- a/sim/ppc/igen.c +++ b/sim/ppc/igen.c @@ -450,7 +450,7 @@ main(int argc, code &= ~generate_with_icache; break; default: - error ("Expecting -Ggen-icache or -Ggen-icache=\n"); + ERROR ("Expecting -Ggen-icache or -Ggen-icache=\n"); } } break; @@ -568,7 +568,7 @@ main(int argc, real_file_name = NULL; break; default: - error("unknown option\n"); + ERROR("unknown option\n"); } } return 0; diff --git a/sim/ppc/ld-cache.c b/sim/ppc/ld-cache.c index 9a78f908b05a..a5d101daf6c9 100644 --- a/sim/ppc/ld-cache.c +++ b/sim/ppc/ld-cache.c @@ -115,7 +115,7 @@ main(int argc, char **argv) { cache_table *rules; if (argc != 3) - error("Usage: cache \n"); + ERROR("Usage: cache \n"); rules = load_cache_table(argv[1], a2i(argv[2])); dump_cache_rules(rules, 0); return 0; diff --git a/sim/ppc/ld-decode.c b/sim/ppc/ld-decode.c index 63c2c2e53d40..a631645f54de 100644 --- a/sim/ppc/ld-decode.c +++ b/sim/ppc/ld-decode.c @@ -143,7 +143,7 @@ main(int argc, char **argv) { decode_table *rules; if (argc != 3) - error("Usage: decode \n"); + ERROR("Usage: decode \n"); rules = load_decode_table(argv[1], a2i(argv[2])); dump_decode_rules(rules, 0); return 0; diff --git a/sim/ppc/ld-insn.c b/sim/ppc/ld-insn.c index 5cb72b226226..c11b449a58c1 100644 --- a/sim/ppc/ld-insn.c +++ b/sim/ppc/ld-insn.c @@ -110,7 +110,7 @@ parse_insn_format(table_entry *entry, /* sanity check */ if (!isdigit(*chp)) { - error("%s:%d: missing position field at `%s'\n", + ERROR("%s:%d: missing position field at `%s'\n", entry->file_name, entry->line_nr, chp); } @@ -122,7 +122,7 @@ parse_insn_format(table_entry *entry, if (*chp == '.' && strlen_pos > 0) chp++; else { - error("%s:%d: missing field value at %s\n", + ERROR("%s:%d: missing field value at %s\n", entry->file_name, entry->line_nr, chp); break; } @@ -137,7 +137,7 @@ parse_insn_format(table_entry *entry, if (*chp == ',') chp++; else if (*chp != '\0' || strlen_val == 0) { - error("%s:%d: missing field terminator at %s\n", + ERROR("%s:%d: missing field terminator at %s\n", entry->file_name, entry->line_nr, chp); break; } @@ -216,7 +216,7 @@ parse_include_entry (table *file, { /* parse the include file_entry */ if (file_entry->nr_fields < 4) - error ("Incorrect nr fields for include record\n"); + ERROR ("Incorrect nr fields for include record\n"); /* process it */ if (!is_filtered_out(file_entry->fields[include_flags], filters)) { @@ -326,7 +326,7 @@ insn_table_insert_insn(insn_table *table, } if (!model_ptr) - error("%s:%d: machine model `%s' was not known about\n", + ERROR("%s:%d: machine model `%s' was not known about\n", file_entry->file_name, file_entry->line_nr, name); } @@ -663,7 +663,7 @@ insn_table_find_opcode_field(insn *insns, curr_opcode->boolean_constant = rule->special_constant; break; default: - error("Something is going wrong\n"); + ERROR("Something is going wrong\n"); } return curr_opcode; @@ -979,7 +979,7 @@ main(int argc, char **argv) cache_table *cache_rules = NULL; if (argc != 5) - error("Usage: insn \n"); + ERROR("Usage: insn \n"); filters = new_filter(argv[1], filters); hi_bit_nr = a2i(argv[2]); diff --git a/sim/ppc/lf.c b/sim/ppc/lf.c index 9a9d6151c6e8..9deb2d2bb523 100644 --- a/sim/ppc/lf.c +++ b/sim/ppc/lf.c @@ -274,7 +274,7 @@ lf_print__c_code(lf *file, chp++; } if (in_bit_field) - error("bit field paren miss match some where\n"); + ERROR("bit field paren miss match some where\n"); if (*chp == '\n') { nr += lf_putchr(file, '\n'); chp++; diff --git a/sim/ppc/misc.c b/sim/ppc/misc.c index a281d62b0af1..9499101b6029 100644 --- a/sim/ppc/misc.c +++ b/sim/ppc/misc.c @@ -28,7 +28,7 @@ #include void -error (const char *msg, ...) +error (const void *line, const char *msg, ...) { va_list ap; va_start(ap, msg); @@ -42,7 +42,7 @@ zalloc(long size) { void *memory = malloc(size); if (memory == NULL) - error("zalloc failed\n"); + ERROR("zalloc failed\n"); memset(memory, 0, size); return memory; } @@ -186,7 +186,7 @@ name2i(const char *names, if (curr->i >= 0) return curr->i; else - error("%s contains no valid names\n", names); + ERROR("%s contains no valid names\n", names); return 0; } @@ -199,6 +199,6 @@ i2name(const int i, return map->name; map++; } - error("map lookup failed for %d\n", i); + ERROR("map lookup failed for %d\n", i); return NULL; } diff --git a/sim/ppc/misc.h b/sim/ppc/misc.h index 0073467863ad..243d5c93605a 100644 --- a/sim/ppc/misc.h +++ b/sim/ppc/misc.h @@ -28,8 +28,11 @@ #include "ansidecl.h" #include "filter_host.h" -extern void error (const char *msg, ...) - ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); +extern void error (const void *line, const char *msg, ...) + ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3); + +#define ERROR(EXPRESSION, args...) \ + error (NULL, EXPRESSION, ## args) #define ASSERT(EXPRESSION) \ do { \ diff --git a/sim/ppc/table.c b/sim/ppc/table.c index cb9a73aa8c49..0c5b6fcd925a 100644 --- a/sim/ppc/table.c +++ b/sim/ppc/table.c @@ -98,7 +98,7 @@ table_push (table *root, /* free (dup_name); */ if (include->next == NULL) { - error ("Problem opening file `%s'\n", file_name); + ERROR ("Problem opening file `%s'\n", file_name); perror (file_name); exit (1); }