{"id":47444111,"url":"https://github.com/JuliaDebug/CodeTracking.jl","last_synced_at":"2026-04-06T13:00:57.858Z","repository":{"id":34747706,"uuid":"167376903","full_name":"JuliaDebug/CodeTracking.jl","owner":"JuliaDebug","description":"It's editing-time, do you know where your methods are?","archived":false,"fork":false,"pushed_at":"2026-03-27T20:49:26.000Z","size":214,"stargazers_count":151,"open_issues_count":4,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-03-28T03:07:32.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuliaDebug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-01-24T14:02:27.000Z","updated_at":"2026-03-27T20:29:38.000Z","dependencies_parsed_at":"2024-06-19T11:18:23.369Z","dependency_job_id":"0170008c-fbec-483f-89a5-8226fce9b923","html_url":"https://github.com/JuliaDebug/CodeTracking.jl","commit_stats":{"total_commits":142,"total_committers":13,"mean_commits":"10.923076923076923","dds":0.204225352112676,"last_synced_commit":"923fe46923aefdb191b4a128c5576083cc344e25"},"previous_names":["juliadebug/codetracking.jl","timholy/codetracking.jl"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/JuliaDebug/CodeTracking.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaDebug%2FCodeTracking.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaDebug%2FCodeTracking.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaDebug%2FCodeTracking.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaDebug%2FCodeTracking.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaDebug","download_url":"https://codeload.github.com/JuliaDebug/CodeTracking.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaDebug%2FCodeTracking.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31473271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-03-23T06:00:59.902Z","updated_at":"2026-04-06T13:00:57.853Z","avatar_url":"https://github.com/JuliaDebug.png","language":"Julia","funding_links":[],"categories":["Binary Analysis and Reverse Engineering"],"sub_categories":["Debugging and Introspection"],"readme":"# CodeTracking\n\n[![Build status](https://github.com/timholy/CodeTracking.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/timholy/CodeTracking.jl/actions/workflows/ci.yml)\n[![Coverage](https://codecov.io/gh/timholy/CodeTracking.jl/branch/master/graph/badge.svg?token=bBzCYyj19O)](https://codecov.io/gh/timholy/CodeTracking.jl)\n\nCodeTracking can be thought of as an extension of Julia's\n[InteractiveUtils library](https://docs.julialang.org/en/v1/stdlib/InteractiveUtils/).\nIt provides an interface for obtaining:\n\n- the strings and expressions of method definitions\n- the method signatures (and their corresponding method table) at a specific file \u0026 line number\n- location information for \"dynamic\" code that might have moved since it was first loaded\n- a list of files that comprise a particular package.\n\nCodeTracking is a minimal package designed to work with\n[Revise.jl](https://github.com/timholy/Revise.jl) (for versions v1.1.0 and higher).\nCodeTracking is a very lightweight dependency.\n\n## Examples\n\n### `@code_string` and `@code_expr`\n\n```julia\njulia\u003e using CodeTracking, Revise\n\njulia\u003e print(@code_string sum(1:5))\nfunction sum(r::AbstractRange{\u003c:Real})\n    l = length(r)\n    # note that a little care is required to avoid overflow in l*(l-1)/2\n    return l * first(r) + (iseven(l) ? (step(r) * (l-1)) * (l\u003e\u003e1)\n                                     : (step(r) * l) * ((l-1)\u003e\u003e1))\nend\n\njulia\u003e @code_expr sum(1:5)\n[ Info: tracking Base\nquote\n    #= toplevel:977 =#\n    function sum(r::AbstractRange{\u003c:Real})\n        #= /home/tim/src/julia-1/base/range.jl:978 =#\n        l = length(r)\n        #= /home/tim/src/julia-1/base/range.jl:980 =#\n        return l * first(r) + if iseven(l)\n                    (step(r) * (l - 1)) * l \u003e\u003e 1\n                else\n                    (step(r) * l) * (l - 1) \u003e\u003e 1\n                end\n    end\nend\n```\n\n`@code_string` succeeds in that case even if you are not using Revise, but `@code_expr` always requires Revise.\n(If you must live without Revise, you can use `Meta.parse(@code_string(...))` as a fallback.)\n\n\"Difficult\" methods are handled more accurately with `@code_expr` and Revise.\nHere's one that's defined via an `@eval` statement inside a loop:\n\n```julia\njulia\u003e @code_expr Float16(1) + Float16(2)\n:(a::Float16 + b::Float16 = begin\n          #= /home/tim/src/julia-1/base/float.jl:398 =#\n          Float16(Float32(a) + Float32(b))\n      end)\n```\n\nwhereas `@code_string` cannot return a useful result:\n\n```\njulia\u003e @code_string Float16(1) + Float16(2)\n\"# This file is a part of Julia. License is MIT: https://julialang.org/license\\n\\nconst IEEEFloat = Union{Float16, Float32, Float64}\"\n```\nConsequently it's recommended to use `@code_expr` in preference to `@code_string` wherever possible.\n\n`@code_expr` and `@code_string` have companion functional variants, `code_expr` and `code_string`, which accept the function and a `Tuple{T1, T2, ...}` of types.\n\n`@code_expr` and `@code_string` are based on the lower-level function `definition`;\nyou can read about it with `?definition`.\n\n### Location information\n\n```julia\njulia\u003e using CodeTracking, Revise\n\njulia\u003e m = @which sum([1,2,3])\nsum(a::AbstractArray) in Base at reducedim.jl:648\n\njulia\u003e Revise.track(Base)  # also edit reducedim.jl\n\njulia\u003e file, line = whereis(m)\n(\"/home/tim/src/julia-1/usr/share/julia/base/reducedim.jl\", 642)\n\njulia\u003e m.line\n648\n```\n\nIn this (ficticious) example, `sum` moved because I deleted a few lines higher in the file;\nthese didn't affect the functionality of `sum` (so we didn't need to redefine and recompile it),\nbut it does change the starting line number of the file at which this method appears.\n`whereis` reports the current line number, and `m.line` the old line number. (For technical reasons, it is important that `m.line` remain at the value it had when the code was lowered.)\n\nOther methods of `whereis` allow you to obtain the current position corresponding to a single\nstatement inside a method; see `?whereis` for details.\n\nCodeTracking can also be used to find out what files define a particular package:\n\n```julia\njulia\u003e using CodeTracking, Revise, ColorTypes\n\njulia\u003e pkgfiles(ColorTypes)\nPkgFiles(ColorTypes [3da002f7-5984-5a60-b8a6-cbb66c0b333f]):\n  basedir: /home/tim/.julia/packages/ColorTypes/BsAWO\n  files: [\"src/ColorTypes.jl\", \"src/types.jl\", \"src/traits.jl\", \"src/conversions.jl\", \"src/show.jl\", \"src/operations.jl\"]\n```\n\n\nYou can also find the method signatures at a particular location:\n\n```julia\njulia\u003e signatures_at(ColorTypes, \"src/traits.jl\", 14)\n1-element Vector{Pair{Union{Nothing, Core.MethodTable}, Type}}:\n nothing =\u003e Tuple{typeof(red),AbstractRGB}\n\njulia\u003e signatures_at(\"/home/tim/.julia/packages/ColorTypes/BsAWO/src/traits.jl\", 14)\n1-element Vector{Pair{Union{Nothing, Core.MethodTable}, Type}}:\n nothing =\u003e Tuple{typeof(red),AbstractRGB}\n```\n\nwith the first element being the method table for which the method was added (a value of `nothing` denotes the default method table).\n\nCodeTracking also helps correcting for [Julia issue #26314](https://github.com/JuliaLang/julia/issues/26314):\n\n```julia\njulia\u003e @which uuid1()\nuuid1() in UUIDs at C:\\cygwin\\home\\Administrator\\buildbot\\worker\\package_win64\\build\\usr\\share\\julia\\stdlib\\v1.1\\UUIDs\\src\\UUIDs.jl:50\n\njulia\u003e CodeTracking.whereis(@which uuid1())\n(\"C:\\\\Users\\\\SomeOne\\\\AppData\\\\Local\\\\Julia-1.1.0\\\\share\\\\julia\\\\stdlib\\\\v1.1\\\\UUIDs\\\\src\\\\UUIDs.jl\", 50)\n```\n\n## A few details\n\nCodeTracking has limited functionality unless the user is also running Revise,\nbecause Revise populates CodeTracking's internal variables.\n(Using `whereis` as an example, CodeTracking will just return the\nfile/line info in the method itself if Revise isn't running.)\n\nCodeTracking is perhaps best thought of as the \"query\" part of Revise.jl,\nproviding a lightweight and stable API for gaining access to information it maintains internally.\n\n## Limitations (without Revise)\n\n- parsing sometimes starts on the wrong line. Line numbers are determined by counting `'\\n'` in the source file, without parsing the contents. Consequently quoted- or in-code `'\\n'` can mess up CodeTracking's notion of line numbering\n- default constructor methods for `struct`s are not found\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJuliaDebug%2FCodeTracking.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJuliaDebug%2FCodeTracking.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJuliaDebug%2FCodeTracking.jl/lists"}