diff --git a/SpacemanDMM.toml b/SpacemanDMM.toml index 81aff0d5576..b1c71c30062 100644 --- a/SpacemanDMM.toml +++ b/SpacemanDMM.toml @@ -7,3 +7,6 @@ disallow_relative_proc_definitions = true [dmdoc] use_typepath_names = true + +[debugger] +engine = "auxtools" diff --git a/code/__DEFINES/_tick.dm b/code/__DEFINES/_tick.dm index a8f7a18a028..c5310296fbb 100644 --- a/code/__DEFINES/_tick.dm +++ b/code/__DEFINES/_tick.dm @@ -1,7 +1,11 @@ /// Percentage of tick to leave for master controller to run #define MAPTICK_MC_MIN_RESERVE 58 //SKYRAT EDIT ORIGINAL: 70 /// internal_tick_usage is updated every tick by extools +#ifdef USE_EXTOOLS #define MAPTICK_LAST_INTERNAL_TICK_USAGE ((GLOB.internal_tick_usage / world.tick_lag) * 100) +#else +#define MAPTICK_LAST_INTERNAL_TICK_USAGE (world.map_cpu) +#endif /// Tick limit while running normally #define TICK_BYOND_RESERVE 2 #define TICK_LIMIT_RUNNING (max(100 - TICK_BYOND_RESERVE - MAPTICK_LAST_INTERNAL_TICK_USAGE, MAPTICK_MC_MIN_RESERVE)) diff --git a/code/__DEFINES/qdel.dm b/code/__DEFINES/qdel.dm index 11b4bf2acd4..0d156b8fb7c 100644 --- a/code/__DEFINES/qdel.dm +++ b/code/__DEFINES/qdel.dm @@ -15,8 +15,8 @@ //! Defines for the [gc_destroyed][/datum/var/gc_destroyed] var. -#ifdef LEGACY_REFERENCE_TRACKING -/** If LEGACY_REFERENCE_TRACKING is enabled, qdel will call this object's find_references() verb. +#ifdef REFERENCE_TRACKING +/** If REFERENCE_TRACKING is enabled, qdel will call this object's find_references() verb. * * Functionally identical to [QDEL_HINT_QUEUE] if [GC_FAILURE_HARD_LOOKUP] is not enabled in _compiler_options.dm. */ diff --git a/code/__DEFINES/spaceman_dmm.dm b/code/__DEFINES/spaceman_dmm.dm index 568415edd9f..c74ad576085 100644 --- a/code/__DEFINES/spaceman_dmm.dm +++ b/code/__DEFINES/spaceman_dmm.dm @@ -28,7 +28,20 @@ #define VAR_PROTECTED var #endif +/proc/auxtools_stack_trace(msg) + CRASH(msg) + +/proc/enable_debugging(mode, port) + CRASH("auxtools not loaded") + /world/proc/enable_debugger() - var/dll = world.GetConfig("env", "EXTOOLS_DLL") + var/dll = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") if (dll) - call(dll, "debug_initialize")() + call(dll, "auxtools_init")() + enable_debugging() + +/world/Del() + var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (debug_server) + call(debug_server, "auxtools_shutdown")() + . = ..() diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index 2c54136718d..a8aca196bd3 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -75,7 +75,6 @@ #define VV_HK_MARK "mark" #define VV_HK_ADDCOMPONENT "addcomponent" #define VV_HK_MODIFY_TRAITS "modtraits" -#define VV_HK_VIEW_REFERENCES "viewreferences" // /atom #define VV_HK_MODIFY_TRANSFORM "atom_transform" diff --git a/code/_compile_options.dm b/code/_compile_options.dm index d50022e7d5a..8ff0ac753a4 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -11,24 +11,17 @@ #ifdef TESTING #define DATUMVAR_DEBUGGING_MODE -/* -* Enables extools-powered reference tracking system, letting you see what is referencing objects that refuse to hard delete. -* -* * Requires TESTING to be defined to work. -*/ +///Used to find the sources of harddels, quite laggy, don't be surpised if it freezes your client for a good while //#define REFERENCE_TRACKING +#ifdef REFERENCE_TRACKING -///Method of tracking references without using extools. Slower, kept to avoid over-reliance on extools. -//#define LEGACY_REFERENCE_TRACKING -#ifdef LEGACY_REFERENCE_TRACKING - -///Use the legacy reference on things hard deleting by default. +///Run a lookup on things hard deleting by default. //#define GC_FAILURE_HARD_LOOKUP #ifdef GC_FAILURE_HARD_LOOKUP #define FIND_REF_NO_CHECK_TICK #endif //ifdef GC_FAILURE_HARD_LOOKUP -#endif //ifdef LEGACY_REFERENCE_TRACKING +#endif //ifdef REFERENCE_TRACKING #define VISUALIZE_ACTIVE_TURFS //Highlights atmos active turfs in green #define TRACK_MAX_SHARE //Allows max share tracking, for use in the atmos debugging ui @@ -54,6 +47,11 @@ #error You need version 513.1514 or higher #endif +//Don't load extools on 514 +#if DM_VERSION < 514 +#define USE_EXTOOLS +#endif + //Additional code for the above flags. #ifdef TESTING #warn compiling in TESTING mode. testing() debug messages will be visible. diff --git a/code/controllers/subsystem/garbage.dm b/code/controllers/subsystem/garbage.dm index 04c97bf30b6..b35ae5716d2 100644 --- a/code/controllers/subsystem/garbage.dm +++ b/code/controllers/subsystem/garbage.dm @@ -47,7 +47,7 @@ SUBSYSTEM_DEF(garbage) //Queue var/list/queues - #ifdef LEGACY_REFERENCE_TRACKING + #ifdef REFERENCE_TRACKING var/list/reference_find_on_fail = list() #endif @@ -161,7 +161,7 @@ SUBSYSTEM_DEF(garbage) ++gcedlasttick ++totalgcs pass_counts[level]++ - #ifdef LEGACY_REFERENCE_TRACKING + #ifdef REFERENCE_TRACKING reference_find_on_fail -= refID //It's deleted we don't care anymore. #endif if (MC_TICK_CHECK) @@ -173,13 +173,11 @@ SUBSYSTEM_DEF(garbage) switch (level) if (GC_QUEUE_CHECK) #ifdef REFERENCE_TRACKING - D.find_references() - #elif defined(LEGACY_REFERENCE_TRACKING) if(reference_find_on_fail[refID]) - D.find_references_legacy() + D.find_references() #ifdef GC_FAILURE_HARD_LOOKUP else - D.find_references_legacy() + D.find_references() #endif reference_find_on_fail -= refID #endif @@ -194,10 +192,6 @@ SUBSYSTEM_DEF(garbage) to_chat(admin, "## TESTING: GC: -- [ADMIN_VV(D)] | [type] was unable to be GC'd --") testing("GC: -- \ref[src] | [type] was unable to be GC'd --") #endif - #ifdef REFERENCE_TRACKING - GLOB.deletion_failures += D //It should no longer be bothered by the GC, manual deletion only. - continue - #endif I.failures++ if (GC_QUEUE_HARDDELETE) HardDelete(D) @@ -334,10 +328,10 @@ SUBSYSTEM_DEF(garbage) SSgarbage.Queue(D, GC_QUEUE_HARDDELETE) if (QDEL_HINT_HARDDEL_NOW) //qdel should assume this object won't gc, and hard del it post haste. SSgarbage.HardDelete(D) - #ifdef LEGACY_REFERENCE_TRACKING - if (QDEL_HINT_FINDREFERENCE) //qdel will, if LEGACY_REFERENCE_TRACKING is enabled, display all references to this object, then queue the object for deletion. + #ifdef REFERENCE_TRACKING + if (QDEL_HINT_FINDREFERENCE) //qdel will, if REFERENCE_TRACKING is enabled, display all references to this object, then queue the object for deletion. SSgarbage.Queue(D) - D.find_references_legacy() + D.find_references() if (QDEL_HINT_IFFAIL_FINDREFERENCE) SSgarbage.Queue(D) SSgarbage.reference_find_on_fail[REF(D)] = TRUE diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index 14177a63102..4c7b3827544 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -31,7 +31,6 @@ VV_DROPDOWN_OPTION(VV_HK_EXPOSE, "Show VV To Player") VV_DROPDOWN_OPTION(VV_HK_ADDCOMPONENT, "Add Component/Element") VV_DROPDOWN_OPTION(VV_HK_MODIFY_TRAITS, "Modify Traits") - VV_DROPDOWN_OPTION(VV_HK_VIEW_REFERENCES, "View References") //This proc is only called if everything topic-wise is verified. The only verifications that should happen here is things like permission checks! //href_list is a reference, modifying it in these procs WILL change the rest of the proc in topic.dm of admin/view_variables! diff --git a/code/game/world.dm b/code/game/world.dm index 75a6c3fdf74..e1bbc00d6cb 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -29,13 +29,12 @@ GLOBAL_VAR(restart_counter) * All atoms in both compiled and uncompiled maps are initialized() */ /world/New() +#ifdef USE_EXTOOLS var/extools = world.GetConfig("env", "EXTOOLS_DLL") || (world.system_type == MS_WINDOWS ? "./byond-extools.dll" : "./libbyond-extools.so") if (fexists(extools)) call(extools, "maptick_initialize")() - enable_debugger() -#ifdef REFERENCE_TRACKING - enable_reference_tracking() #endif + enable_debugger() log_world("World loaded at [time_stamp()]!") diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 195aaca9aa0..95586f8ba6b 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -188,10 +188,6 @@ GLOBAL_PROTECT(admin_verbs_debug) /client/proc/run_dynamic_simulations, #endif /datum/admins/proc/create_or_modify_area, -#ifdef REFERENCE_TRACKING - /datum/admins/proc/view_refs, - /datum/admins/proc/view_del_failures, -#endif /client/proc/check_timer_sources, /client/proc/toggle_cdn ) diff --git a/code/modules/admin/view_variables/reference_tracking.dm b/code/modules/admin/view_variables/reference_tracking.dm index a8c9946c2d2..699b25f2d43 100644 --- a/code/modules/admin/view_variables/reference_tracking.dm +++ b/code/modules/admin/view_variables/reference_tracking.dm @@ -1,119 +1,14 @@ #ifdef REFERENCE_TRACKING -GLOBAL_LIST_EMPTY(deletion_failures) - -/world/proc/enable_reference_tracking() - var/extools = world.GetConfig("env", "EXTOOLS_DLL") || (world.system_type == MS_WINDOWS ? "./byond-extools.dll" : "./libbyond-extools.so") - if (fexists(extools)) - call(extools, "ref_tracking_initialize")() - -/proc/get_back_references(datum/D) - CRASH("/proc/get_back_references not hooked by extools, reference tracking will not function!") - -/proc/get_forward_references(datum/D) - CRASH("/proc/get_forward_references not hooked by extools, reference tracking will not function!") - -/proc/clear_references(datum/D) - return - -/datum/admins/proc/view_refs(atom/D in world) //it actually supports datums as well but byond no likey - set category = "Debug" - set name = "View References" - - if(!check_rights(R_DEBUG) || !D) - return - - var/list/backrefs = get_back_references(D) - if(isnull(backrefs)) - var/datum/browser/popup = new(usr, "ref_view", "
Error
") - popup.set_content("Reference tracking not enabled") - popup.open(FALSE) - return - - var/list/frontrefs = get_forward_references(D) - var/list/dat = list() - dat += "

