current commit
261028.3 · Automate JS-to-JS library dependencies using Acorn (#27995)
/**
 * @license
 * Copyright 2026 The Emscripten Authors
 * SPDX-License-Identifier: MIT
 */

#if WASM_EXCEPTIONS
#error "Internal error! WASM_EXCEPTIONS should not be enabled when including libunwind.js."
#endif

var LibraryUnwind = {

  _Unwind_Backtrace: (func, arg) => {
    var trace = getCallstack();
    var parts = trace.split('\n');
    for (var i = 0; i < parts.length; i++) {
      var ret = {{{ makeDynCall('iii', 'func') }}}(0, arg);
      if (ret) return;
    }
  },

  _Unwind_GetIPInfo: (context, ipBefore) => abort('Unwind_GetIPInfo'),

  _Unwind_FindEnclosingFunction: (ip) => 0, // we cannot succeed

  _Unwind_RaiseException: (ex) => {
    {{{ makeThrow('ex') }}}
  },

  _Unwind_Resume: (ex) => {
    {{{ makeThrow('ex') }}}
  },

  _Unwind_DeleteException: (ex) => err('TODO: Unwind_DeleteException'),
};

addToLibrary(LibraryUnwind);