This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Patch: Simulator for 64-bit CPU now writes correct gmon.out files
- From: Holger Teutsch <holger dot a dot teutsch at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Sat, 9 Feb 2013 17:40:35 +0100
- Subject: Patch: Simulator for 64-bit CPU now writes correct gmon.out files
Hi,
GDB's simulator as of 7.5.1 did not write out correct "gmon.out" files
for 64-bit CPUs.
The attached patch adds this functionality.
- holger
Proposed Changelog:
2013-02-09 Holger Teutsch <holger.a.teutsch@gmail.com>
* sim-profile.c (profile_print_pc): Write out correct gmon.out
file for 64-bit cpus.
Patch:
--- sim-profile.c-orig 2013-01-28 09:29:46.981112221 +0100
+++ sim-profile.c 2013-01-28 10:02:18.837989551 +0100
@@ -704,28 +704,72 @@ profile_print_pc (sim_cpu *cpu, int verb
else
{
int ok;
- /* FIXME: what if the target has a 64 bit PC? */
- unsigned32 header[3];
unsigned loop;
- if (PROFILE_PC_END (profile) != 0)
+
+ /* 32 bit case */
+ if (sizeof (IADDR) <= 4)
{
- header[0] = PROFILE_PC_START (profile);
- header[1] = PROFILE_PC_END (profile);
+ unsigned32 header[3];
+
+ if (PROFILE_PC_END (profile) != 0)
+ {
+ header[0] = PROFILE_PC_START (profile);
+ header[1] = PROFILE_PC_END (profile);
+ }
+ else
+ {
+ header[0] = 0;
+ header[1] = 0;
+ }
+ /* size of sample buffer (+ header) */
+ header[2] = PROFILE_PC_NR_BUCKETS (profile) * 2 + sizeof (header);
+
+ /* Header must be written out in target byte order. */
+ H2T (header[0]);
+ H2T (header[1]);
+ H2T (header[2]);
+
+ ok = fwrite (&header, sizeof (header), 1, pf);
}
else
{
- header[0] = 0;
- header[1] = 0;
- }
- /* size of sample buffer (+ header) */
- header[2] = PROFILE_PC_NR_BUCKETS (profile) * 2 + sizeof (header);
+ /* A BSD44_64 header */
+ struct raw_phdr
+ {
+ unsigned64 low_pc;
+ unsigned64 high_pc;
+ unsigned32 ncnt;
+ unsigned32 version;
+ unsigned32 profrate;
+ char spare[3*4];
+ } header;
- /* Header must be written out in target byte order. */
- H2T (header[0]);
- H2T (header[1]);
- H2T (header[2]);
+ if (PROFILE_PC_END (profile) != 0)
+ {
+ header.low_pc = PROFILE_PC_START (profile);
+ header.high_pc = PROFILE_PC_END (profile);
+ }
+ else
+ {
+ header.low_pc = 0;
+ header.high_pc = 0;
+ }
+
+ /* size of sample buffer (+ header) */
+ header.ncnt = PROFILE_PC_NR_BUCKETS (profile) * 2 + sizeof (header);
+ header.version = 0x00051879; /* GMONVERSION */
+ header.profrate =
+ PROFILE_CPU_FREQ (profile) / PROFILE_PC_FREQ (profile);
+
+ H2T (header.low_pc);
+ H2T (header.high_pc);
+ H2T (header.ncnt);
+ H2T (header.version);
+ H2T (header.profrate);
+
+ ok = fwrite (&header, sizeof (header), 1, pf);
+ }
- ok = fwrite (&header, sizeof (header), 1, pf);
for (loop = 0;
ok && (loop < PROFILE_PC_NR_BUCKETS (profile));
loop++)