Skip to content

Commit

Permalink
[core/state] Dump SparseArray for CrashDumper
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 2, 2025
1 parent f2c84da commit cbefd82
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,8 @@ def _DumpVarFrame(frame):
if case(value_e.Undef):
cell_json['val'] = value.Null

elif case(value_e.Str, value_e.BashArray, value_e.BashAssoc):
elif case(value_e.Str, value_e.BashArray, value_e.BashAssoc,
value_e.SparseArray):
cell_json['val'] = cell.val

else:
Expand Down
24 changes: 24 additions & 0 deletions spec/ble-idioms.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1145,3 +1145,27 @@ true

## N-I bash/zsh/mksh/ash STDOUT:
## END


#### SparseArray: crash dump
case $SH in bash|zsh|mksh|ash) exit ;; esac

OILS_CRASH_DUMP_DIR=$TMP $SH -ec 'a=({0..3}); unset -v "a[2]"; var a = _a2sp(a); false'
json read (&crash_dump) < $TMP/*.json
json write (crash_dump.var_stack[0].a)

## STDOUT:
{
"val": {
"type": "SparseArray",
"data": {
"0": "0",
"1": "1",
"3": "3"
}
}
}
## END

## N-I bash/zsh/mksh/ash STDOUT:
## END

0 comments on commit cbefd82

Please sign in to comment.