Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing stack trace capture on iree_status_t for Win/Mac. (iree-…
…org#15151) Enabled only when `IREE_STATUS_MODE`>=3, which by default means off in release builds and on in debug builds. Capturing stacks isn't free so performance sensitive code should keep them off, though we do split the symbol resolution/string formatting such that it's not the worst thing if they are always-on. It's important that we consistently use `iree_status_from_code` when using status returns for control flow. Example from Windows: ``` D:\Dev\iree\runtime\src\iree\base\internal\file_io.c:295: NOT_FOUND; failed to open file 'oops.vmfb'; stack: 0x00007ff6346eeff3 iree-run-module <iree_file_map_contents_readonly_platform+0xa3> (D:\Dev\iree\runtime\src\iree\base\internal\file_io.c:294) 0x00007ff6346eece7 iree-run-module <iree_file_map_contents_readonly+0x117> (D:\Dev\iree\runtime\src\iree\base\internal\file_io.c:229) 0x00007ff6346eea13 iree-run-module <iree_file_read_contents+0xa3> (D:\Dev\iree\runtime\src\iree\base\internal\file_io.c:132) 0x00007ff634622c9d iree-run-module <iree_tooling_load_bytecode_module+0x27d> (D:\Dev\iree\runtime\src\iree\tooling\context_util.c:73) 0x00007ff634621f97 iree-run-module <iree_tooling_load_modules_from_flags+0x347> (D:\Dev\iree\runtime\src\iree\tooling\context_util.c:155) 0x00007ff6346259d4 iree-run-module <iree_tooling_create_run_context+0x74> (D:\Dev\iree\runtime\src\iree\tooling\run_module.c:96) 0x00007ff634624e3e iree-run-module <iree_tooling_run_module_with_data+0x11e> (D:\Dev\iree\runtime\src\iree\tooling\run_module.c:341) 0x00007ff634624d10 iree-run-module <iree_tooling_run_module_from_flags+0x90> (D:\Dev\iree\runtime\src\iree\tooling\run_module.c:327) 0x00007ff63461a32e iree-run-module <main+0x10e> (D:\Dev\iree\tools\iree-run-module-main.c:43) 0x00007ff6347d92e9 iree-run-module <invoke_main+0x39> (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79) 0x00007ff6347d918e iree-run-module <__scrt_common_main_seh+0x12e> (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288) 0x00007ff6347d904e iree-run-module <__scrt_common_main+0xe> (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331) 0x00007ff6347d937e iree-run-module <mainCRTStartup+0xe> (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17) 0x00007ffc27b97344 ??? <BaseThreadInitThunk+0x14> 0x00007ffc29a026b1 ??? <RtlUserThreadStart+0x21> ; loading bytecode module at 'oops.vmfb'; loading modules and dependencies; creating run context ``` Example from MacOS: ``` iree/runtime/src/iree/base/internal/file_io.c:253: NOT_FOUND; failed to open file '/Users/ben/Dev/iree/../iree-tmp/foo.vmfb'; stack: 0x0000000100093644 iree-run-module <iree_file_map_contents_readonly_platform+0x64> 0x0000000100093318 iree-run-module <iree_file_map_contents_readonly+0x12c> 0x0000000100092ff0 iree-run-module <iree_file_read_contents+0x80> 0x0000000100028a04 iree-run-module <iree_tooling_load_bytecode_module+0x208> 0x0000000100028518 iree-run-module <iree_tooling_load_modules_from_flags+0x28c> 0x000000010002ab90 iree-run-module <iree_tooling_create_run_context+0x68> 0x000000010002a9d8 iree-run-module <iree_tooling_run_module_with_data+0x98> 0x000000010002a934 iree-run-module <iree_tooling_run_module_from_flags+0x64> 0x0000000100006228 iree-run-module <main+0xcc> 0x000000018dd61058 dyld <start+0x8b0> ; loading bytecode module at '/Users/ben/Dev/iree/../iree-tmp/foo.vmfb'; loading modules and dependencies; creating run context ``` Example from Linux: ``` iree/runtime/src/iree/base/internal/file_io.c:199: NOT_FOUND; failed to open file 'oops.vmfb'; stack: 0x00000000004cdafc iree-run-module <???> 0x0000000000725319 iree-run-module <???> 0x0000000000724e7b iree-run-module <???> 0x00000000004dddc2 iree-run-module <???> 0x00000000004dc898 iree-run-module <???> 0x00000000004e7123 iree-run-module <???> 0x00000000004e6586 iree-run-module <???> 0x00000000004e5f8a iree-run-module <???> 0x00000000004c8623 iree-run-module <???> 0x00007f84b58e1083 libc.so.6 <__libc_start_main+0xf3> 0x000000000041d9ce iree-run-module <???> ; loading bytecode module at 'oops.vmfb'; loading modules and dependencies; creating run context ``` ^ https://www.youtube.com/watch?v=lRAZk0Xb0xM If we want stack traces with symbols on linux we'll need to have libdwarf-dev installed and use it to resolve things ala https://gist.github.com/tuxology/6144170 - I'm happy with having symbols on Windows and basic ones in debug mode on Mac for now. We've got everything in place for making linux resolution better if someone cares. I couldn't figure out how to make the builds happy with all the GNU_SOURCE shenannigans and just disabled the whole thing for now. Fixes #55.
- Loading branch information