* RFA: Make --memory-info work for MIPS simulators
@ 2007-08-10 10:38 Nick Clifton
2007-09-03 17:14 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2007-08-10 10:38 UTC (permalink / raw)
To: ths, ths; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1728 bytes --]
Hi Thiemo,
The --memory-info command line switch (and its alias --info-memory)
do not work for the MIPS simulator because the memory regions are
not set up until after the command line has been parsed. The
attached patch fixes this by delaying the processing of
--memory-info until after the regions have been initialized.
The patch does have one slightly dubious component - it removes the
mips specific command line options table from the linked list of
options tables once the command line has been processed. It does
this so that the real handler for --memory-info can be called via
the sim_do_commandf() function. I think that this is safe, since
there is no longer any need to process mips specific command line
switches.
Before the patch:
% mips64vrel-elf-run --memory-info a.out
Memory maps:
After the patch:
% mips64vrel-elf-run --memory-info a.out
Memory maps:
memory region 0x7fff8000,0x8000
memory alias 0xa0000000@0x1,0x20000000%0x800000,0x80000000@0x1
May I apply this patch please ?
Cheers
Nick
PS. The sim/MAINTAINERS file has your email address as
<ths@networkno.de>, judging from the ChangeLog though, I guessed that
this was incorrect.
sim/mips/ChangeLog
2007-08-10 Nick Clifton <nickc@redhat.com>
* interp.c (options enum): Add OPTION_INFO_MEMORY.
(display_mem_info): New static variable.
(mips_option_handler): Handle OPTION_INFO_MEMORY.
(mips_options): Add info-memory and memory-info.
(sim_open): After processing the command line and board
specification, check display_mem_info. If it is set then
call the real handler for the --memory-info command line
switch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: interp.c.patch --]
[-- Type: text/x-patch, Size: 2902 bytes --]
Index: sim/mips/interp.c
===================================================================
RCS file: /cvs/src/src/sim/mips/interp.c,v
retrieving revision 1.23
diff -c -3 -p -r1.23 interp.c
*** sim/mips/interp.c 19 Feb 2007 17:46:53 -0000 1.23
--- sim/mips/interp.c 10 Aug 2007 10:29:49 -0000
*************** enum {
*** 180,188 ****
--- 180,190 ----
OPTION_DINERO_TRACE = OPTION_START,
OPTION_DINERO_FILE,
OPTION_FIRMWARE,
+ OPTION_INFO_MEMORY,
OPTION_BOARD
};
+ static int display_mem_info = 0;
static SIM_RC
mips_option_handler (sd, cpu, opt, arg, is_command)
*************** Re-compile simulator with \"-DTRACE\" to
*** 259,264 ****
--- 261,270 ----
}
return SIM_RC_OK;
}
+
+ case OPTION_INFO_MEMORY:
+ display_mem_info = 1;
+ break;
}
return SIM_RC_OK;
*************** static const OPTION mips_options[] =
*** 290,295 ****
--- 296,315 ----
, "Customize simulation for a particular board.", mips_option_handler },
+ /* These next two options have the same names as ones found in the
+ memory_options[] array in common/sim-memopt.c. This is because
+ the intention is to provide an alternative handler for those two
+ options. We need an alternative handler because the memory
+ regions are not set up until after the command line arguments
+ have been parsed, and so we cannot display the memory info whilst
+ processing the command line. There is a hack in sim_open to
+ remove these handlers when we want the real --memory-info option
+ to work. */
+ { { "info-memory", no_argument, NULL, OPTION_INFO_MEMORY },
+ '\0', NULL, "List configured memory regions", mips_option_handler },
+ { { "memory-info", no_argument, NULL, OPTION_INFO_MEMORY },
+ '\0', NULL, NULL, mips_option_handler },
+
{ {NULL, no_argument, NULL, 0}, '\0', NULL, NULL, NULL }
};
*************** sim_open (kind, cb, abfd, argv)
*** 587,592 ****
--- 607,637 ----
}
#endif
+ if (display_mem_info)
+ {
+ struct option_list * ol;
+ struct option_list * prev;
+
+ /* This is a hack. We want to execute the real --memory-info command
+ line switch which is handled in common/sim-memopts.c, not the
+ override we have defined in this file. So we remove the
+ mips_options array from the state options list. This is safe
+ because we have now processed all of the command line. */
+ for (ol = STATE_OPTIONS (sd), prev = NULL;
+ ol != NULL;
+ prev = ol, ol = ol->next)
+ if (ol->options == mips_options)
+ break;
+
+ SIM_ASSERT (ol != NULL);
+
+ if (prev == NULL)
+ STATE_OPTIONS (sd) = ol->next;
+ else
+ prev->next = ol->next;
+
+ sim_do_commandf (sd, "memory-info");
+ }
/* check for/establish the a reference program image */
if (sim_analyze_program (sd,
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: RFA: Make --memory-info work for MIPS simulators
2007-08-10 10:38 RFA: Make --memory-info work for MIPS simulators Nick Clifton
@ 2007-09-03 17:14 ` Daniel Jacobowitz
2007-09-03 17:45 ` Thiemo Seufer
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-09-03 17:14 UTC (permalink / raw)
To: Nick Clifton; +Cc: ths, ths, gdb-patches
On Fri, Aug 10, 2007 at 11:38:10AM +0100, Nick Clifton wrote:
> sim/mips/ChangeLog
> 2007-08-10 Nick Clifton <nickc@redhat.com>
>
> * interp.c (options enum): Add OPTION_INFO_MEMORY.
> (display_mem_info): New static variable.
> (mips_option_handler): Handle OPTION_INFO_MEMORY.
> (mips_options): Add info-memory and memory-info.
> (sim_open): After processing the command line and board
> specification, check display_mem_info. If it is set then
> call the real handler for the --memory-info command line
> switch.
I didn't see any response to this patch. I think it's OK to commit,
though.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: Make --memory-info work for MIPS simulators
2007-09-03 17:14 ` Daniel Jacobowitz
@ 2007-09-03 17:45 ` Thiemo Seufer
2007-09-04 14:34 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Thiemo Seufer @ 2007-09-03 17:45 UTC (permalink / raw)
To: Nick Clifton, gdb-patches
Daniel Jacobowitz wrote:
> On Fri, Aug 10, 2007 at 11:38:10AM +0100, Nick Clifton wrote:
> > sim/mips/ChangeLog
> > 2007-08-10 Nick Clifton <nickc@redhat.com>
> >
> > * interp.c (options enum): Add OPTION_INFO_MEMORY.
> > (display_mem_info): New static variable.
> > (mips_option_handler): Handle OPTION_INFO_MEMORY.
> > (mips_options): Add info-memory and memory-info.
> > (sim_open): After processing the command line and board
> > specification, check display_mem_info. If it is set then
> > call the real handler for the --memory-info command line
> > switch.
>
> I didn't see any response to this patch. I think it's OK to commit,
> though.
I sent the appended email on 2007-08-13, it seems it didn't reach the
list for some reason.
Thiemo
From ths@networkno.de Mon Aug 13 18:15:43 2007
Date: Mon, 13 Aug 2007 18:15:43 +0100
From: Thiemo Seufer <ths@networkno.de>
To: Nick Clifton <nickc@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: Make --memory-info work for MIPS simulators
Message-ID: <20070813171543.GB19507@networkno.de>
References: <m33ayrfze5.fsf@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <m33ayrfze5.fsf@redhat.com>
User-Agent: Mutt/1.5.16 (2007-06-11)
Status: RO
Content-Length: 2065
Lines: 58
Nick Clifton wrote:
> Hi Thiemo,
>
> The --memory-info command line switch (and its alias --info-memory)
> do not work for the MIPS simulator because the memory regions are
> not set up until after the command line has been parsed. The
> attached patch fixes this by delaying the processing of
> --memory-info until after the regions have been initialized.
>
> The patch does have one slightly dubious component - it removes the
> mips specific command line options table from the linked list of
> options tables once the command line has been processed. It does
> this so that the real handler for --memory-info can be called via
> the sim_do_commandf() function. I think that this is safe, since
> there is no longer any need to process mips specific command line
> switches.
>
> Before the patch:
>
> % mips64vrel-elf-run --memory-info a.out
> Memory maps:
>
> After the patch:
>
> % mips64vrel-elf-run --memory-info a.out
> Memory maps:
> memory region 0x7fff8000,0x8000
> memory alias 0xa0000000@0x1,0x20000000%0x800000,0x80000000@0x1
>
> May I apply this patch please ?
>
> Cheers
> Nick
>
> PS. The sim/MAINTAINERS file has your email address as
> <ths@networkno.de>, judging from the ChangeLog though, I guessed that
> this was incorrect.
In the Changelog I use the mips.com mail address for changes which are
covered by the MTI copyright assignment, the networkno.de address is
for contributions which fall under my personal copyright assignment.
> sim/mips/ChangeLog
> 2007-08-10 Nick Clifton <nickc@redhat.com>
>
> * interp.c (options enum): Add OPTION_INFO_MEMORY.
> (display_mem_info): New static variable.
> (mips_option_handler): Handle OPTION_INFO_MEMORY.
> (mips_options): Add info-memory and memory-info.
> (sim_open): After processing the command line and board
> specification, check display_mem_info. If it is set then
> call the real handler for the --memory-info command line
> switch.
Ok.
Thiemo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-09-04 14:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-10 10:38 RFA: Make --memory-info work for MIPS simulators Nick Clifton
2007-09-03 17:14 ` Daniel Jacobowitz
2007-09-03 17:45 ` Thiemo Seufer
2007-09-04 14:34 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox