1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <nel/misc/types_nl.h>
18 #include <nel/misc/common.h>
33 bool readString (string
&str
, FILE *file
)
36 while ((c
= fgetc (file
)))
45 int main(int argc
, char* argv
[])
50 while (fgets(buffer
, 512, stdin
))
53 if (strcmp (buffer
, "help") == 0)
55 printf ("Commands available:\n");
56 printf ("help | Show this help\n");
57 printf ("address [memoryaddress] | Show history of this address\n");
59 printf ("memoryaddress must be like this: 8b125df\n");
61 else if (sscanf (buffer
, "address %x", &address
) == 1)
63 printf ("0x%x history:\n", address
);
64 // Read the memory log
65 FILE *file
= fopen (argv
[1], "rb");
69 if (fread (&size
, sizeof(uint32
), 1, file
) != 1)
79 if (fread (&start
, sizeof(uint32
), 1, file
) != 1)
83 NLMISC_BSWAP32(start
);
87 if (!readString (category
, file
))
90 if (start
<= address
&& address
< (start
+size
))
91 printf ("0x%x (%d bytes) %s\n", start
, size
, category
.c_str ());
99 fprintf (stderr
, "Can't open the file %s for reading\n", argv
[1]);
104 printf ("Command unknown, try help\n");
110 printf ("memlog [filename.memlog]\n");