References of \ref[D] - [D]


\[Refresh\]
" - dat += "

Back references - these things hold references to this object.

" - dat += "" - dat += "" - for(var/ref in backrefs) - var/datum/backreference = ref - if(isnull(backreference)) - dat += "" - if(istype(backreference)) - dat += "" - else if(islist(backreference)) - dat += "" - else - dat += "" - dat += "
RefTypeVariable NameFollow
GC'd Reference
[REF(backreference)][backreference.type][backrefs[backreference]]\[Follow\]
[REF(backreference)]list[backrefs[backreference]]\[Follow\]
Weird reference type. Add more debugging checks.

" - dat += "

Forward references - this object is referencing those things.

" - dat += "" - dat += "" - for(var/ref in frontrefs) - var/datum/backreference = frontrefs[ref] - dat += "" - dat += "
Variable nameRefTypeFollow
[ref][REF(backreference)][backreference.type]\[Follow\]

" - dat = dat.Join() - - var/datum/browser/popup = new(usr, "ref_view", "
References of \ref[D]
") - popup.set_content(dat) - popup.open(FALSE) - - -/datum/admins/proc/view_del_failures() - set category = "Debug" - set name = "View Deletion Failures" - - if(!check_rights(R_DEBUG)) - return - - var/list/dat = list("") - for(var/t in GLOB.deletion_failures) - if(isnull(t)) - dat += "" - continue - var/datum/thing = t - dat += "" - dat += "
GC'd Reference | Clear Nulls
\ref[thing] | [thing.type][thing.gc_destroyed ? " (destroyed)" : ""] [ADMIN_VV(thing)]

