> Afternoon all, > > I have been working on a Firebird Internals manual for some time, and it > was built with the help of a small tool I wrote to dump out specific > pages from a database. The structs for each page were blatantly copied > from jrd/ods.h and when I compiled my app back then (ahem, 2009!) my gcc > version was 4.1.2 and all worked fine. > > On my own laptop I have gcc version 4.6.3 and I'm getting complete > garbage with the same source code. > > I suspect I'm falling foul of some gcc alignment/padding thing and I'm > wondering if anyone could point me in the right direction? > > At present I compile with a simple "gcc -o fbdump fbdump.c" and that's > the same on the old system and my laptop (exactly the same source.) > > As an example of how wrong it can be, here's a Firebird 2.5 employee > page header showing all sorts of errors: > > FBDUMP 1.00 - Firebird Page Dump Utility > > Parameters : -v -p 0 > Database: /var/lib/firebird/2.5/data/employee.fdb > > DATABASE PAGE DETAILS - Page 0 > PAGE HEADER > Page Type: 1 > Flags: 0 > Checksum: 12345 > Generation: 0 > SCN: 15033110528 > Reserved: 2993592205312 > PAGE DATA > Database Page Size: 698 > ODS Version: 0 > Pages: 240028567601152 > Next Page: 348481045616 > Oldest Transaction: 563031557799936 > Oldest Active: 6291458 > Next Transaction: 2997887172609 > Sequence: 0 > Flags: 0 > Creation Date: COMING SOON > Attachment Id: 0 > Shadow Count: 0 > Implementation: 0 > ODS minor: 0 > ODS minororiginal: 0 > HDR_END: 0 > Page Buffers: 0 > Bumped Transaction: 0 > Oldest Snapshot: 0 > Backup Pages: 0 > > A straight hexdump of the first page is as follows: > > 0000 01 00 39 30 c8 02 00 00 00 00 00 00 00 00 00 00 > 0010 00 10 0b 80 03 00 00 00 00 00 00 00 b9 02 00 00 > 0020 ba 02 00 00 bb 02 00 00 00 00 82 01 4e da 00 00 > 0030 70 c4 16 23 51 00 00 00 00 00 00 00 13 00 02 00 > 0040 02 00 60 00 00 00 00 00 01 00 00 00 ba 02 00 00 > 0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > And finally, how the header page is defined in the utility: > > // Page Header - on every page type. > typedef struct > { > SCHAR pag_type; > UCHAR pag_flags; > USHORT pag_checksum; > ULONG pag_generation; > ULONG pag_scn; > ULONG pag_reserved; > } pageHeader;
Looks like your ULONG is 8-byte integer while it shold be 4-byte. Regards, Vlad ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. This 200-page book is written by three acclaimed leaders in the field. The early access version is available now. Download your free book today! http://p.sf.net/sfu/neotech_d2d_may Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel