From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id AD4C038582BC for ; Wed, 12 Oct 2022 09:39:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD4C038582BC Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-139-njpRCjATOnWyOsiPJZLcFw-1; Wed, 12 Oct 2022 05:39:29 -0400 X-MC-Unique: njpRCjATOnWyOsiPJZLcFw-1 Received: by mail-wm1-f71.google.com with SMTP id i5-20020a1c3b05000000b003c47c8569easo879355wma.1 for ; Wed, 12 Oct 2022 02:39:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qdU5yS+NcQko/clTyG/UlhaYIrqKfBeEI4YEkMI43G0=; b=hmbC6/cTUtBrVnUmIcUjvUOXNwZKcGM0p3sXJ079mLa5UDT4yjhCiLufXiiR5QNA17 th/qeZ53OdvJj/ITBFiqUJSMjKA4ZT5Ww1YVPIW8as4QEOG2xWK0VIGtrbOejFdo62v0 vjiT2Mm3w6NPeVBqlMqc+DhDWejCthQl86cM3GBNjJhkIKBfVyvjGtNKNEXMLekSW1A+ KiNeKXUQ7YO8b0I6jme/gbtKfmUnXDLDU60Ac8eVi/ycD4PdtF2h72spZvh5qQ4sngRR CgcI4wJ4VeI2/3Lpq5olPHS0quy4azh9GktUtXS6OfLhgP73nH98/ecZ8GduGdSEz0Zp zsUw== X-Gm-Message-State: ACrzQf03/gpeB/rdccyfr2DEdN93W9dV9A7p7njFSMuZatKake7O9asX F7tq2tNwK28S5DMNTaFF7I2U972k3nqM30x3k4TH2+7o6W1LtvTULyBtiI9IWB6Eqd2lW9nJ6Fa xfRVIBJvQqkXqq5+lb9mqiw== X-Received: by 2002:a05:6000:1888:b0:22f:a5af:c9c5 with SMTP id a8-20020a056000188800b0022fa5afc9c5mr12032669wri.631.1665567566848; Wed, 12 Oct 2022 02:39:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Fu9fD1vWZvHgnw2PMKN6kTnfy6wbUJNNvpzfL55slYWUg/7pm386cXl3SJ25QKx/KyAGsXQ== X-Received: by 2002:a05:6000:1888:b0:22f:a5af:c9c5 with SMTP id a8-20020a056000188800b0022fa5afc9c5mr12032655wri.631.1665567566564; Wed, 12 Oct 2022 02:39:26 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id s3-20020adfdb03000000b0022e309d35f8sm13174112wri.12.2022.10.12.02.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:39:26 -0700 (PDT) From: Andrew Burgess To: Jan-Benedict Glaw Cc: Tsukasa OI , Mike Frysinger , Stephane Carrez , "Frank Ch . Eigler" , gdb-patches@sourceware.org Subject: Re: [PATCH v2 6/7] sim/ppc: Add ATTRIBUTE_PRINTF In-Reply-To: <20221012082940.44hq4m7qkudpvyl5@lug-owl.de> References: <9ee0350e33400397851bb55c129a675519e5f174.1665038133.git.research_trasio@irq.a4lg.com> <8735bucu5p.fsf@redhat.com> <20221012082940.44hq4m7qkudpvyl5@lug-owl.de> Date: Wed, 12 Oct 2022 10:39:25 +0100 Message-ID: <87wn95bctu.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Oct 2022 09:39:32 -0000 Jan-Benedict Glaw writes: > On Tue, 2022-10-11 15:27:30 +0100, Andrew Burgess via Gdb-patches wrote: >> Tsukasa OI writes: >> >> > Clang generates a warning if the format string of a printf-like function is >> > not a literal ("-Wformat-nonliteral"). On the default configuration, it >> > causes a build failure (unless "--disable-werror" is specified). >> > >> > To avoid warnings on the printf-like wrapper, it requires proper >> > __attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason. >> > >> > This commit adds ATTRIBUTE_PRINTF to the printf-like functions. >> >> I've pushed this patch, but I moved all the ATTRIBUTE_PRINTF attributes >> to the function declarations. >> >> Also, one of the definitions already had an ATTRIBUTE_NORETURN, I moved >> this to the declaration too. > > Building with a recent GCC, I get this: > > $ .../configure --prefix=/tmp/gdb-ppc-elf --target=ppc-elf > $ make V=1 all-gdb > [...] > /usr/lib/gcc-snapshot/bin/gcc -c -g -O2 -Werror -DDEFAULT_INLINE=0 -DWITH_SMP=5 -DHAVE_TERMIOS_STRUCTURE -DHAVE_TERMIOS_CLINE -DHAVE_DEVZERO -Wall -Wdeclaration-after-statement -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wno-error=maybe-uninitialized -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wpointer-sign -Wold-style-declaration -I. -I. -I./../../include -I../../bfd -I./../../bfd -I../../gdb -I./../../gdb -I./../../gdb/config -I../.. -I./../../gnulib/import -I../../gnulib/import -DHAVE_COMMON_FPU -I../common -I./../common emul_generic.c > /usr/lib/gcc-snapshot/bin/gcc -c -g -O2 -Werror -DDEFAULT_INLINE=0 -DWITH_SMP=5 -DHAVE_TERMIOS_STRUCTURE -DHAVE_TERMIOS_CLINE -DHAVE_DEVZERO -Wall -Wdeclaration-after-statement -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wno-error=maybe-uninitialized -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wpointer-sign -Wold-style-declaration -I. -I. -I./../../include -I../../bfd -I./../../bfd -I../../gdb -I./../../gdb -I./../../gdb/config -I../.. -I./../../gnulib/import -I../../gnulib/import -DHAVE_COMMON_FPU -I../common -I./../common emul_bugapi.c > emul_bugapi.c: In function 'emul_bugapi_instruction_call': > emul_bugapi.c:495:11: error: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'spreg' {aka 'unsigned int'} [-Werror=format=] > 495 | error("emul-bugapi: unimplemented bugapi %s from address 0x%lx\n", > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: all warnings being treated as errors > make[3]: *** [Makefile:144: emul_bugapi.o] Error 1 > make[3]: Leaving directory '/var/lib/laminar/run/gdb-ppc-elf/6/binutils-gdb/sim/ppc' > make[2]: *** [Makefile:1933: all-recursive] Error 1 > make[2]: Leaving directory '/var/lib/laminar/run/gdb-ppc-elf/6/binutils-gdb/sim' > make[1]: *** [Makefile:1185: all] Error 2 > make[1]: Leaving directory '/var/lib/laminar/run/gdb-ppc-elf/6/binutils-gdb/sim' > make: *** [Makefile:11309: all-sim] Error 2 Sorry for the breakage. I've pushed the patch below, which I think should resolve the issue you are seeing, as well as some other, similar issues in the ppc sim. Let me know if you are still seeing build problems with the latest master. Thanks, Andrew --- commit 182421c9d2eea8c4877d983a2124e591f0aca710 Author: Andrew Burgess Date: Tue Oct 11 15:02:08 2022 +0100 sim/ppc: fixes for arguments to printf style functions 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. This commit fixes all of the issues that I ran into. 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 --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 = mapping->next; } if (abort) - error("core_find_mapping() - access to unmaped address, attach a default map to handle this - addr=0x%x nr_bytes=0x%x processor=0x%x cia=0x%x\n", - addr, nr_bytes, processor, cia); + error("core_find_mapping() - access to unmaped address, attach a default map to handle this - addr=0x%x nr_bytes=0x%x processor=0x%p cia=0x%x\n", + addr, nr_bytes, (void *) processor, cia); return NULL; } 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; /* read a single character, output r3 = 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, sizeof(name)); + error("chirp: note name too long (%d > %d)\n", (int)head.namesz, (int)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, too 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, with 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 = 0; - error("internal error - instruction_storage_interrupt - reason %d not implemented"); + error("internal error - instruction_storage_interrupt - reason %d not implemented", reason); break; } TRACE(trace_interrupts, ("instruction storage interrupt - cia=0x%lx SRR1|=0x%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 += 1; if (argv[*ptr_to_argp] == NULL) - error(err_msg); + error("%s", err_msg); return argv[*ptr_to_argp]; } @@ -535,7 +535,7 @@ psim_create(const char *file_name, if (ppc_trace[trace_print_device_tree] || ppc_trace[trace_dump_device_tree]) tree_print(root); if (ppc_trace[trace_dump_device_tree]) - error(""); + error("%s", ""); 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, description)) { 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') == NULL) {