{"id":17999521,"url":"https://github.com/zeex/samp-plugin-crashdetect","last_synced_at":"2025-04-11T12:24:48.802Z","repository":{"id":2915723,"uuid":"3925501","full_name":"Zeex/samp-plugin-crashdetect","owner":"Zeex","description":"Crash/error reporting plugin for SA-MP server","archived":false,"fork":false,"pushed_at":"2024-08-04T18:01:44.000Z","size":5246,"stargazers_count":116,"open_issues_count":31,"forks_count":23,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-29T23:34:46.404Z","etag":null,"topics":["cmake","cplusplus","crash-reporting","plugin","sa-mp"],"latest_commit_sha":null,"homepage":"http://forum.sa-mp.com/showthread.php?t=262796","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zeex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-04T04:36:38.000Z","updated_at":"2024-09-27T07:56:10.000Z","dependencies_parsed_at":"2024-07-24T12:56:01.910Z","dependency_job_id":"fa1340a3-52ec-4f5b-a42f-c69a9d294fb4","html_url":"https://github.com/Zeex/samp-plugin-crashdetect","commit_stats":null,"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeex%2Fsamp-plugin-crashdetect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeex%2Fsamp-plugin-crashdetect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeex%2Fsamp-plugin-crashdetect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zeex%2Fsamp-plugin-crashdetect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zeex","download_url":"https://codeload.github.com/Zeex/samp-plugin-crashdetect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224315392,"owners_count":17290991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake","cplusplus","crash-reporting","plugin","sa-mp"],"created_at":"2024-10-29T22:13:23.615Z","updated_at":"2024-11-12T17:01:35.876Z","avatar_url":"https://github.com/Zeex.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[CrashDetect plugin][github]\n============================\n\n[![Version][version_badge]][version]\n[![Build Status][build_status]][build]\n\nCrashDetect helps you debug runtime errors and server crashes. When something\ngoes wrong you will get a detailed error message with error description, stack\ntrace, and other useful information that will make it easier to quickly find\nand fix the issue.\n\nInstallation\n------------\n\n1. Download a binary package from the [Releases][download] page on Github or\n   build it yourself from source code (see\n   [Building from source code](#building-from-source-code)).\n2. Extract and copy `crashdetect.so` or `crashdetect.dll` to `\u003csever\u003e/plugins/`.\n3. Add `crashdetect` (Windows) or `crashdetect.so` (Linux) to the `plugins`\n   line of your server.cfg.\n\nBinary packages come with an include file (`crashdetect.inc`) that contains\nsome helper functions that you may find useful. But **you don't have to\ninclude** it to be able to use CrashDetect.\n\nUsage\n-----\n\nApart from installing the plugin you don't have to do anything further to\nstart receiving errors reports. By default all errors will be saved in your\n`server_log.txt`, but this can be changed\n(see [Configuration](#configuration)).\n\nFor better debugging experience, make sure that you\n[compile your script with debug info enabled][debug_info]. Doing this will let\nyou see more information in stack traces such as function names, parameter names\nand values, source file names and line numbers.\n\nPlease be aware that when using this plugin your code WILL run slower due\nto the overhead associated with detecting errors and providing accurate\nerror information (for example, some runtime optimizations are disabled).\nUsually this is fine during development, but it's not recommended to load\nCrashDetect on a production (live) server with many players.\n\nConfiguration\n-------------\n\nCrashDetect reads settings from server.cfg, the server configuration file. This\nis done during plugin loading, so if you change any settings you will probably\nneed to restart your server.\n\nAvailable settings:\n\n* `trace \u003cflags\u003e`\n\n  Enables function call tracing.\n\n  If enabled, CrashDetect will show information about every function call in\n  all running scripts, such as the name of the function being called and the\n  values of its parameters.\n\n  `flags` may be one or combination of the following:\n\n  * `n` - trace native functions\n  * `p` - trace public functions\n  * `f` - trace normal functions (i.e. all non-public functions)\n\n  For example, `trace pn` will trace both public and native calls, and\n  `trace pfn` will trace all functions.\n\n* `trace_filter \u003cregexp\u003e`\n\n  Filters `trace` output based on a regular expression.\n\n  Examples:\n\n  * `trace_filter Player` - output functions whose name contains `Player`\n  * `trace_filter playerid=0` - show functions whose `playerid` parameter is 0\n\n* `crashdetect_log \u003cfilename\u003e`\n\n  Use a custom log file for output.\n\n  By default all diagnostic information is printed to the server log. This\n  option lets you redirect output to a separate file.\n\n* `long_call_time \u003cus\u003e`\n\n  How long a top-level callback call should last before CrashDetect prints a\n  warning. This can be set very high (for example `1000000`) to only detect\n  functions that have totally hung, or very low (`500`) to detect functions that\n  complete, but are just slow (thus affecting overall server execution and\n  sync). Default value is `5000` (5 milliseconds).\n\n  Use `0` to disable this check.\n\nAddress Naught\n--------------\n\nOften writing to address naught is a mistake, it indicates that some target\naddress is unset, especially in larger modes. `address_naught` mode detects all\nwrites to this address and gives a new (to VM) error in that case -\n`AMX_ERR_ADDRESS_0`. Note that this isn't always an error, it is a valid\naddress and real data can be stored there, so if this detection is enabled the\nmode must ensure that nothing important will be written there (fixes.inc does\nthis by defining and not using the anonymous automata). This is also the reason\nwhy there is no global config option for this detection - it is by necessity\ndone on a per-mode basis, is off by default, and can only be enabled by\nfunctions (technically by registers).\n\nFunctions\n---------\n\nThere are several functions defined in `crashdetect.inc` to access plugin\ninformation. These are all just wrappers around direct register accesses, but\nprovide a much nicer API.\n\n* `bool:IsCrashDetectPresent()` - Is the CrashDetect plugin loaded?\n* `SetCrashDetectLongCallTime(us_time)` - Set the long call warning threshold.\n* `GetCrashDetectLongCallTime()` - Get the long call warning threshold.\n* `DisableCrashDetectLongCall()` - Disable the long call warning.\n* `EnableCrashDetectLongCall()` - Enable the long call warning.\n* `ResetCrashDetectLongCallTime()` - Reset the long call threshold to the\n   default (from `server.cfg`).\n* `RestartCrashDetectLongCall()` - Restart the long call timer.\n* `bool:IsCrashDetectLongCallEnabled()` - Is long function call detection\n   enabled?\n* `bool:HasCrashDetectLongCall()` - Does the current version of CrashDetect\n   support this feature?\n* `GetCrashDetectDefaultTime()` - Get the default long call time threshold.\n* `DisableCrashDetectAddr0()` - Disable address naught write detection in this\n   mode.\n* `EnableCrashDetectAddr0()` - Enable address naught write detection in this\n   mode.\n* `bool:IsCrashDetectAddr0Enabled()` - Is the error currently enabled?\n* `bool:HasCrashDetectAddr0()` - Does the current version of CrashDetect\n   support this feature?\n\nRegisters\n---------\n\nThe plugin adds two control registers accessed via `LCTRL` and `SCTRL` - `0xFF`\nfor general flags and `0xFE` for long call time values:\n\n```pawn\n// Get the current long call time (even when it is disabled).\n#emit ZERO.pri          // Always set pri to 0 before `LCTRL` calls.\n#emit LCTRL        0xFE // Will set `pri` if the plugin is loaded.\n#emit STOR.pri     var  // Save the result.\n```\n\n```pawn\n// Enable address naught write detection.\n#emit CONST.pri    192  // 64 (address_naught control bit) | 128 (address_naught enable).\n#emit SCTRL        0xFF // Set the register.\n```\n\nThe flags are:\n\n* `1` - CrashDetect is present (read only).\n* `2` - long_call_time checks enabled (write ignored when `server.cfg` has\n  `long_call_time 0`).\n* `4` - long_call_time reset to default time (write `1` only).\n* `8` - long_call_time restart check from now (write `1` only).\n* `16` - Error with the CrashDetect user data.\n* `32` - long_call_time control bit.\n* `64` - address_naught control bit.\n* `128` - address_naught detection enabled.\n\nWhen read-only values are set, they are ignored. When write-only bits are\nreturned they are always `0`. When write-1-only bits are `0` they are ignored,\nthe `1` is a signal to trigger something. To set most registers the relevant\ncontrol bit must also be set. So to enable address naught detection requires\nbit `6` (`64`) and bit `7` (`128`). To disable it just requires bit `6`.\nNote that while many of these bits would seem to be independent you cannot\ndisable address naught detection, enable long call detection, and reset and\nrestart the timer all at once with `0x6E`; only one command at once will work.\n\nBuilding from source code\n-------------------------\n\nIf you want to build CrashDetect from source code, e.g. to fix a bug and\nsubmit a pull request, simply follow the steps below. You will need a C++\ncompiler and CMake.\n\n### Linux\n\nInstall gcc and g++, make and cmake. On Ubuntu you would do that like so:\n\n```\nsudo apt-get install gcc g++ make cmake\n```\n\nIf you're on a 64-bit system you'll need additional packages for compiling\nfor 32-bit:\n\n```\nsudo apt-get install gcc-multilib g++-multilib\n```\n\nFor CentOS:\n\n```\nyum install gcc gcc-c++ cmake28 make\n```\n\nNow you're ready to build CrashDetect:\n\n```\ncd crashdetect\nmkdir build \u0026\u0026 cd build\ncmake ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF\nmake\n```\n\n### Windows\n\nYou'll need to install CMake and Visual Studio (Express edition will suffice).\nAfter that, either run cmake from the command line:\n\n```\ncd crashdetect\nmkdir build \u0026\u0026 cd build\npath/to/cmake.exe ../ -DBUILD_TESTING=OFF\n```\n\nor do the same from cmake-gui. This will generate a Visual Studio project in\nthe build folder.\n\nTo build the project:\n\n```\npath/to/cmake.exe --build . --config Release\n```\n\nYou can also build it from within Visual Studio: open build/crashdetect.sln\nand go to menu -\u003e Build -\u003e Build Solution (or just press F7).\n\nLicense\n-------\n\nLicensed under the 2-clause BSD license. See [LICENSE.txt](LICENSE.txt).\n\n[github]: https://github.com/Zeex/samp-plugin-crashdetect\n[version]: http://badge.fury.io/gh/Zeex%2Fsamp-plugin-crashdetect\n[version_badge]: https://badge.fury.io/gh/Zeex%2Fsamp-plugin-crashdetect.svg\n[build]: https://ci.appveyor.com/project/Zeex/samp-plugin-crashdetect/branch/master\n[build_status]: https://ci.appveyor.com/api/projects/status/nay4h3t5cu6469ic/branch/master?svg=true\n[download]: https://github.com/Zeex/samp-plugin-crashdetect/releases\n[debug_info]: https://github.com/Zeex/samp-plugin-crashdetect/wiki/Compiling-scripts-with-debug-info\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeex%2Fsamp-plugin-crashdetect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeex%2Fsamp-plugin-crashdetect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeex%2Fsamp-plugin-crashdetect/lists"}