MagicStats 2.0 Hackers Guide

Abstract:

Hacking MagicStats can be a fun and easy way to convince it to do what you want... this guide talks about how to set up MagicStats to optimally hack on it, without breaking your default stats installation...
  1. MagicStats Hacking Overview:
  2. Installing MagicStats twice:
  3. What is MagicStats2_g?:
  4. MagicStats ignores my hacked plugin!
  5. Conclusion:

MagicStats Hacking Overview:

Hey, ya wanna hack on MagicStats to 'scratch your itch'? Well go ahead, it's free software (GPL)... but here are a few hints to hopefully make it an easier experience for you...

This file assumes that you have MagicStats Installed and working and you don't want to mess up your "mission critical" statistics that are being generated.

Installing MagicStats twice:

MagicStats makes it pretty easy to keep two installations of MagicStats seperate from each other. To do this, you need a seperate location for each of the following things:

  1. The new hacked binaries.
  2. Your MagicStats.cfg file.
  3. The persistant storage database file that MagicStats creates (MagicStats.dat).
  4. All of the output statistics.
Okay, we'll go through these in order. #1 is easy, just extract the source tarball someplace and build MagicStats. The build process should automatically create an Install tree that is fully functional and seperate from any other MagicStats installation. This allows Binaries, themes, and plugins to be seperated out. Note that when you do this, you need to set your Resources URL/Path to point to your new installation, not the old one.

To allow MagicStats.cfg files to be someplace other than ~/.MagicStats, MagicStats supports the -C <file> commandline option. If you followed the recommended installation steps, you should have a ~/.MagicStats directory with two things in it (MagicStats.cfg and MagicStats.dat). I would recommend that you put your new config file in the same directory, just name it different. For example, name it ~/.MagicStats/MSHacked.cfg and run your new MagicStats as: ~/MagicStats/Install/MagicStats2 -C ~/.MagicStats/MSHacked.cfg.

Getting MagicStats to look for its data file in a different location is similarly easy. Simply specify a DataFilename value in the [Global] section of your MSHacked.cfg file, like this:

Data Filename    : "~/.MagicStats/MSHacked.dat";
Specifying a directory for your output statistics to go to is done by specifying a different $PathPrefix value in your MSHacked.cfg file.

What is MagicStats2_g?:

You may notice that when you compile MagicStats, you get both a MagicStats2 and MagicStats2_g files... and all the plugins are split into Plugins and Plugins_g directories. The _g versions are compiled with debug information... a very useful tool for a hacker!

MagicStats ignores my hacked plugin!

So here's the scenario: You hacked a plugin somehow (created from scratch, modified existing one, whatever), compiled it, linked it, and MagicStats should be able to find plugin (Resources path points to it) - Yet MagicStats -T does not list it. The most likely cause is that there is a dynamic link error with your plugin. Try running MagicStats2 -g -T (debug mode), and it will print something like this:

Install>$ MagicStats2 -C ~/.MagicStats/MSHacked.cfg -P -g
MagicStats v2.0pr9...   By: Chris Lattner (sabre@nondot.org)
  Loading configuration file...
Loading configuration file from disk: /home/sabre/.MagicStats/MSHacked.cfg
Loading configuration file from disk: Fancy.cfg
Active Resource Paths:
  /home/sabre/MagicStats/Install
  /home/sabre/.MagicStats
Failed to load promising external plugin: AfIISAccessFormat from: 
    /home/sabre/MagicStats/Install/Plugins/AfIISAccessFormat/AfIISAccessFormat.so
  Error = /home/sabre/MagicStats/Install/Plugins/AfIISAccessFormat/AfIISAccessFormat.so: 
    undefined symbol: _17AfIISAccessFormat.FieldNames
...
Whoa... we have an undefined symbol! But what is it? Try running this:

Install>$ echo _17AfIISAccessFormat.FieldNames | c++filt
AfIISAccessFormat::FieldNames
Install>$ 
Ooops... I forgot to define that. Okay, now that I fixed it, I try again and get:

Install>$ MagicStats2 -C ~/.MagicStats/MSHacked.cfg -P -g
MagicStats v2.0pr9...   By: Chris Lattner (sabre@nondot.org)
  Loading configuration file...
Loading configuration file from disk: /home/sabre/.MagicStats/MSHacked.cfg
Loading configuration file from disk: Fancy.cfg
Active Resource Paths:
  /home/sabre/MagicStats/Install
  /home/sabre/.MagicStats
Loaded plugin: AfIISAccessFormat from: 
    /home/sabre/MagicStats/Install/Plugins/AfIISAccessFormat/AfIISAccessFormat.so
...
Cool, it works now!!!

Conclusion:

This short guide talks about how to work on MagicStats and how to set it up to not interfere with your normal installation. If you have any questions regarding any of this stuff, or topics for future entries, let me know. -Chris

Copyright © 2000 Chris Lattner