public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: constify watchpoint interrupt names
@ 2010-03-29 21:49 Mike Frysinger
  2010-03-30 16:19 ` Tom Tromey
  2010-03-30 22:53 ` Hans-Peter Nilsson
  0 siblings, 2 replies; 10+ messages in thread
From: Mike Frysinger @ 2010-03-29 21:49 UTC (permalink / raw)
  To: gdb-patches

GCC issues warnings because const strings like "foo" are passed as char*.
sim-watch.c: In function 'watchpoint_type_to_str':
sim-watch.c:120: warning: return discards qualifiers from pointer target type
sim-watch.c:122: warning: return discards qualifiers from pointer target type
sim-watch.c:124: warning: return discards qualifiers from pointer target type
sim-watch.c:127: warning: return discards qualifiers from pointer target type
sim-watch.c: In function 'interrupt_nr_to_str':
sim-watch.c:138: warning: return discards qualifiers from pointer target type
sim-watch.c:140: warning: return discards qualifiers from pointer target type
sim-watch.c: At top level:
sim-watch.c:385: warning: initialization discards qualifiers from pointer target type
sim-watch.c: In function 'sim_watchpoint_install':
sim-watch.c:430: warning: initialization discards qualifiers from pointer target type

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
2010-03-29  Mike Frysinger  <vapier@gentoo.org>

	* sim-watch.c (watchpoint_type_to_str): Add const to return.
	(interrupt_nr_to_str): Likewise.
	(default_interrupt_names): Add const to pointer type.
	(sim_watchpoint_install): Add const to prefix.
	* sim-watch.h (struct _sim_watchpoints): Add const to interrupt_names.

 sim/common/sim-watch.c |    8 ++++----
 sim/common/sim-watch.h |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sim/common/sim-watch.c b/sim/common/sim-watch.c
index df8e1b8..17125af 100644
--- a/sim/common/sim-watch.c
+++ b/sim/common/sim-watch.c
@@ -109,7 +109,7 @@ do_watchpoint_delete (SIM_DESC sd,
   return status;
 }
 
-static char *
+static const char *
 watchpoint_type_to_str (SIM_DESC sd,
 			watchpoint_type type)
 {
@@ -128,7 +128,7 @@ watchpoint_type_to_str (SIM_DESC sd,
   return NULL;
 }
 
-static char *
+static const char *
 interrupt_nr_to_str (SIM_DESC sd,
 		     int interrupt_nr)
 {
@@ -381,7 +381,7 @@ static const OPTION watchpoint_options[] =
   { {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL }
 };
 
-static char *default_interrupt_names[] = { "int", 0, };
+static const char *default_interrupt_names[] = { "int", 0, };
 
 
 
@@ -425,7 +425,7 @@ sim_watchpoint_install (SIM_DESC sd)
     /* adjust first few entries so that they contain real
        documentation, the first entry includes a list of actions. */
     {
-      char *prefix = 
+      const char *prefix =
 	"Watch the simulator, take ACTION in COUNT cycles (`+' for every COUNT cycles), ACTION is";
       char *doc;
       int len = strlen (prefix) + 1;
diff --git a/sim/common/sim-watch.h b/sim/common/sim-watch.h
index 65be89f..2945f8d 100644
--- a/sim/common/sim-watch.h
+++ b/sim/common/sim-watch.h
@@ -63,7 +63,7 @@ typedef struct _sim_watchpoints {
   /* FIXME: can this be done better?  Look at the PPC's interrupt
      mechanism and table for a rough idea of where it will go next */
   int nr_interrupts;
-  char **interrupt_names;
+  const char **interrupt_names;
 
   /* active watchpoints */
   int last_point_nr;
-- 
1.7.0.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-29 21:49 [PATCH] sim: constify watchpoint interrupt names Mike Frysinger
@ 2010-03-30 16:19 ` Tom Tromey
  2010-03-30 22:53 ` Hans-Peter Nilsson
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Tromey @ 2010-03-30 16:19 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

>>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes:

Mike> 2010-03-29  Mike Frysinger  <vapier@gentoo.org>
Mike> 	* sim-watch.c (watchpoint_type_to_str): Add const to return.
Mike> 	(interrupt_nr_to_str): Likewise.
Mike> 	(default_interrupt_names): Add const to pointer type.
Mike> 	(sim_watchpoint_install): Add const to prefix.
Mike> 	* sim-watch.h (struct _sim_watchpoints): Add const to interrupt_names.

This is ok, thanks.

Tom

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-29 21:49 [PATCH] sim: constify watchpoint interrupt names Mike Frysinger
  2010-03-30 16:19 ` Tom Tromey
@ 2010-03-30 22:53 ` Hans-Peter Nilsson
  2010-03-30 23:07   ` Mike Frysinger
  1 sibling, 1 reply; 10+ messages in thread
From: Hans-Peter Nilsson @ 2010-03-30 22:53 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

On Mon, 29 Mar 2010, Mike Frysinger wrote:
> 	* sim-watch.h (struct _sim_watchpoints): Add const to interrupt_names.

Either the above or one of your other committs to this area,
caused, for v850-elf (beware of linewrapped cutnpaste):

gcc -c -DHAVE_CONFIG_H     -DPROFILE=1 -DWITH_PROFILE=-1
-DWITH_DEFAULT_ALIGNMENT=NONSTRICT_ALIGNMENT
-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31
-DWITH_TARGET_BYTE_ORDER=LITTLE_ENDIAN
-DWITH_HOST_BYTE_ORDER=LITTLE_ENDIAN -DDEFAULT_INLINE=0
-DWITH_RESERVED_BITS=1    -Wimplicit -Wreturn-type -Wcomment
-Wtrigraphs -Wformat -Wparentheses -Wpointer-arith
-Wuninitialized    -DDEBUG
-I/tmp/hpautotest-sim/src/sim/v850/../../newlib/libc/sys/sysnecv850
-I. -I/tmp/hpautotest-sim/src/sim/v850 -I../common
-I/tmp/hpautotest-sim/src/sim/v850/../common -I../../include
-I/tmp/hpautotest-sim/src/sim/v850/../../include -I../../bfd
-I/tmp/hpautotest-sim/src/sim/v850/../../bfd -I../../opcodes
-I/tmp/hpautotest-sim/src/sim/v850/../../opcodes  -g -O2
/tmp/hpautotest-sim/src/sim/v850/interp.c
/tmp/hpautotest-sim/src/sim/v850/interp.c: In function
'do_interrupt':
/tmp/hpautotest-sim/src/sim/v850/interp.c:70: error: invalid
operands to binary -
/tmp/hpautotest-sim/src/sim/v850/interp.c: In function
'sim_open':
/tmp/hpautotest-sim/src/sim/v850/interp.c:210: warning:
assignment from incompatible pointer type
make[3]: Leaving directory
`/tmp/hpautotest-sim/v850-elf/sim/v850'
make[2]: Leaving directory `/tmp/hpautotest-sim/v850-elf/sim'
make[1]: Leaving directory `/tmp/hpautotest-sim/v850-elf'
make[3]: *** [interp.o] Error 1

Host gcc is gcc-4.4.3 (actually gcc-4.4.3-4.fc12.x86_64).

brgds, H-P

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-30 22:53 ` Hans-Peter Nilsson
@ 2010-03-30 23:07   ` Mike Frysinger
  2010-03-30 23:21     ` Hans-Peter Nilsson
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2010-03-30 23:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Hans-Peter Nilsson

[-- Attachment #1: Type: Text/Plain, Size: 1346 bytes --]

On Tuesday 30 March 2010 18:53:17 Hans-Peter Nilsson wrote:
> On Mon, 29 Mar 2010, Mike Frysinger wrote:
> > 	* sim-watch.h (struct _sim_watchpoints): Add const to interrupt_names.
> 
> Either the above or one of your other committs to this area,
> caused, for v850-elf (beware of linewrapped cutnpaste):

it was this one

> /tmp/hpautotest-sim/src/sim/v850/interp.c: In function
> 'do_interrupt':
> /tmp/hpautotest-sim/src/sim/v850/interp.c:70: error: invalid
> operands to binary -
> /tmp/hpautotest-sim/src/sim/v850/interp.c: In function
> 'sim_open':
> /tmp/hpautotest-sim/src/sim/v850/interp.c:210: warning:
> assignment from incompatible pointer type

this should fix it:
RCS file: /cvs/src/src/sim/v850/interp.c,v
retrieving revision 1.4
diff -u -p -r1.4 interp.c
--- interp.c	5 Sep 2003 17:46:52 -0000	1.4
+++ interp.c	30 Mar 2010 23:06:58 -0000
@@ -48,7 +48,7 @@ enum interrupt_type
   num_int_types
 };
 
-char *interrupt_names[] = {
+const char *interrupt_names[] = {
   "reset",
   "nmi",
   "intov1",
@@ -65,7 +65,7 @@ do_interrupt (sd, data)
      SIM_DESC sd;
      void *data;
 {
-  char **interrupt_name = (char**)data;
+  const char **interrupt_name = (const char**)data;
   enum interrupt_type inttype;
   inttype = (interrupt_name - STATE_WATCHPOINTS (sd)->interrupt_names);
 
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-30 23:07   ` Mike Frysinger
@ 2010-03-30 23:21     ` Hans-Peter Nilsson
  2010-03-30 23:42       ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Hans-Peter Nilsson @ 2010-03-30 23:21 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

On Tue, 30 Mar 2010, Mike Frysinger wrote:
> On Tuesday 30 March 2010 18:53:17 Hans-Peter Nilsson wrote:
> > On Mon, 29 Mar 2010, Mike Frysinger wrote:
> > > 	* sim-watch.h (struct _sim_watchpoints): Add const to interrupt_names.
> >
> > Either the above or one of your other committs to this area,
> > caused, for v850-elf (beware of linewrapped cutnpaste):

> this should fix it:

Feel free to commit with a suitable ChangeLog entry if
tests pass.

brgds, H-P

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-30 23:21     ` Hans-Peter Nilsson
@ 2010-03-30 23:42       ` Mike Frysinger
  2010-03-31  1:20         ` Doug Evans
  2010-03-31  1:46         ` Hans-Peter Nilsson
  0 siblings, 2 replies; 10+ messages in thread
From: Mike Frysinger @ 2010-03-30 23:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Hans-Peter Nilsson

[-- Attachment #1: Type: Text/Plain, Size: 812 bytes --]

On Tuesday 30 March 2010 19:20:56 Hans-Peter Nilsson wrote:
> On Tue, 30 Mar 2010, Mike Frysinger wrote:
> > On Tuesday 30 March 2010 18:53:17 Hans-Peter Nilsson wrote:
> > > On Mon, 29 Mar 2010, Mike Frysinger wrote:
> > > > 	* sim-watch.h (struct _sim_watchpoints): Add const to
> > > > 	interrupt_names.
> > > 
> > > Either the above or one of your other committs to this area,
> > 
> > > caused, for v850-elf (beware of linewrapped cutnpaste):
> > this should fix it:
>
> Feel free to commit with a suitable ChangeLog entry if
> tests pass.

they do pass, and this reminds me of why dejagnu is so damn annoying.  a 
simple `make check-sim` fails by default because the sim framework attempts to 
execute the binary on the host instead of through the sim.  seems pretty dumb 
to me.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-30 23:42       ` Mike Frysinger
@ 2010-03-31  1:20         ` Doug Evans
  2010-03-31  1:46         ` Hans-Peter Nilsson
  1 sibling, 0 replies; 10+ messages in thread
From: Doug Evans @ 2010-03-31  1:20 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches, Hans-Peter Nilsson

On Tue, Mar 30, 2010 at 4:41 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> they do pass, and this reminds me of why dejagnu is so damn annoying.  a
> simple `make check-sim` fails by default because the sim framework attempts to
> execute the binary on the host instead of through the sim.  seems pretty dumb
> to me.

I'm guessing a patch to sim/testsuite/lib/sim-defs.exp to catch this
would be trivial.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-30 23:42       ` Mike Frysinger
  2010-03-31  1:20         ` Doug Evans
@ 2010-03-31  1:46         ` Hans-Peter Nilsson
  2010-03-31  3:42           ` Mike Frysinger
  2010-03-31 23:43           ` Doug Evans
  1 sibling, 2 replies; 10+ messages in thread
From: Hans-Peter Nilsson @ 2010-03-31  1:46 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

On Tue, 30 Mar 2010, Mike Frysinger wrote:
> On Tuesday 30 March 2010 19:20:56 Hans-Peter Nilsson wrote:
> > Feel free to commit with a suitable ChangeLog entry if
> > tests pass.
>
> they do pass, and this reminds me of why dejagnu is so damn annoying.  a
> simple `make check-sim` fails by default because the sim framework attempts to
> execute the binary on the host instead of through the sim.  seems pretty dumb
> to me.

JFTR, you're supposed to specify a "board", like so:
"make check-sim RUNTESTFLAGS=--target_board=v850-sim" but you
know that as you have run tests.

Target executable files always default to the host (through
"unix.exp" aka. --target_board=unix).  That you're testing the
simulator itself by running the target executable files there is
just a special-case, but anyway I guess it'd be a good idea
(read: feel free to send patches) for the simulator Makefile.in
to default to its dejagnu board when running the tests, e.g. to
default RUNTESTFLAGS to the above.  ...or maybe even better, as
Doug suggested.

brgds, H-P
PS. thanks for the quick turnaround, my autotester is pacified.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-31  1:46         ` Hans-Peter Nilsson
@ 2010-03-31  3:42           ` Mike Frysinger
  2010-03-31 23:43           ` Doug Evans
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2010-03-31  3:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Hans-Peter Nilsson

[-- Attachment #1: Type: Text/Plain, Size: 1443 bytes --]

On Tuesday 30 March 2010 21:45:54 Hans-Peter Nilsson wrote:
> On Tue, 30 Mar 2010, Mike Frysinger wrote:
> > On Tuesday 30 March 2010 19:20:56 Hans-Peter Nilsson wrote:
> > > Feel free to commit with a suitable ChangeLog entry if
> > > tests pass.
> > 
> > they do pass, and this reminds me of why dejagnu is so damn annoying.  a
> > simple `make check-sim` fails by default because the sim framework
> > attempts to execute the binary on the host instead of through the sim. 
> > seems pretty dumb to me.
> 
> JFTR, you're supposed to specify a "board", like so:
> "make check-sim RUNTESTFLAGS=--target_board=v850-sim"

thanks

> but you know that as you have run tests.

i hacked the .exp locally to force the run binary

> Target executable files always default to the host (through
> "unix.exp" aka. --target_board=unix).  That you're testing the
> simulator itself by running the target executable files there is
> just a special-case, but anyway I guess it'd be a good idea
> (read: feel free to send patches) for the simulator Makefile.in
> to default to its dejagnu board when running the tests, e.g. to
> default RUNTESTFLAGS to the above.  ...or maybe even better, as
> Doug suggested.

i agree that the default behavior for other dirs makes sense, but i think the 
sim should default to the sim instead of the host because of the nature of it

i'd have to ponder how to actually implement it
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] sim: constify watchpoint interrupt names
  2010-03-31  1:46         ` Hans-Peter Nilsson
  2010-03-31  3:42           ` Mike Frysinger
@ 2010-03-31 23:43           ` Doug Evans
  1 sibling, 0 replies; 10+ messages in thread
From: Doug Evans @ 2010-03-31 23:43 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: Mike Frysinger, gdb-patches

On Tue, Mar 30, 2010 at 6:45 PM, Hans-Peter Nilsson <hp@bitrange.com> wrote:
> On Tue, 30 Mar 2010, Mike Frysinger wrote:
>> On Tuesday 30 March 2010 19:20:56 Hans-Peter Nilsson wrote:
>> > Feel free to commit with a suitable ChangeLog entry if
>> > tests pass.
>>
>> they do pass, and this reminds me of why dejagnu is so damn annoying.  a
>> simple `make check-sim` fails by default because the sim framework attempts to
>> execute the binary on the host instead of through the sim.  seems pretty dumb
>> to me.
>
> JFTR, you're supposed to specify a "board", like so:
> "make check-sim RUNTESTFLAGS=--target_board=v850-sim" but you
> know that as you have run tests.
>
> Target executable files always default to the host (through
> "unix.exp" aka. --target_board=unix).  That you're testing the
> simulator itself by running the target executable files there is
> just a special-case, but anyway I guess it'd be a good idea
> (read: feel free to send patches) for the simulator Makefile.in
> to default to its dejagnu board when running the tests, e.g. to
> default RUNTESTFLAGS to the above.  ...or maybe even better, as
> Doug suggested.

For reference sake,
an alternative to explicitly passing --target_board is to point
$DEJAGNU at a file that specifies what target to use, e.g. based on
target-triplet/tool.

The m32r case I use is mildly interesting.  The syntax is clumsy, but
I keep it around to remind me how to automagically run multiple
variations with one "make check".

A "make check" of m32r produces:

                === sim tests ===

Schedule of variations:
    m32r-sim/-mmodel=small/-G 0/-m32r
    m32r-sim/-mmodel=small/-G 0/-m32rx
    m32r-sim/-mmodel=small/-msdata=use -G 8/-m32r
    m32r-sim/-mmodel=small/-msdata=use -G 8/-m32rx
    m32r-sim/-mmodel=medium/-G 0/-m32r
    m32r-sim/-mmodel=medium/-G 0/-m32rx
    m32r-sim/-mmodel=medium/-msdata=use -G 8/-m32r
    m32r-sim/-mmodel=medium/-msdata=use -G 8/-m32rx
    m32r-sim/-mmodel=large/-G 0/-m32r
    m32r-sim/-mmodel=large/-G 0/-m32rx
    m32r-sim/-mmodel=large/-msdata=use -G 8/-m32r
    m32r-sim/-mmodel=large/-msdata=use -G 8/-m32rx

Running target m32r-sim/-mmodel=small/-G 0/-m32r
Using /usr/share/dejagnu/baseboards/m32r-sim.exp as board description
file for target.
[...]

[There's also the MULTIPASS/PASS vars to control running multiple
passes in one "make check" if one wants to do that kind of thing.]


In case it helps, here's $DEJAGNU from one of my systems:

--- snip ---

set run_multiple_targets 1

send_user "target_triplet: $target_triplet\n"
if [info exists tool] {
    send_user "tool: $tool\n"
}

switch -glob "$target_triplet" {

    "arm-*-elf" {
        if { "$tool" == "sim" } {
            set target_list { arm-sim }
        } else {
            set target_list { arm-sid }
        }
    }

    "powerpc-*-*" {
        set target_list { powerpc-sim }
    }

    "powerpcle-*-*" {
        set target_list { powerpcle-sim }
    }

    "m32r-*-elf*" {
        if { $run_multiple_targets } {
            set target_list
{{{m32r-sim{-mmodel=small,-mmodel=medium,-mmodel=large}{-G
0,-msdata=use -G 8}}{-m32r,-m32rx}}}
        } else {
            set target_list { m32r-sim }
        }
    }

    "i?86-*-nacl*" {
        set target_list "nacl"
    }

    "i?86-*-*" {
        set target_list { unix }
    }

    "x86_64-*-*" {
        set target_list { unix }
    }

    "i960-*-coff" {
        set target_list { i960-sim }
    }

    "cris-*-elf" {
        set target_list { cris-sim }
    }

    "fr30-*-elf" {
        set target_list { fr30-sim }
    }

    "frv-*-elf" {
        set target_list { frv-sim }
    }

    "ip2k-*-elf" {
        set target_list { ip2k-sim }
    }

    "iq2000-*-elf" {
        set target_list { iq2000-sim }
    }

    "lm32-*-elf" {
        set target_list { lm32-sim }
    }

    "m32c-*-elf" {
        set target_list { m32c-sim }
    }

    "m68hc08-*-*" {
        set target_list { m68hc08-sim }
    }

    "mep-*-elf" {
        set target_list { mep-sim }
    }

    "mt-*-elf" {
        set target_list { mt-sim }
    }

    "openrisc-*-elf" {
        set target_list { openrisc-sim }
    }

    "or32-*-elf" {
        set target_list { openrisc-sim }
    }

    "sh64-*-elf" {
        set target_list { sh64-sim }
    }

    "xc16x-*-elf" {
        set target_list { xc16x-sim }
    }

    "xstormy16-*-elf" {
        set target_list { xstormy16-sid }
    }

    default {
        send_user "ERROR: dejagnu.exp Unknown target $target_triplet\n"
        exit 1
    }
}

if [info exists target_list] {
    send_user "target_list: $target_list\n"
} else {
    send_user "target_list: unspecified\n"
}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-03-31 23:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-29 21:49 [PATCH] sim: constify watchpoint interrupt names Mike Frysinger
2010-03-30 16:19 ` Tom Tromey
2010-03-30 22:53 ` Hans-Peter Nilsson
2010-03-30 23:07   ` Mike Frysinger
2010-03-30 23:21     ` Hans-Peter Nilsson
2010-03-30 23:42       ` Mike Frysinger
2010-03-31  1:20         ` Doug Evans
2010-03-31  1:46         ` Hans-Peter Nilsson
2010-03-31  3:42           ` Mike Frysinger
2010-03-31 23:43           ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).