Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to show where top level eval is in progress #57137

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2846,6 +2846,12 @@ function include_string(mapexpr::Function, mod::Module, code::AbstractString,
# Wrap things to be eval'd in a :toplevel expr to carry line
# information as part of the expr.
line_and_ex.args[2] = ex
show_eval = JLOptions().show_eval
if show_eval == 2 # show everything
println("eval: ", line_and_ex)
elseif show_eval == 1 # show top location only
println("eval: ", line_and_ex.args[1])
end
result = Core.eval(mod, line_and_ex)
end
return result
Expand Down
1 change: 1 addition & 0 deletions base/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct JLOptions
heap_size_hint::UInt64
trace_compile_timing::Int8
trim::Int8
show_eval::Int8
task_metrics::Int8
timeout_for_safepoint_straggler_s::Int16
end
Expand Down
14 changes: 14 additions & 0 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ JL_DLLEXPORT void jl_init_options(void)
0, // heap-size-hint
0, // trace_compile_timing
JL_TRIM_NO, // trim
0, // show-eval
0, // task_metrics
-1, // timeout_for_safepoint_straggler_s
};
Expand Down Expand Up @@ -330,6 +331,7 @@ static const char opts_hidden[] =
" and can throw errors. With unsafe-warn warnings will be\n"
" printed for dynamic call sites that might lead to such\n"
" errors. In safe mode compile-time errors are given instead.\n"
" --show-eval={loc|full|no*} Show the expression being evaluated before eval.\n"
;

JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
Expand Down Expand Up @@ -381,6 +383,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
opt_gc_threads,
opt_permalloc_pkgimg,
opt_trim,
opt_show_eval,
opt_experimental_features,
};
static const char* const shortopts = "+vhqH:e:E:L:J:C:it:p:O:g:m:";
Expand Down Expand Up @@ -450,6 +453,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
{ "permalloc-pkgimg",required_argument, 0, opt_permalloc_pkgimg },
{ "heap-size-hint", required_argument, 0, opt_heap_size_hint },
{ "trim", optional_argument, 0, opt_trim },
{ "show-eval", optional_argument, 0, opt_show_eval },
{ 0, 0, 0, 0 }
};

Expand Down Expand Up @@ -994,6 +998,16 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
else
jl_errorf("julia: invalid argument to --trim={safe|no|unsafe|unsafe-warn} (%s)", optarg);
break;
case opt_show_eval:
if (optarg == NULL || !strcmp(optarg,"loc"))
jl_options.show_eval = 1;
else if (!strcmp(optarg,"full"))
jl_options.show_eval = 2;
else if (!strcmp(optarg,"no"))
jl_options.show_eval = 0;
else
jl_errorf("julia: invalid argument to --show-eval={yes|no} (%s)", optarg);
break;
case opt_task_metrics:
if (!strcmp(optarg, "no"))
jl_options.task_metrics = JL_OPTIONS_TASK_METRICS_OFF;
Expand Down
1 change: 1 addition & 0 deletions src/jloptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef struct {
uint64_t heap_size_hint;
int8_t trace_compile_timing;
int8_t trim;
int8_t show_eval;
int8_t task_metrics;
int16_t timeout_for_safepoint_straggler_s;
} jl_options_t;
Expand Down
Loading