* [fyi] fix mips-tdep.c -Wprintf(a?"%d":"%d%d", ...)
@ 2001-02-20 15:49 Andrew Cagney
2001-02-21 2:27 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2001-02-20 15:49 UTC (permalink / raw)
To: GDB Patches
Hello,
I've checked in the attatched. A GCC variant didn't like conditional
formats vis:
printf (cond ? "arg1=%d" : "arg1=%d arg2+%d", arg1, arg2);
(can't say that I like them much either mind :-)
Andrew
2001-02-20 Andrew Cagney <ac131313@redhat.com>
* mips-tdep.c (do_fp_register_row, do_fp_register_row): Fix printf
formatting.
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.41
diff -p -r1.41 mips-tdep.c
*** mips-tdep.c 2001/02/20 03:38:32 1.41
--- mips-tdep.c 2001/02/20 23:39:15
*************** do_fp_register_row (int regnum)
*** 2677,2688 ****
flt2 = unpack_double (builtin_type_float, raw_buffer[LO], &inv2);
doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);
! printf_filtered (inv1 ? " %-5s: <invalid float>" :
! " %-5s%-17.9g", REGISTER_NAME (regnum), flt1);
! printf_filtered (inv2 ? " %-5s: <invalid float>" :
! " %-5s%-17.9g", REGISTER_NAME (regnum + 1), flt2);
! printf_filtered (inv3 ? " dbl: <invalid double>\n" :
! " dbl: %-24.17g\n", doub);
/* may want to do hex display here (future enhancement) */
regnum += 2;
}
--- 2677,2701 ----
flt2 = unpack_double (builtin_type_float, raw_buffer[LO], &inv2);
doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);
! printf_filtered (" %-5s", REGISTER_NAME (regnum));
! if (inv1)
! printf_filtered (": <invalid float>");
! else
! printf_filtered ("%-17.9g", flt1);
!
! printf_filtered (" %-5s", REGISTER_NAME (regnum + 1));
! if (inv2)
! printf_filtered (": <invalid float>");
! else
! printf_filtered ("%-17.9g", flt2);
!
! printf_filtered (" dbl: ");
! if (inv3)
! printf_filtered ("<invalid double>");
! else
! printf_filtered ("%-24.17g", doub);
! printf_filtered ("\n");
!
/* may want to do hex display here (future enhancement) */
regnum += 2;
}
*************** do_fp_register_row (int regnum)
*** 2694,2704 ****
flt1 = unpack_double (builtin_type_float,
&raw_buffer[HI][offset], &inv1);
doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);
! printf_filtered (inv1 ? " %-5s: <invalid float>" :
! " %-5s flt: %-17.9g", REGISTER_NAME (regnum), flt1);
! printf_filtered (inv3 ? " dbl: <invalid double>\n" :
! " dbl: %-24.17g\n", doub);
/* may want to do hex display here (future enhancement) */
regnum++;
}
--- 2707,2726 ----
flt1 = unpack_double (builtin_type_float,
&raw_buffer[HI][offset], &inv1);
doub = unpack_double (builtin_type_double, dbl_buffer, &inv3);
+
+ printf_filtered (" %-5s: ", REGISTER_NAME (regnum));
+ if (inv1)
+ printf_filtered ("<invalid float>");
+ else
+ printf_filtered ("flt: %-17.9g", flt1);
+
+ printf_filtered (" dbl: ");
+ if (inv3)
+ printf_filtered ("<invalid double>");
+ else
+ printf_filtered ("%-24.17g", doub);
! printf_filtered ("\n");
/* may want to do hex display here (future enhancement) */
regnum++;
}
From kevinb@cygnus.com Tue Feb 20 15:51:00 2001
From: Kevin Buettner <kevinb@cygnus.com>
To: gdb-patches@sourceware.cygnus.com
Subject: [PATCH] solib-aix5.c cleanups
Date: Tue, 20 Feb 2001 15:51:00 -0000
Message-id: <1010220235140.ZM26652@ocotillo.lan>
X-SW-Source: 2001-02/msg00406.html
Content-length: 7218
Most of the changes below were suggested by J.T. Conklin in
http://sources.redhat.com/ml/gdb-patches/2001-02/msg00403.html
In the above message, J.T. also noted that in_svr4_dynsym_resolve_code()
collides with a function of the same name in solib-svr4.c. This
problem is not fixed in the patch below; I will address this problem
separately as the solution that I have in mind will affect several
other files too.
I wish to thank J.T. for promptly reviewing my changes and suggesting
these cleanups.
* solib-aix5.c (solib-svr4.h): Remove include.
(solib_break_names): Delete names which aren't actually
used by AIX5.
(bkpt_names): Remove.
(aix5_relocate_main_executable, bfd_lookup_symbol): Replace calls
to STREQ() with equivalent calls to strcmp().
(in_svr4_dynsym_resolve_code, enable_break, bfd_lookup_symbol,
aix5_solib_create_inferior_hook): Revise comments.
(enable_break): Remove old ``bkpt_names'' code.
Index: solib-aix5.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-aix5.c,v
retrieving revision 1.1
diff -u -p -r1.1 solib-aix5.c
--- solib-aix5.c 2001/02/20 20:43:12 1.1
+++ solib-aix5.c 2001/02/20 23:39:45
@@ -46,7 +46,6 @@
#include "gdbcmd.h"
#include "solist.h"
-#include "solib-svr4.h"
/* Link map info to include in an allocated so_list entry */
@@ -71,33 +70,15 @@ struct lm_info
char *membername; /* member name in archive file */
};
-/* On SVR4 systems, a list of symbols in the dynamic linker where
- GDB can try to place a breakpoint to monitor shared library
- events.
-
- If none of these symbols are found, or other errors occur, then
- SVR4 systems will fall back to using a symbol as the "startup
- mapping complete" breakpoint address. */
+/* List of symbols in the dynamic linker where GDB can try to place
+ a breakpoint to monitor shared library events. */
static char *solib_break_names[] =
{
- "r_debug_state",
"_r_debug_state",
- "_dl_debug_state",
- "rtld_db_dlactivity",
NULL
};
-static char *bkpt_names[] =
-{
-#ifdef SOLIB_BKPT_NAME
- SOLIB_BKPT_NAME, /* Prefer configured name if it exists. */
-#endif
- "_start",
- "main",
- NULL
-};
-
static void aix5_relocate_main_executable (void);
/*
@@ -143,7 +124,7 @@ bfd_lookup_symbol (bfd *abfd, char *symn
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
- if (STREQ (sym->name, symname))
+ if (strcmp (sym->name, symname) == 0)
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
@@ -156,8 +137,7 @@ bfd_lookup_symbol (bfd *abfd, char *symn
if (symaddr)
return symaddr;
- /* On FreeBSD, the dynamic linker is stripped by default. So we'll
- have to check the dynamic string table too. */
+ /* Look for the symbol in the dynamic string table too. */
storage_needed = bfd_get_dynamic_symtab_upper_bound (abfd);
/* FIXME: This problem should be addressed in BFD. */
@@ -174,7 +154,7 @@ bfd_lookup_symbol (bfd *abfd, char *symn
for (i = 0; i < number_of_symbols; i++)
{
sym = *symbol_table++;
- if (STREQ (sym->name, symname))
+ if (strcmp (sym->name, symname) == 0)
{
/* Bfd symbols are section relative. */
symaddr = sym->value + sym->section->vma;
@@ -422,7 +402,7 @@ aix5_current_sos (void)
/* Return 1 if PC lies in the dynamic symbol resolution code of the
- SVR4 run time loader. */
+ run time loader. */
static CORE_ADDR interp_text_sect_low;
static CORE_ADDR interp_text_sect_high;
@@ -449,36 +429,11 @@ in_svr4_dynsym_resolve_code (CORE_ADDR p
int enable_break (void)
DESCRIPTION
+
+ The dynamic linkers has, as part of its debugger interface, support
+ for arranging for the inferior to hit a breakpoint after mapping in
+ the shared libraries. This function enables that breakpoint.
- Both the SunOS and the SVR4 dynamic linkers have, as part of their
- debugger interface, support for arranging for the inferior to hit
- a breakpoint after mapping in the shared libraries. This function
- enables that breakpoint.
-
- For SunOS, there is a special flag location (in_debugger) which we
- set to 1. When the dynamic linker sees this flag set, it will set
- a breakpoint at a location known only to itself, after saving the
- original contents of that place and the breakpoint address itself,
- in it's own internal structures. When we resume the inferior, it
- will eventually take a SIGTRAP when it runs into the breakpoint.
- We handle this (in a different place) by restoring the contents of
- the breakpointed location (which is only known after it stops),
- chasing around to locate the shared libraries that have been
- loaded, then resuming.
-
- For SVR4, the debugger interface structure contains a member (r_brk)
- which is statically initialized at the time the shared library is
- built, to the offset of a function (_r_debug_state) which is guaran-
- teed to be called once before mapping in a library, and again when
- the mapping is complete. At the time we are examining this member,
- it contains only the unrelocated offset of the function, so we have
- to do our own relocation. Later, when the dynamic linker actually
- runs, it relocates r_brk to be the actual address of _r_debug_state().
-
- The debugger interface structure also contains an enumeration which
- is set to either RT_ADD or RT_DELETE prior to changing the mapping,
- depending upon whether or not the library is being mapped or unmapped,
- and then set to RT_CONSISTENT after the library is mapped/unmapped.
*/
static int
@@ -582,19 +537,6 @@ enable_break (void)
warning ("Unable to find dynamic linker breakpoint function.\nGDB will be unable to debug shared library initializers\nand track explicitly loaded dynamic code.");
}
- /* Scan through the list of symbols, trying to look up the symbol and
- set a breakpoint there. Terminate loop when we/if we succeed. */
-
- for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
- {
- msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile);
- if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
- {
- create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol));
- return 1;
- }
- }
-
/* Nothing good happened. */
success = 0;
@@ -714,11 +656,11 @@ aix5_relocate_main_executable (void)
point, this function gets called via expansion of the macro
SOLIB_CREATE_INFERIOR_HOOK.
- For SVR4 executables, this first instruction is either the first
+ For AIX5 executables, this first instruction is the first
instruction in the dynamic linker (for dynamically linked
executables) or the instruction at "start" for statically linked
executables. For dynamically linked executables, the system
- first exec's /lib/libc.so.N, which contains the dynamic linker,
+ first exec's libc.so.N, which contains the dynamic linker,
and starts it running. The dynamic linker maps in any needed
shared libraries, maps in the actual user executable, and then
jumps to "start" in the user executable.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [fyi] fix mips-tdep.c -Wprintf(a?"%d":"%d%d", ...)
2001-02-20 15:49 [fyi] fix mips-tdep.c -Wprintf(a?"%d":"%d%d", ...) Andrew Cagney
@ 2001-02-21 2:27 ` Eli Zaretskii
2001-02-21 10:30 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2001-02-21 2:27 UTC (permalink / raw)
To: Andrew Cagney; +Cc: GDB Patches
On Tue, 20 Feb 2001, Andrew Cagney wrote:
> I've checked in the attatched. A GCC variant didn't like conditional
> formats vis:
>
> printf (cond ? "arg1=%d" : "arg1=%d arg2+%d", arg1, arg2);
That's one of my gripes with latest versions of GCC (which version did
you use, btw?): this change caused lots of valid C code to start
emitting tons of warnings. Ulrich Drepper tried to change GCC
maintainers' minds on this one (evidently, glibc uses such expressions
in printf's), to no avail IIRC.
Isn't there a compiler switch to turn this warning off? Perhaps we
should use it instead of ``fixing'' that which isn't broken.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [fyi] fix mips-tdep.c -Wprintf(a?"%d":"%d%d", ...)
2001-02-21 2:27 ` Eli Zaretskii
@ 2001-02-21 10:30 ` Andrew Cagney
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2001-02-21 10:30 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: GDB Patches
Eli Zaretskii wrote:
>
> On Tue, 20 Feb 2001, Andrew Cagney wrote:
>
> > I've checked in the attatched. A GCC variant didn't like conditional
> > formats vis:
> >
> > printf (cond ? "arg1=%d" : "arg1=%d arg2+%d", arg1, arg2);
>
> That's one of my gripes with latest versions of GCC (which version did
> you use, btw?): this change caused lots of valid C code to start
> emitting tons of warnings. Ulrich Drepper tried to change GCC
> maintainers' minds on this one (evidently, glibc uses such expressions
> in printf's), to no avail IIRC.
>
> Isn't there a compiler switch to turn this warning off? Perhaps we
> should use it instead of ``fixing'' that which isn't broken.
ac131313@localhost$ gcc --version
egcs-1.1.2
but I know it is lieing - there should be a ``+ NetBSD patches''
appended.
The warning comes from the ``-Wprintf'' flag so I think fixing this
little nuance is far less of a hassle than dropping -Wprintf. (To be
honest, I personally don't like the ``?:'' operator - I can't debug it -
so I don't object to this ``fix'' :-).
The other thing to keep in mind is that the ui_out interface strongly
discourages the above convention. What was:
> printf (cond ? "arg1=%d" : "arg1=%d arg2+%d", arg1, arg2);
and I rewrote to something like:
printf ("arg1=");
printf ("%d", arg1);
if (cond)
{
printf (" arg2+");
printf ("%d", arg2);
}
will eventually be written as something like:
ui_out_text ("arg1=");
ui_out_int (arg1, fmt, "arg1");
if (cond)
{
ui_out_text (" arg2+");
ui_out_int (arg2, fmt, "arg2");
}
so I'm in a way just helping the code along a little :-)
enjoy,
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-02-21 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-20 15:49 [fyi] fix mips-tdep.c -Wprintf(a?"%d":"%d%d", ...) Andrew Cagney
2001-02-21 2:27 ` Eli Zaretskii
2001-02-21 10:30 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox