Grab stacktrace on signal.

This commit is contained in:
Deukhoofd committed 2020-08-18 19:26:39 +02:00
1 parent c852824c91
commit 59b4223d18
9 files changed
+46 -8

No files matched your search

+9
View File
@@ -10,5 +10,14 @@ namespace Arbutils.Generated
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_GetLastException")]
internal static extern IntPtr GetLastException();
/// <param name="callback">Function *</param>
/// <returns>void</returns>
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_SetSignalCallback")]
internal static extern void SetSignalCallback(IntPtr callback);
/// <returns>void</returns>
[DllImport("Arbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_RaiseSignal")]
internal static extern void RaiseSignal();
}
}
+4
View File
@@ -14,5 +14,9 @@ namespace Creaturelib.Generated
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_C_GetLastExceptionStacktrace")]
internal static extern IntPtr GetLastExceptionStacktrace();
/// <returns>void</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_C_RaiseSignal")]
internal static extern void RaiseSignal();
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Runtime.InteropServices;
namespace PkmnLibSharp.Utilities
{
public static class SignalHandler
{
public delegate void SignalDelegate(string s);
private delegate void InternalSignalDelegate(IntPtr ptr);
private static InternalSignalDelegate? _internalSignalDelegate;
public static void SetSignalListener(SignalDelegate del)
{
_internalSignalDelegate = ptr =>
{
del(ptr.PtrString()!);
};
Arbutils.Generated.C.SetSignalCallback(Marshal.GetFunctionPointerForDelegate(_internalSignalDelegate));
}
}
}
+1 -1
View File
@@ -1 +1 @@
{"enums":[{"byteSize":4,"filename":"Arbutils","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"Arbutils","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}}],"functions":[{"filename":"Arbutils","name":"Arbutils_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"Arbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"Arbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"Arbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"Arbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"Arbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]}
{"enums":[{"byteSize":4,"filename":"Arbutils","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"Arbutils","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}}],"functions":[{"filename":"Arbutils","name":"Arbutils_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"Arbutils","name":"Arbutils_C_SetSignalCallback","parameters":[{"name":"callback","type":"Function *"}],"returns":"void"},{"filename":"Arbutils","name":"Arbutils_C_RaiseSignal","parameters":[],"returns":"void"},{"filename":"Arbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"Arbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"Arbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"Arbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"Arbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"Arbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"Arbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]}
+1 -1
View File
@@ -1 +1 @@
{"enums":[{"byteSize":4,"filename":"CreatureLib","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"CreatureLib","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}},{"byteSize":1,"filename":"CreatureLib","name":"ScriptCategory","values":{"0":"Attack","1":"Talent","2":"Status","3":"Creature","4":"Battle","5":"Side"}},{"byteSize":1,"filename":"CreatureLib","name":"Statistic","values":{"0":"Health","1":"PhysicalAttack","2":"PhysicalDefense","3":"MagicalAttack","4":"MagicalDefense","5":"Speed"}},{"byteSize":1,"filename":"CreatureLib","name":"Gender","values":{"0":"Male","1":"Female","2":"Genderless"}},{"byteSize":1,"filename":"CreatureLib","name":"ItemCategory","values":{"0":"MiscItem","1":"CaptureDevice","2":"Medicine","3":"Berry","4":"MoveLearner","5":"VariantChanger","6":"KeyItem","7":"Mail"}},{"byteSize":1,"filename":"CreatureLib","name":"BattleItemCategory","values":{"0":"None","1":"Healing","2":"StatusHealing","3":"CaptureDevice","4":"MiscBattleItem"}},{"byteSize":1,"filename":"CreatureLib","name":"DamageSource","values":{"0":"AttackDamage"}},{"byteSize":1,"filename":"CreatureLib","name":"EventDataKind","values":{"0":"Damage","1":"Heal","10":"ChangeVariant","11":"AttackUse","2":"Faint","3":"Switch","4":"TurnStart","5":"TurnEnd","6":"ExperienceGain","7":"Miss","8":"DisplayText","9":"ChangeSpecies"}},{"byteSize":1,"filename":"CreatureLib","name":"HistoryElementKind","values":{"0":"AttackUse"}},{"byteSize":4,"filename":"CreatureLib","name":"AttackLearnMethod","values":{"0":"Unknown","1":"Level"}},{"byteSize":1,"filename":"CreatureLib","name":"TurnChoiceKind","values":{"0":"Pass","1":"Attack","2":"Item","3":"Switch","4":"Flee"}},{"byteSize":1,"filename":"CreatureLib","name":"EffectParameterType","values":{"0":"None","1":"Bool","2":"Int","3":"Float","4":"String"}},{"byteSize":1,"filename":"CreatureLib","name":"AttackCategory","values":{"0":"Physical","1":"Magical","2":"Status"}},{"byteSize":1,"filename":"CreatureLib","name":"AttackTarget","values":{"0":"Adjacent","1":"AdjacentAlly","10":"RandomOpponent","11":"Self","2":"AdjacentAllySelf","3":"AdjacentOpponent","4":"All","5":"AllAdjacent","6":"AllAdjacentOpponent","7":"AllAlly","8":"AllOpponent","9":"Any"}}],"functions":[{"filename":"CreatureLib","name":"CreatureLib_Battle_Construct","parameters":[{"name":"out","type":"Battle * &"},{"name":"library","type":"const BattleLibrary *"},{"name":"partyArr","type":"BattleParty * *"},{"name":"numberOfParties","type":"long unsigned int"},{"name":"canFlee","type":"bool"},{"name":"numberOfSides","type":"unsigned char"},{"name":"creaturesPerSide","type":"unsigned char"},{"name":"randomSeed","type":"long unsigned int"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_Destruct","parameters":[{"name":"p","type":"const Battle *"}],"returns":"void"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetLibrary","parameters":[{"name":"p","type":"const Battle *"}],"returns":"const BattleLibrary *"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CanUse","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_TrySetChoice","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CanFlee","parameters":[{"name":"p","type":"const Battle *"}],"returns":"bool"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CheckChoicesSetAndRun","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCurrentTurn","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCreaturesPerSide","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCurrentTurnQueue","parameters":[{"name":"p","type":"const Battle *"}],"returns":"ChoiceQueue *"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetRandom","parameters":[{"name":"p","type":"Battle *"}],"returns":"BattleRandom *"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CreatureInField","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"const Battle *"},{"name":"c","type":"Creature *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCreature","parameters":[{"name":"out","type":"Creature * &"},{"name":"p","type":"const Battle *"},{"name":"side","type":"unsigned char"},{"name":"target","type":"unsigned char"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_ForceRecall",Line truncated
{"enums":[{"byteSize":4,"filename":"CreatureLib","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"CreatureLib","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}},{"byteSize":1,"filename":"CreatureLib","name":"ScriptCategory","values":{"0":"Attack","1":"Talent","2":"Status","3":"Creature","4":"Battle","5":"Side"}},{"byteSize":1,"filename":"CreatureLib","name":"Statistic","values":{"0":"Health","1":"PhysicalAttack","2":"PhysicalDefense","3":"MagicalAttack","4":"MagicalDefense","5":"Speed"}},{"byteSize":1,"filename":"CreatureLib","name":"Gender","values":{"0":"Male","1":"Female","2":"Genderless"}},{"byteSize":1,"filename":"CreatureLib","name":"ItemCategory","values":{"0":"MiscItem","1":"CaptureDevice","2":"Medicine","3":"Berry","4":"MoveLearner","5":"VariantChanger","6":"KeyItem","7":"Mail"}},{"byteSize":1,"filename":"CreatureLib","name":"BattleItemCategory","values":{"0":"None","1":"Healing","2":"StatusHealing","3":"CaptureDevice","4":"MiscBattleItem"}},{"byteSize":1,"filename":"CreatureLib","name":"DamageSource","values":{"0":"AttackDamage"}},{"byteSize":1,"filename":"CreatureLib","name":"EventDataKind","values":{"0":"Damage","1":"Heal","10":"ChangeVariant","11":"AttackUse","2":"Faint","3":"Switch","4":"TurnStart","5":"TurnEnd","6":"ExperienceGain","7":"Miss","8":"DisplayText","9":"ChangeSpecies"}},{"byteSize":1,"filename":"CreatureLib","name":"HistoryElementKind","values":{"0":"AttackUse"}},{"byteSize":4,"filename":"CreatureLib","name":"AttackLearnMethod","values":{"0":"Unknown","1":"Level"}},{"byteSize":1,"filename":"CreatureLib","name":"TurnChoiceKind","values":{"0":"Pass","1":"Attack","2":"Item","3":"Switch","4":"Flee"}},{"byteSize":1,"filename":"CreatureLib","name":"EffectParameterType","values":{"0":"None","1":"Bool","2":"Int","3":"Float","4":"String"}},{"byteSize":1,"filename":"CreatureLib","name":"AttackCategory","values":{"0":"Physical","1":"Magical","2":"Status"}},{"byteSize":1,"filename":"CreatureLib","name":"AttackTarget","values":{"0":"Adjacent","1":"AdjacentAlly","10":"RandomOpponent","11":"Self","2":"AdjacentAllySelf","3":"AdjacentOpponent","4":"All","5":"AllAdjacent","6":"AllAdjacentOpponent","7":"AllAlly","8":"AllOpponent","9":"Any"}}],"functions":[{"filename":"CreatureLib","name":"CreatureLib_Battle_Construct","parameters":[{"name":"out","type":"Battle * &"},{"name":"library","type":"const BattleLibrary *"},{"name":"partyArr","type":"BattleParty * *"},{"name":"numberOfParties","type":"long unsigned int"},{"name":"canFlee","type":"bool"},{"name":"numberOfSides","type":"unsigned char"},{"name":"creaturesPerSide","type":"unsigned char"},{"name":"randomSeed","type":"long unsigned int"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_Destruct","parameters":[{"name":"p","type":"const Battle *"}],"returns":"void"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetLibrary","parameters":[{"name":"p","type":"const Battle *"}],"returns":"const BattleLibrary *"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CanUse","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_TrySetChoice","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CanFlee","parameters":[{"name":"p","type":"const Battle *"}],"returns":"bool"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CheckChoicesSetAndRun","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCurrentTurn","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCreaturesPerSide","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCurrentTurnQueue","parameters":[{"name":"p","type":"const Battle *"}],"returns":"ChoiceQueue *"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetRandom","parameters":[{"name":"p","type":"Battle *"}],"returns":"BattleRandom *"},{"filename":"CreatureLib","name":"CreatureLib_Battle_CreatureInField","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"const Battle *"},{"name":"c","type":"Creature *"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_GetCreature","parameters":[{"name":"out","type":"Creature * &"},{"name":"p","type":"const Battle *"},{"name":"side","type":"unsigned char"},{"name":"target","type":"unsigned char"}],"returns":"unsigned char"},{"filename":"CreatureLib","name":"CreatureLib_Battle_ForceRecall",Line truncated
+3
View File
@@ -3,6 +3,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using NUnit.Framework;
using PkmnLibSharp.Battling;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharpTests
{
@@ -20,6 +21,8 @@ namespace PkmnLibSharpTests
{
Console.WriteLine($"[{level.ToString().ToUpperInvariant()}] {s}");
});
SignalHandler.SetSignalListener(s => throw new Exception("Encountered a catastrophic signal. \n" + s));
}
}
}