This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Make procfs.c build warning free
- From: Pedro Alves <pedro at codesourcery dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 9 Oct 2008 14:51:33 +0100
- Subject: Re: Make procfs.c build warning free
- References: <200809090326.13826.pedro@codesourcery.com> <20080930002526.GD3811@adacore.com>
On Tuesday 30 September 2008 01:25:26, Joel Brobecker wrote:
> The changes look good to me (not that you really need my approval anymore
> :-). I didn't do a general audit, but I'm sure we can fix any warning as
> soon as one comes up.
Thanks Joel, sorry for the delay in coming back to this.
The reason for the delay, is that I found out that GDB doesn't
link anymore for me:
gcc -g -O2 \
-o gdb gdb.o libgdb.a \
../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a ./../intl/libintl.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -ldl -lcurses -lz -lsocket -lnsl -lm -lpython2.4 -lexpat ../libiberty/libiberty.a gnulib/libgnu.a
Undefined first referenced
symbol in file
elfcore_write_prpsinfo libgdb.a(procfs.o)
elfcore_write_prstatus libgdb.a(procfs.o)
ld: fatal: Symbol referencing errors. No output written to gdb
collect2: ld returned 1 exit status
make: *** [gdb] Error 1
Something changed in the bfd side, maybe related to the recent libtool update,
which triggers this while configuring bfd:
configure:18672: checking sys/procfs.h usability
configure:18684: gcc -c -g -O2 conftest.c >&5
In file included from /usr/include/sys/procfs.h:50,
from conftest.c:104:
/usr/include/sys/old_procfs.h:57:2: #error "Cannot use procfs in the large file compilation environment"
With the end result being that HAVE_PRPSINFO_T and HAVE_PSINFO_T
end up undefined in bfd's config.h, thus skipping including
elfcore_write_prpsinfo and elfcore_write_prstatus in libbfd.a (from bfd/elf.c).
bfd's configure is tripping on this in /usr/include/sys/old_procfs.h:
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#error "Cannot use procfs in the large file compilation environment"
#endif
Because bfd's configure is now noticing that _FILE_OFFSET_BITS is 64,
while it didn't a few weeks ago.
target/host/build: i386-pc-solaris2.11-gcc
$uname -a
SunOS opensolaris 5.11 snv_86 i86pc i386 i86pc Solaris
$gcc -v
Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/specs
Configured with: /builds/sfwnv-86/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++,f77,objc --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-20050802)
I was hoping to find time to investigate this and come up with a fix, but,
I haven't yet. This is unrelated, so I checked my patch in, as attached.
> I wish I had the time to clean this up a little bit and implement it
> properly...
Don't we all? :-)
> PS: I wonder which OSes use procfs through ioctl calls? Perhaps we could
> already greatly simplify the file if we could get rid of that part
> of the support (assuming this is for systems that are no longer
> in use).
--
Pedro Alves
2008-10-09 Pedro Alves <pedro@codesourcery.com>
Make it compile without warnings.
* procfs.c (create_procinfo): Initialize `parent'.
(dead_procinfo): Pass a constant string as format to error.
(procfs_address_to_host_pointer): Add cast to gdb_type *.
(procfs_find_LDT_entry): Adjust format string to long int
ptid.tid.
(procfs_xfer_partial): Adjust prototype. Add gdb_byte* cast.
(procfs_xfer_memory): Adjust prototype.
(info_mappings_callback, info_proc_mappings): Adjust to not pass a
variable as printf_filtered format.
(procfs_make_note_section): Change type of auxv local to gdb_byte.
* Makefile.in: Remove special rule.
---
gdb/Makefile.in | 6 ---
gdb/procfs.c | 89 ++++++++++++++++++++++++++++++--------------------------
2 files changed, 48 insertions(+), 47 deletions(-)
Index: src/gdb/procfs.c
===================================================================
--- src.orig/gdb/procfs.c 2008-10-08 01:05:35.000000000 +0100
+++ src/gdb/procfs.c 2008-10-09 14:24:40.000000000 +0100
@@ -126,13 +126,13 @@ static void procfs_kill_inferior (void);
static void procfs_mourn_inferior (void);
static void procfs_create_inferior (char *, char *, char **, int);
static ptid_t procfs_wait (ptid_t, struct target_waitstatus *);
-static int procfs_xfer_memory (CORE_ADDR, char *, int, int,
+static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
struct mem_attrib *attrib,
struct target_ops *);
static LONGEST procfs_xfer_partial (struct target_ops *ops,
enum target_object object,
const char *annex,
- void *readbuf, const void *writebuf,
+ gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, LONGEST len);
static int procfs_thread_alive (ptid_t);
@@ -715,7 +715,7 @@ open_procinfo_files (procinfo *pi, int w
static procinfo *
create_procinfo (int pid, int tid)
{
- procinfo *pi, *parent;
+ procinfo *pi, *parent = NULL;
if ((pi = find_procinfo (pid, tid)))
return pi; /* Already exists, nothing to do. */
@@ -866,7 +866,7 @@ dead_procinfo (procinfo *pi, char *msg,
kill (pi->pid, SIGKILL);
destroy_procinfo (pi);
- error ((msg));
+ error ("%s", msg);
}
/*
@@ -2902,7 +2902,8 @@ procfs_address_to_host_pointer (CORE_ADD
void *ptr;
gdb_assert (sizeof (ptr) == TYPE_LENGTH (ptr_type));
- gdbarch_address_to_pointer (target_gdbarch, ptr_type, &ptr, addr);
+ gdbarch_address_to_pointer (target_gdbarch, ptr_type,
+ (gdb_byte *) &ptr, addr);
return ptr;
}
@@ -3064,14 +3065,14 @@ procfs_find_LDT_entry (ptid_t ptid)
/* Find procinfo for the lwp. */
if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL)
{
- warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%d."),
+ warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%ld."),
PIDGET (ptid), TIDGET (ptid));
return NULL;
}
/* get its general registers. */
if ((gregs = proc_get_gregs (pi)) == NULL)
{
- warning (_("procfs_find_LDT_entry: could not read gregs for %d:%d."),
+ warning (_("procfs_find_LDT_entry: could not read gregs for %d:%ld."),
PIDGET (ptid), TIDGET (ptid));
return NULL;
}
@@ -4375,18 +4376,18 @@ wait_again:
static LONGEST
procfs_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, void *readbuf,
- const void *writebuf, ULONGEST offset, LONGEST len)
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
{
switch (object)
{
case TARGET_OBJECT_MEMORY:
if (readbuf)
- return (*ops->deprecated_xfer_memory) (offset, readbuf, len,
- 0/*read*/, NULL, ops);
+ return (*ops->deprecated_xfer_memory) (offset, readbuf,
+ len, 0/*read*/, NULL, ops);
if (writebuf)
- return (*ops->deprecated_xfer_memory) (offset, writebuf, len,
- 1/*write*/, NULL, ops);
+ return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf,
+ len, 1/*write*/, NULL, ops);
return -1;
#ifdef NEW_PROC_API
@@ -4415,7 +4416,7 @@ procfs_xfer_partial (struct target_ops *
negative values, but this capability isn't implemented here.) */
static int
-procfs_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite,
+procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
struct mem_attrib *attrib, struct target_ops *target)
{
procinfo *pi;
@@ -5780,23 +5781,28 @@ mappingflags (long flags)
static int
info_mappings_callback (struct prmap *map, int (*ignore) (), void *unused)
{
- char *data_fmt_string;
+ unsigned int pr_off;
- if (gdbarch_addr_bit (current_gdbarch) == 32)
- data_fmt_string = "\t%#10lx %#10lx %#10x %#10x %7s\n";
- else
- data_fmt_string = " %#18lx %#18lx %#10x %#10x %7s\n";
-
- printf_filtered (data_fmt_string,
- (unsigned long) map->pr_vaddr,
- (unsigned long) map->pr_vaddr + map->pr_size - 1,
- map->pr_size,
#ifdef PCAGENT /* Horrible hack: only defined on Solaris 2.6+ */
- (unsigned int) map->pr_offset,
+ pr_off = (unsigned int) map->pr_offset;
#else
- map->pr_off,
+ pr_off = map->pr_off;
#endif
- mappingflags (map->pr_mflags));
+
+ if (gdbarch_addr_bit (current_gdbarch) == 32)
+ printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
+ (unsigned long) map->pr_vaddr,
+ (unsigned long) map->pr_vaddr + map->pr_size - 1,
+ map->pr_size,
+ pr_off,
+ mappingflags (map->pr_mflags));
+ else
+ printf_filtered (" %#18lx %#18lx %#10x %#10x %7s\n",
+ (unsigned long) map->pr_vaddr,
+ (unsigned long) map->pr_vaddr + map->pr_size - 1,
+ map->pr_size,
+ pr_off,
+ mappingflags (map->pr_mflags));
return 0;
}
@@ -5810,23 +5816,24 @@ info_mappings_callback (struct prmap *ma
static void
info_proc_mappings (procinfo *pi, int summary)
{
- char *header_fmt_string;
-
- if (gdbarch_ptr_bit (current_gdbarch) == 32)
- header_fmt_string = "\t%10s %10s %10s %10s %7s\n";
- else
- header_fmt_string = " %18s %18s %10s %10s %7s\n";
-
if (summary)
return; /* No output for summary mode. */
printf_filtered (_("Mapped address spaces:\n\n"));
- printf_filtered (header_fmt_string,
- "Start Addr",
- " End Addr",
- " Size",
- " Offset",
- "Flags");
+ if (gdbarch_ptr_bit (current_gdbarch) == 32)
+ printf_filtered ("\t%10s %10s %10s %10s %7s\n",
+ "Start Addr",
+ " End Addr",
+ " Size",
+ " Offset",
+ "Flags");
+ else
+ printf_filtered (" %18s %18s %10s %10s %7s\n",
+ "Start Addr",
+ " End Addr",
+ " Size",
+ " Offset",
+ "Flags");
iterate_over_mappings (pi, NULL, NULL, info_mappings_callback);
printf_filtered ("\n");
@@ -6150,7 +6157,7 @@ procfs_make_note_section (bfd *obfd, int
char *note_data = NULL;
char *inf_args;
struct procfs_corefile_thread_data thread_args;
- char *auxv;
+ gdb_byte *auxv;
int auxv_len;
if (get_exec_file (0))
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in 2008-10-08 01:05:32.000000000 +0100
+++ src/gdb/Makefile.in 2008-10-09 14:24:40.000000000 +0100
@@ -1380,12 +1380,6 @@ printcmd.o: $(srcdir)/printcmd.c
$(GDB_WERROR_CFLAGS) $(COMPILE.post) $(srcdir)/printcmd.c
$(POSTCOMPILE)
-# FIXME: Procfs.o gets -Wformat errors because things like pid_t don't
-# match output format strings.
-procfs.o: $(srcdir)/procfs.c
- $(COMPILE.pre) $(INTERNAL_WARN_CFLAGS) $(COMPILE.post) $(srcdir)/procfs.c
- $(POSTCOMPILE)
-
# Message files. Based on code in gcc/Makefile.in.
# Rules for generating translated message descriptions. Disabled by