获取当前的GCC异常模型 [英] Obtaining current GCC exception model
问题描述
DWARF2
, sjlj
构建 seh
异常模型。 MinGW-build 提供了 g ++
的各种版本有不同的异常模型。我希望能够从 gcc
工具链中确定正在使用的异常模型。是否有一个 g ++
参数可以转储编译器的默认异常模型? 编辑:最初,我正在测试 g ++ -v
中描述的配置标志。正如Jonathon Wakely在评论中指出的那样,这不是一件好事情。
检查方法是编译为assembly:
struct S {〜S(); };
void bar();
void foo(){
S s;
bar();
g ++ -S< filename> -o output.s
在它们中有以下异常引用:
MinGW-4.8.1- x86-posix-sjlj
:
.def ___gxx_personality_sj0; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Register; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Unregister; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x86-posix-矮人
:
.def ___gxx_personality_v0; .scl 2; .type 32; .endef
.def __Unwind_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x64-win32- sjlj
:
.def __gxx_personality_sj0; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Register; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Unregister; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x64-posix- seh
:
.def __gxx_personality_seh0; .scl 2; .type 32; .endef
.def _Unwind_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x64-posix- sjlj
:
.def __gxx_personality_sj0; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Register; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Unregister; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Resume; .scl 2; .type 32; .endef
FC17-g ++ - 4.7.2-x64
:
.cfi_personality 0x3,__ gxx_personality_v0
.globl __gxx_personality_v0
call _Unwind_Resume
看起来我们应该搜索 __ gxx_personality _([az]) (0-9] +)
,然后比较第一个捕获组:
v
= dwarf
seh
= seh
sj
= sjlj
g++
is built using either the DWARF2
, sjlj
or seh
exception model. MinGW-builds provide various builds of g++
that have different exception models. I would like to be able to determine from the gcc
toolchain what exception model is being used. Is there a g++
argument that will dump the default exception model of the compiler?
Edit: Originally, I was testing for the configuration flags that are described in g++ -v
. As Jonathon Wakely points out in the comments, this is not a good thing to do.
An inspection way to do it is to compile to assembly:
struct S { ~S(); };
void bar();
void foo() {
S s;
bar();
}
The result of g++ -S <filename> -o output.s
have the following exception references in them:
MinGW-4.8.1-x86-posix-sjlj
:
.def ___gxx_personality_sj0; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Register; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Unregister; .scl 2; .type 32; .endef
.def __Unwind_SjLj_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x86-posix-dwarf
:
.def ___gxx_personality_v0; .scl 2; .type 32; .endef
.def __Unwind_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x64-win32-sjlj
:
.def __gxx_personality_sj0; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Register; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Unregister; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x64-posix-seh
:
.def __gxx_personality_seh0; .scl 2; .type 32; .endef
.def _Unwind_Resume; .scl 2; .type 32; .endef
MinGW-4.8.1-x64-posix-sjlj
:
.def __gxx_personality_sj0; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Register; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Unregister; .scl 2; .type 32; .endef
.def _Unwind_SjLj_Resume; .scl 2; .type 32; .endef
FC17-g++-4.7.2-x64
:
.cfi_personality 0x3,__gxx_personality_v0
.globl __gxx_personality_v0
call _Unwind_Resume
Looks like we should search for __gxx_personality_([a-z])(0-9]+)
and then compare the first capture group to:
v
=dwarf
seh
=seh
sj
=sjlj
这篇关于获取当前的GCC异常模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!