" - dat = dat.Join() - - var/datum/browser/popup = new(usr, "del_failures", "
Deletion Failures
") - popup.set_content(dat) - popup.open(FALSE) - - -/datum/proc/find_references() - testing("Beginning search for references to a [type].") - var/list/backrefs = get_back_references(src) - for(var/ref in backrefs) - if(isnull(ref)) - log_world("## TESTING: Datum reference found, but gone now.") - continue - if(islist(ref)) - log_world("## TESTING: Found [type] \ref[src] in list.") - continue - var/datum/datum_ref = ref - if(!istype(datum_ref)) - log_world("## TESTING: Found [type] \ref[src] in unknown type reference: [datum_ref].") - return - log_world("## TESTING: Found [type] \ref[src] in [datum_ref.type][datum_ref.gc_destroyed ? " (destroyed)" : ""]") - message_admins("Found [type] \ref[src] [ADMIN_VV(src)] in [datum_ref.type][datum_ref.gc_destroyed ? " (destroyed)" : ""] [ADMIN_VV(datum_ref)]") - testing("Completed search for references to a [type].") - -#endif - -#ifdef LEGACY_REFERENCE_TRACKING - -/datum/verb/legacy_find_refs() +/datum/verb/find_refs() set category = "Debug" set name = "Find References" set src in world - find_references_legacy(FALSE) + find_references(FALSE) -/datum/proc/find_references_legacy(skip_alert) +/datum/proc/find_references(skip_alert) running_find_references = type if(usr?.client) if(usr.client.running_find_references) @@ -165,7 +60,7 @@ GLOBAL_LIST_EMPTY(deletion_failures) qdel(src, TRUE) //force a qdel if(!running_find_references) - find_references_legacy(TRUE) + find_references(TRUE) /datum/verb/qdel_then_if_fail_find_references() diff --git a/code/modules/admin/view_variables/topic_basic.dm b/code/modules/admin/view_variables/topic_basic.dm index 3c4156d24ea..dbc2a58be3b 100644 --- a/code/modules/admin/view_variables/topic_basic.dm +++ b/code/modules/admin/view_variables/topic_basic.dm @@ -47,16 +47,6 @@ usr.client.debug_variables(src) return - #ifdef REFERENCE_TRACKING - if(href_list[VV_HK_VIEW_REFERENCES]) - var/datum/D = locate(href_list[VV_HK_TARGET]) - if(!D) - to_chat(usr, "Unable to locate item.") - return - usr.client.holder.view_refs(target) - return - #endif - if(href_list[VV_HK_MARK]) usr.client.mark_datum(target) if(href_list[VV_HK_ADDCOMPONENT]) diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm index 6039e88d9d8..487fc2e000d 100644 --- a/code/modules/admin/view_variables/view_variables.dm +++ b/code/modules/admin/view_variables/view_variables.dm @@ -62,7 +62,6 @@ "Set len" = VV_HREF_TARGETREF_INTERNAL(refid, VV_HK_LIST_SET_LENGTH), "Shuffle" = VV_HREF_TARGETREF_INTERNAL(refid, VV_HK_LIST_SHUFFLE), "Show VV To Player" = VV_HREF_TARGETREF_INTERNAL(refid, VV_HK_EXPOSE), - "View References" = VV_HREF_TARGETREF_INTERNAL(refid, VV_HK_VIEW_REFERENCES), "---" ) for(var/i in 1 to length(dropdownoptions))