Finalized binlogging update by removing another unnecessary opcode and updating the reader

This commit is contained in:
David Anderson 2006-08-21 04:18:13 +00:00
parent 45b67b6e2c
commit 5b47da7cee
9 changed files with 140 additions and 94 deletions

View File

@ -187,17 +187,8 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
}
case BinLog_NativeRet:
{
int file;
cell retval = va_arg(ap, cell);
fwrite(&retval, sizeof(cell), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break;
}
case BinLog_NativeError:

View File

@ -48,7 +48,7 @@ enum BinLogOp
BinLog_End,
BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
BinLog_NativeError, //<int32 errornum> <str[int16] string>
BinLog_NativeRet, //<cell value> <int32_t filename id>
BinLog_NativeRet, //<cell value>
BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
BinLog_SetLine, //<int32 line no#> <int32_t filename id>
BinLog_Registered, //<string title> <string version>

View File

@ -11,7 +11,8 @@ namespace BinLogReader
public class BinLog
{
private static uint BINLOG_MAGIC = 0x414D424C;
private static short BINLOG_VERSION = 0x0200;
private static short BINLOG_VERSION = 0x0300;
private static short BINLOG_MIN_VERSION = 0x0300;
private ArrayList oplist;
private PluginDb plugdb;
@ -60,7 +61,7 @@ namespace BinLogReader
throw new Exception("Invalid magic log number");
ushort version = br.ReadUInt16();
if (version > BINLOG_VERSION)
if (version > BINLOG_VERSION || version < BINLOG_MIN_VERSION)
throw new Exception("Unknown log version number");
byte timesize = br.ReadByte();
@ -182,19 +183,22 @@ namespace BinLogReader
case BinLogOp.BinLog_SetLine:
{
int line = br.ReadInt32();
int file = br.ReadInt32();
BinLogSetLine bsl =
new BinLogSetLine(line, gametime, realtime, pl);
new BinLogSetLine(line, gametime, realtime, pl, file);
bl.OpList.Add(bsl);
break;
}
case BinLogOp.BinLog_CallPubFunc:
{
int pubidx = br.ReadInt32();
int fileid = br.ReadInt32();
BinLogPublic bp =
new BinLogPublic(pubidx,
gametime,
realtime,
pl);
pl,
fileid);
bl.OpList.Add(bp);
break;
}
@ -214,12 +218,14 @@ namespace BinLogReader
{
int native = br.ReadInt32();
int parms = br.ReadInt32();
int file = br.ReadInt32();
BinLogNativeCall bn =
new BinLogNativeCall(native,
parms,
gametime,
realtime,
pl);
pl,
file);
bl.OpList.Add(bn);
break;
}

View File

