How to read the stack trace report from Process.info()

Hello folks,

I started using the Process.info to print a stack trace in different spots of a program. what I’m trying to accomplish is to trace how calls are being made and where the data is being set/changed.

I’m a bit confused on how t read the report, should the report be read from the top to bottom or from the bottom to the top…

sample report:

stacktrace length: 20
STACKTRACE: {:current_stacktrace,
 [
   {Process, :info, 2, [file: 'lib/process.ex', line: 766]},
   {TS, :logger, 1, [file: 'lib/ts_logger.ex', line: 18]},
   {Work, :schema, 4,
    [file: 'lib/trabajo/client_temps/work.ex', line: 152]},
   {Work, :crear_trabajo, 2,
    [file: 'lib/trabajo/client_temps/work.ex', line: 124]},
   {temps, :"-expand/3-fun-0-", 3,
    [file: 'lib/client_temps/client_temps.ex', line: 54]},
   {temps, :"-reduce_all/3-fun-0-", 3,
    [file: 'lib/client_temps/client_temps.ex', line: 195]},
   {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 2193]},
   {temps, :reduce_all, 3,
    [file: 'lib/client_temps/client_temps.ex', line: 189]},
   {temps, :"-reduce_all/3-fun-0-", 3,
    [file: 'lib/client_temps/client_temps.ex', line: 195]},
   {Enum, :"-reduce/3-lists^foldl/2-0-", 3, [file: 'lib/enum.ex', line: 2193]},
   {temps, :reduce_all, 3,
    [file: 'lib/client_temps/client_temps.ex', line: 189]},
   {temps, :build, 3,
    [file: 'lib/client_temps/client_temps.ex', line: 40]},
   {AspireApi.Work.Controller, :get_task_form, 2,
    [file: 'web/work_defs/work_controller.ex', line: 27]},
   {AspireApi.Work.Controller, :action, 2,
    [file: 'web/work_defs/work_controller.ex', line: 1]},
   {AspireApi.Work.Controller, :phoenix_controller_pipeline, 2,
    [file: 'web/work_defs/work_controller.ex', line: 1]},
   {Phoenix.Router, :__call__, 2, [file: 'lib/phoenix/router.ex', line: 352]},
   {AspireApi.Endpoint, :plug_builder_call, 2,
    [file: 'lib/aspire_api/endpoint.ex', line: 1]},
   {AspireApi.Endpoint, :call, 2, [file: 'lib/aspire_api/endpoint.ex', line: 1]},
   {Phoenix.Endpoint.Cowboy2Handler, :init, 4,
    [file: 'lib/phoenix/endpoint/cowboy2_handler.ex', line: 65]},
 ]}

as this line is at the top, then from top to bottom.

FYI, there is a function that can format a stacktrace Exception — Elixir v1.16.0

1 Like

awesome, thanks