From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 4D7553856DD6; Wed, 12 Oct 2022 09:37:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D7553856DD6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665567454; bh=XC5F+A89ps3AIsBSLI19V5QNbBkxCWgeQWiD05GfYss=; h=From:To:Subject:Date:From; b=GHrQZJQcII2gukvybUjwXvMNx1mQtpEeG2AQVXI0gfqz923W4HhW8oqZn+HogV78C KT3+UevWfoU4mqCIkETUO+/RHDIjiy2ladOD3OT93o/YViGs9P0IPyEAmH2Uc5tAai EOlgEPBOIiBS1oAvCLpVhi+kQ+XH1pdBFEPhCxT0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim/ppc: fixes for arguments to printf style functions X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 33fb3d6f140b03062b6bce2065a44b3c8a42ba62 X-Git-Newrev: 182421c9d2eea8c4877d983a2124e591f0aca710 Message-Id: <20221012093734.4D7553856DD6@sourceware.org> Date: Wed, 12 Oct 2022 09:37:34 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D182421c9d2ee= a8c4877d983a2124e591f0aca710 commit 182421c9d2eea8c4877d983a2124e591f0aca710 Author: Andrew Burgess Date: Tue Oct 11 15:02:08 2022 +0100 sim/ppc: fixes for arguments to printf style functions =20 After the recent series of fixes to mark more functions in the simulator with ATTRIBUTE_PRINTF, there were some build failures in the ppc sim due, in some cases, to bugs with the arguments being passed, and in other cases, the issues were (maybe) less serious, with arguments being the wrong size, or type, for the printf format being used. =20 This commit fixes all of the issues that I ran into. =20 In each case I selected the easiest solution to the problem, which is usually just casting the argument to the correct type. If anyone later on thinks the print format should change, please feel free to do that. What we have here should keep the simulator basically working as it does currently, which is my goal with this commit. Diff: --- sim/ppc/corefile.c | 4 ++-- sim/ppc/emul_bugapi.c | 2 +- sim/ppc/emul_chirp.c | 4 +++- sim/ppc/interrupts.c | 2 +- sim/ppc/psim.c | 6 +++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sim/ppc/corefile.c b/sim/ppc/corefile.c index 1b3eeef8b53..b2faef58c5b 100644 --- a/sim/ppc/corefile.c +++ b/sim/ppc/corefile.c @@ -292,8 +292,8 @@ core_map_find_mapping(core_map *map, mapping =3D mapping->next; } if (abort) - error("core_find_mapping() - access to unmaped address, attach a defau= lt map to handle this - addr=3D0x%x nr_bytes=3D0x%x processor=3D0x%x cia=3D= 0x%x\n", - addr, nr_bytes, processor, cia); + error("core_find_mapping() - access to unmaped address, attach a defau= lt map to handle this - addr=3D0x%x nr_bytes=3D0x%x processor=3D0x%p cia=3D= 0x%x\n", + addr, nr_bytes, (void *) processor, cia); return NULL; } =20 diff --git a/sim/ppc/emul_bugapi.c b/sim/ppc/emul_bugapi.c index c3c607b43f0..f4eed443d8b 100644 --- a/sim/ppc/emul_bugapi.c +++ b/sim/ppc/emul_bugapi.c @@ -493,7 +493,7 @@ emul_bugapi_instruction_call(cpu *processor, switch (call_id) { default: error("emul-bugapi: unimplemented bugapi %s from address 0x%lx\n", - emul_bugapi_instruction_name (call_id), SRR0); + emul_bugapi_instruction_name (call_id), (unsigned long) SRR0); break; =20 /* read a single character, output r3 =3D byte */ diff --git a/sim/ppc/emul_chirp.c b/sim/ppc/emul_chirp.c index 7a585388f63..116f3732ac7 100644 --- a/sim/ppc/emul_chirp.c +++ b/sim/ppc/emul_chirp.c @@ -1509,7 +1509,7 @@ map_over_chirp_note(bfd *image, return; /* check the name field */ if (head.namesz > sizeof(name)) { - error("chirp: note name too long (%d > %d)\n", (int)head.namesz, siz= eof(name)); + error("chirp: note name too long (%d > %d)\n", (int)head.namesz, (in= t)sizeof(name)); } if (!bfd_get_section_contents(image, sect, name, sizeof(head), head.namesz)) { @@ -1971,12 +1971,14 @@ emul_chirp_instruction_call(cpu *processor, } if (emul_data->n_args > 6) { /* See iee1275 requirements on nr returns= */ error("OpenFirmware service %s called from 0x%lx with args 0x%lx, to= o many args (%d)\n", + service_name, (unsigned long)emul_data->return_address, (unsigned long)emul_data->arguments, emul_data->n_returns); } if (emul_data->n_returns > 6) { error("OpenFirmware service %s called from 0x%lx with args 0x%lx, w= ith too many returns (%d)\n", + service_name, (unsigned long)emul_data->return_address, (unsigned long)emul_data->arguments, emul_data->n_args); diff --git a/sim/ppc/interrupts.c b/sim/ppc/interrupts.c index 133638fdcaf..a33274aa562 100644 --- a/sim/ppc/interrupts.c +++ b/sim/ppc/interrupts.c @@ -234,7 +234,7 @@ instruction_storage_interrupt(cpu *processor, break; default: srr1_set =3D 0; - error("internal error - instruction_storage_interrupt - reason %d not imp= lemented"); + error("internal error - instruction_storage_interrupt - reason %d not imp= lemented", reason); break; } TRACE(trace_interrupts, ("instruction storage interrupt - cia=3D0x%l= x SRR1|=3D0x%lx\n", diff --git a/sim/ppc/psim.c b/sim/ppc/psim.c index 9f1db675e50..acc40edf8aa 100644 --- a/sim/ppc/psim.c +++ b/sim/ppc/psim.c @@ -99,7 +99,7 @@ find_arg(const char *err_msg, { *ptr_to_argp +=3D 1; if (argv[*ptr_to_argp] =3D=3D NULL) - error(err_msg); + error("%s", err_msg); return argv[*ptr_to_argp]; } =20 @@ -535,7 +535,7 @@ psim_create(const char *file_name, if (ppc_trace[trace_print_device_tree] || ppc_trace[trace_dump_device_tr= ee]) tree_print(root); if (ppc_trace[trace_dump_device_tree]) - error(""); + error("%s", ""); =20 return system; } @@ -1186,7 +1186,7 @@ psim_merge_device_file(device *root, /* append the next line */ if (!fgets(device_path + curlen, sizeof(device_path) - curlen, descr= iption)) { fclose(description); - error("%s:%s: unexpected eof in line continuation - %s", + error("%s:%d: unexpected eof in line continuation - %s", file_name, line_nr, device_path); } if (strchr(device_path, '\n') =3D=3D NULL) {