@ -10,16 +10,16 @@ namespace BinLogReader
BinLog_Invalid=0,
BinLog_Start=1,
BinLog_End,
BinLog_NativeCall, //<int16_t native id>
BinLog_NativeError,
BinLog_NativeRet,
BinLog_CallPubFunc, //<int16_t public id>
BinLog_SetLine, //<int16_t line no#>
BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
BinLog_NativeError, //<int32 errornum> <str[int16] string>
BinLog_NativeRet, //<cell value>
BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
BinLog_SetLine, //<int32 line no#> <int32_t filename id>
BinLog_Registered, //<string title> <string version>
BinLog_FormatString,
BinLog_NativeParams,
BinLog_GetString,
BinLog_SetString,
BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string>
BinLog_NativeParams, //<int32 num> <cell ...>
BinLog_GetString, //<cell addr> <string[int16]>
BinLog_SetString, //<cell addr> <int maxlen> <string[int16]>
};
public enum BinLogFlags
@ -72,6 +72,40 @@ namespace BinLogReader
}
}
public static void PluginText(StringBuilder sb, Plugin pl, BinLogFlags flags, int fileid)
{
if (HasFlag(flags, BinLogFlags.Show_PlugId)
&& HasFlag(flags, BinLogFlags.Show_PlugFile))
{
sb.Append("\"");
sb.Append(pl.File);
if (pl.IsDebug())
{
sb.Append(", ");
sb.Append(pl.FindFile(fileid));
}
sb.Append("\"");
sb.Append(" (");
sb.Append(pl.Index);
sb.Append(")");
}
else if (HasFlag(flags, BinLogFlags.Show_PlugId))
{
sb.Append(pl.Index);
}
else if (HasFlag(flags, BinLogFlags.Show_PlugFile))
{
sb.Append("\"");
sb.Append(pl.File);
if (pl.IsDebug())
{
sb.Append(", ");
sb.Append(pl.FindFile(fileid));
}
sb.Append("\"");
}
}
public static void BinLogString(StringBuilder sb, BinLogEntry ble, BinLogFlags flags)
{
bool realtime = false;
@ -130,6 +164,7 @@ namespace BinLogReader
public class BinLogSetLine : BinLogEntry
{
private int line;
private int fileid;
public int Line
{
@ -139,16 +174,17 @@ namespace BinLogReader
}
}
public BinLogSetLine(int _line, float gt, long rt, Plugin _pl)
public BinLogSetLine(int _line, float gt, long rt, Plugin _pl, int file)
: base(gt, rt, _pl)
{
line = _line;
fileid = file;
}
public override void ToLogString(StringBuilder sb, BinLogFlags flags)
{
sb.Append("Plugin ");
BinLogEntry.PluginText(sb, plugin, flags);
BinLogEntry.PluginText(sb, plugin, flags, fileid);
sb.Append(" hit line ");
sb.Append(Line);
sb.Append(".");
@ -163,6 +199,7 @@ namespace BinLogReader
public class BinLogPublic : BinLogEntry
{
private int pubidx;
private int fileid;
public string Public
{
@ -172,16 +209,17 @@ namespace BinLogReader
}
}
public BinLogPublic(int pi, float gt, long rt, Plugin _pl)
public BinLogPublic(int pi, float gt, long rt, Plugin _pl, int _file)
: base(gt, rt, _pl)
{
pubidx = pi;
fileid = _file;
}
public override void ToLogString(StringBuilder sb, BinLogFlags flags)
{
sb.Append("Plugin ");
BinLogEntry.PluginText(sb, plugin, flags);
BinLogEntry.PluginText(sb, plugin, flags, fileid);
sb.Append(" had public function \"");
sb.Append(Public);
sb.Append("\" (");
@ -283,6 +321,7 @@ namespace BinLogReader
{
private int nativeidx;
private int numparams;
private int fileid;
public string Native
{
@ -292,17 +331,18 @@ namespace BinLogReader
}
}
public BinLogNativeCall(int na, int nu, float gt, long rt, Plugin _pl)
public BinLogNativeCall(int na, int nu, float gt, long rt, Plugin _pl, int _file)
: base(gt, rt, _pl)
{
nativeidx = na;
numparams = nu;
fileid = _file;
}
public override void ToLogString(StringBuilder sb, BinLogFlags flags)
{
sb.Append("Plugin ");
BinLogEntry.PluginText(sb, plugin, flags);
BinLogEntry.PluginText(sb, plugin, flags, fileid);
sb.Append(" called native \"");
sb.Append(Native);
sb.Append("\" (");

View File

@ -22,11 +22,10 @@ namespace BinLogReader
private System.Windows.Forms.OpenFileDialog ofd;
private System.Windows.Forms.MenuItem MenuFileOpen;
private System.Windows.Forms.TabPage PluginsTab;
private System.Windows.Forms.TabPage LogTextTab;
private System.Windows.Forms.TabPage ViewTab;
private System.Windows.Forms.TabPage LogListTab;
private System.Windows.Forms.ListView PluginList;
private System.Windows.Forms.TabPage LogTextTab;
private System.Windows.Forms.RichTextBox TextLog;
private System.Windows.Forms.TabPage LogListTab;
private System.Windows.Forms.TabControl MainTab;
/// <summary>
/// Required designer variable.
@ -77,16 +76,15 @@ namespace BinLogReader
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.MainTab = new System.Windows.Forms.TabControl();
this.PluginsTab = new System.Windows.Forms.TabPage();
this.PluginList = new System.Windows.Forms.ListView();
this.LogTextTab = new System.Windows.Forms.TabPage();
this.TextLog = new System.Windows.Forms.RichTextBox();
this.LogListTab = new System.Windows.Forms.TabPage();
this.ViewTab = new System.Windows.Forms.TabPage();
this.MainTab.SuspendLayout();
this.MainTab = new System.Windows.Forms.TabControl();
this.PluginsTab.SuspendLayout();
this.LogTextTab.SuspendLayout();
this.MainTab.SuspendLayout();
this.SuspendLayout();
//
// mainMenu1
@ -137,22 +135,6 @@ namespace BinLogReader
//
this.ofd.Filter = "Binary Log Files|*.blg";
//
// MainTab
//
this.MainTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainTab.Controls.Add(this.PluginsTab);
this.MainTab.Controls.Add(this.LogTextTab);
this.MainTab.Controls.Add(this.LogListTab);
this.MainTab.Controls.Add(this.ViewTab);
this.MainTab.Location = new System.Drawing.Point(8, 12);
this.MainTab.Name = "MainTab";
this.MainTab.SelectedIndex = 0;
this.MainTab.Size = new System.Drawing.Size(656, 372);
this.MainTab.TabIndex = 0;
this.MainTab.SelectedIndexChanged += new System.EventHandler(this.MainTab_SelectedIndexChanged);
//
// PluginsTab
//
this.PluginsTab.Controls.Add(this.PluginList);
@ -187,7 +169,7 @@ namespace BinLogReader
// TextLog
//
this.TextLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.TextLog.Font = new System.Drawing.Font("Lucida Sans Typewriter", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.TextLog.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.TextLog.Location = new System.Drawing.Point(0, 0);
this.TextLog.Name = "TextLog";
this.TextLog.Size = new System.Drawing.Size(648, 346);
@ -202,13 +184,21 @@ namespace BinLogReader
this.LogListTab.TabIndex = 3;
this.LogListTab.Text = "Event Log (List)";
//
// ViewTab
// MainTab
//
this.ViewTab.Location = new System.Drawing.Point(4, 22);
this.ViewTab.Name = "ViewTab";
this.ViewTab.Size = new System.Drawing.Size(648, 346);
this.ViewTab.TabIndex = 2;
this.ViewTab.Text = "View Configuration";
this.MainTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainTab.Controls.Add(this.PluginsTab);
this.MainTab.Controls.Add(this.LogTextTab);
this.MainTab.Controls.Add(this.LogListTab);
this.MainTab.ItemSize = new System.Drawing.Size(46, 18);
this.MainTab.Location = new System.Drawing.Point(8, 12);
this.MainTab.Name = "MainTab";
this.MainTab.SelectedIndex = 0;
this.MainTab.Size = new System.Drawing.Size(656, 372);
this.MainTab.TabIndex = 0;
this.MainTab.SelectedIndexChanged += new System.EventHandler(this.MainTab_SelectedIndexChanged);
//
// Form1
//
@ -219,9 +209,9 @@ namespace BinLogReader
this.Name = "Form1";
this.Text = "AMX Mod X BinLogReader";
this.Load += new System.EventHandler(this.Form1_Load);
this.MainTab.ResumeLayout(false);
this.PluginsTab.ResumeLayout(false);
this.LogTextTab.ResumeLayout(false);
this.MainTab.ResumeLayout(false);
this.ResumeLayout(false);
}

View File

@ -151,24 +151,6 @@
<data name="ofd.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>126, 17</value>
</data>
<data name="MainTab.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="MainTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="MainTab.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="MainTab.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="MainTab.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="MainTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>4, 4</value>
</data>
<data name="PluginsTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
@ -241,27 +223,30 @@
<data name="LogListTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>8, 8</value>
</data>
<data name="ViewTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<data name="MainTab.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="MainTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="ViewTab.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<data name="MainTab.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="ViewTab.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="ViewTab.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<data name="MainTab.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="ViewTab.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<data name="MainTab.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="ViewTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>8, 8</value>
<data name="MainTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>4, 4</value>
</data>
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="$this.Name">
<value>Form1</value>
</data>
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>(Default)</value>
</data>
@ -283,9 +268,6 @@
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="$this.Name">
<value>Form1</value>
</data>
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>

View File

@ -12,6 +12,7 @@ namespace BinLogReader
private string Filename;
private ArrayList Natives;
private ArrayList Publics;
private ArrayList Files;
private string title;
private string version;
private int index;
@ -70,11 +71,12 @@ namespace BinLogReader
}
}
public Plugin(string name, int natives, int publics, byte _status, int _index)
public Plugin(string name, int natives, int publics, int files, byte _status, int _index)
{
Filename = name;
Natives = new ArrayList(natives);
Publics = new ArrayList(publics);
Files = new ArrayList(files+1);
status = _status;
index = _index;
}
@ -89,18 +91,37 @@ namespace BinLogReader
Publics.Add(pubname);
}
public void AddFile(string filename)
{
Files.Add(filename);
}
public string FindNative(int id)
{
if (id < 0 || id >= Natives.Count)
{
return null;
}
return (string)Natives[id];
}
public string FindFile(int id)
{
if (id < 0 || id >= Files.Count)
{
return null;
}
return (string)Files[id];
}
public string FindPublic(int id)
{
if (id < 0 || id >= Publics.Count)
{
return null;
}
return (string)Publics[id];
}

View File

@ -47,16 +47,32 @@ namespace BinLogReader
{
byte status = br.ReadByte();
byte length = br.ReadByte();
uint files = 0;
byte [] name = br.ReadBytes(length + 1);
if (status == 2)
{
files = br.ReadUInt32();
}
uint natives = br.ReadUInt32();
uint publics = br.ReadUInt32();
int id = db.CreatePlugin(
Encoding.ASCII.GetString(name, 0, length),
(int)natives,
(int)publics,
(int)publics,
(int)files,
status,
(int)i);
Plugin pl = db.GetPluginById(id);
for (uint j=0; j<files; j++)
{
length = br.ReadByte();
name = br.ReadBytes(length + 1);
pl.AddFile(Encoding.ASCII.GetString(name, 0, length));
}
if (files == 0)
{
pl.AddFile(pl.File);
}
for (uint j=0; j<natives; j++)
{
length = br.ReadByte();
@ -74,9 +90,9 @@ namespace BinLogReader
return db;
}
private int CreatePlugin(string file, int natives, int publics, byte status, int index)
private int CreatePlugin(string file, int natives, int publics, int files, byte status, int index)
{
Plugin pl = new Plugin(file, natives, publics, status, index);
Plugin pl = new Plugin(file, natives, publics, files, status, index);
PluginList.Add(pl);
return PluginList.Count - 1;
}