{"id":1602,"date":"2009-06-18T02:05:05","date_gmt":"2009-06-18T09:05:05","guid":{"rendered":"http:\/\/www.jinmei.org\/blog\/?p=1602"},"modified":"2009-06-19T22:12:15","modified_gmt":"2009-06-20T05:12:15","slug":"_unwind_backtrace%e3%81%a8-fomit-frame-pointer","status":"publish","type":"post","link":"https:\/\/www.jinmei.org\/blog\/2009\/06\/18\/1602","title":{"rendered":"_Unwind_Backtrace()\u3068-fomit-frame-pointer"},"content":{"rendered":"<p><a href=\"http:\/\/www.jinmei.org\/blog\/2009\/06\/14\/1580\">\u4e00\u3064\u524d\u306e\u30a8\u30f3\u30c8\u30ea<\/a>\u306e\u7d9a\u304d\u3002gcc\u306e<code>_Unwind_Backtrace()<\/code>\u306b\u306f\u3001\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306a\u3057\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u305f\u30b3\u30fc\u30c9\u306b\u5bfe\u3057\u3066\u3082\u52d5\u304f\u3068\u3044\u3046\u7279\u9577\u304c\u3042\u308b\u3002\u306f\u3058\u3081\u306f\u3001\u6700\u521d\u306e\u30d5\u30ec\u30fc\u30e0\u306e\u3068\u304d\u3060\u3051builtin\u95a2\u6570\u306b\u983c\u3063\u305f\u5f8c\u306f\u30ec\u30b8\u30b9\u30bf\u306e\u5024\u3092\u5fa9\u5143\u3057\u306a\u304c\u3089\u5dfb\u304d\u623b\u3057\u3066\u3044\u304f\u306e\u3067\u305d\u3046\u3044\u3046\u3053\u3068\u3082\u3067\u304d\u3066\u5f53\u7136\u3001\u304f\u3089\u3044\u306b\u601d\u3063\u3066\u3044\u305f\u306e\u3060\u304c\u3001\u8abf\u3079\u3066\u307f\u305f\u3089\u304b\u306a\u308atricky\u3060\u3068\u3044\u3046\u3053\u3068\u304c\u5224\u660e\u3057\u305f: (\u5c11\u306a\u304f\u3068\u3082FreeBSD\/i386\u306e\u5834\u5408)\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306a\u3057\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u3001gcc\u306f\u5404\u30d5\u30ec\u30fc\u30e0\u306b\u304a\u3051\u308b\u30b9\u30bf\u30c3\u30af\u306e\u4f38\u7e2e\u72b6\u6cc1\u3092\u7d30\u304b\u304f\u8a18\u9332\u3059\u308bFDE\u3092\u4f5c\u308b\u3002<code>_Unwind_Backtrace()<\/code>\u3067\u5dfb\u304d\u623b\u3059\u3068\u304d\u306f\u3001\u30ec\u30b8\u30b9\u30bf\u306e\u72b6\u6cc1\u306b\u306f\u307b\u3068\u3093\u3069\u983c\u3089\u305a\u3001\u4e00\u3064\u524d\u306e\u30d5\u30ec\u30fc\u30e0\u306b\u304a\u3051\u308b\u30b9\u30bf\u30c3\u30af\u306e\u958b\u59cb\u4f4d\u7f6e\u304b\u3089\u3001FDE\u306b\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\u73fe\u5728\u306e\u30d5\u30ec\u30fc\u30e0\u306e\u30b9\u30bf\u30c3\u30af\u306e\u30b5\u30a4\u30ba\u5206\u3092\u5dee\u3057\u5f15\u3044\u3066\u3001\u76f4\u63a5\u73fe\u5728\u30d5\u30ec\u30fc\u30e0\u306e\u30b9\u30bf\u30c3\u30af\u306e\u4f4d\u7f6e\u3092\u8a08\u7b97\u3057\u3066\u3044\u308b\u3002<br \/>\n\u5358\u306b<code>_Unwind_Backtrace()<\/code>\u3092\u4f7f\u3046\u3060\u3051\u306a\u3089\u3001\u3053\u3093\u306a\u3053\u3068\u307e\u3067\u77e5\u3063\u3066\u308b\u5fc5\u8981\u306f\u307e\u3063\u305f\u304f\u306a\u3044\u306e\u3060\u304c\u3001\u305b\u3063\u304b\u304f\u6642\u9593\u3092\u304b\u3051\u3066\u8abf\u3079\u305f\u306e\u3067\u3053\u308c\u3082\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u3066\u304a\u304f\u3053\u3068\u306b\u3059\u308b\u3002<br \/>\n<!--more--><\/p>\n<h2>\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306e\u6709\u7121\u3068backtrace<\/h2>\n<p>i386\u3084x86_64\u306a\u3069\u3067\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u304c\u4f7f\u3048\u308b\u5834\u5408\u306b\u306f\u3001\u304a\u624b\u8efd\u304b\u3064\u3088\u308a\u52b9\u7387\u3088\u304fbacktrace\u60c5\u5831\u3092\u5165\u624b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002ebp\u3084rbp\u30ec\u30b8\u30b9\u30bf\u304c\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u3092\u6307\u3059\u3088\u3046\u306b\u30d0\u30a4\u30ca\u30ea\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u308c\u3070\u3001\u307e\u305a\u306a\u3093\u3089\u304b\u306e\u65b9\u6cd5(\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30ea\u306a\u3069)\u3067\u3053\u308c\u3089\u306e\u30ec\u30b8\u30b9\u30bf\u306e\u5024\u3092\u5165\u624b\u3057\u3001\u3042\u3068\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u9806\u756a\u306b\u30d5\u30ec\u30fc\u30e0\u3092\u305f\u3069\u3063\u3066\u3044\u3051\u3070\u3088\u3044\u3002<\/p>\n<pre class=\"codefrag\">\r\n\/* \u6700\u521d\u306bebp\u306b\u30ec\u30b8\u30b9\u30bf\u306e\u5024\u3092\u30b3\u30d4\u30fc *\/\r\nwhile (ebp != NULL) {\r\n\tretaddr[i++] = ((void **)ebp)[1];\r\n\tebp = *ebp;\r\n}\r\n<\/pre>\n<p>\u3057\u304b\u3057\u3001\u3053\u306e\u65b9\u6cd5\u306b\u306f\u3001\u5b9f\u884c\u30b3\u30fc\u30c9\u304c\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u3092\u4f7f\u308f\u306a\u3044\u3088\u3046\u306a\u6700\u9069\u5316\u3092\u7528\u3044\u3066\u751f\u6210\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u306f\u4f7f\u3048\u306a\u3044\u3068\u3044\u3046\u6b20\u70b9\u304c\u3042\u308b\u3002gcc\u3060\u3068-fomit-frame-pointer\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u3066\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u305f\u30d0\u30a4\u30ca\u30ea\u3067\u306f\u3053\u306e\u6700\u9069\u5316\u304c\u6709\u52b9\u306b\u306a\u308b\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a(\u4f55\u3082\u3057\u306a\u3044)\u30d7\u30ed\u30b0\u30e9\u30e0\u3092i386\u3067\u4f55\u3082\u6307\u5b9a\u305b\u305a\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068<\/p>\n<pre class=\"codefrag\">\r\nvoid\r\nfoo() {\r\n\treturn;\r\n}\r\n<\/pre>\n<p>\u751f\u6210\u3055\u308c\u308b\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b<\/p>\n<pre class=\"codefrag\">\r\nfoo:\r\n\tpushl\t%ebp\r\n\tmovl\t%esp, %ebp\r\n\tsubl\t$8, %esp\r\n\tleave\r\n\tret\r\n<\/pre>\n<p>\u3059\u306a\u308f\u3061\u3001\u307e\u305aebp\u30ec\u30b8\u30b9\u30bf\u3092\u30b9\u30bf\u30c3\u30af\u306b\u7a4d\u307f(\u3053\u306e\u6642\u70b9\u3067\u306febp\u306b\u306f\u4e00\u3064\u4e0a\u306e\u30b9\u30bf\u30c3\u30af\u30d5\u30ec\u30fc\u30e0\u306e\u30a2\u30c9\u30ec\u30b9\u304c\u5165\u3063\u3066\u3044\u308b)\u3001\u6b21\u3044\u3067\u7a4d\u3093\u3060\u5834\u6240(\u30b9\u30bf\u30c3\u30af\u30dd\u30a4\u30f3\u30bf\u306e\u5024)\u3092ebp\u306b\u30b3\u30d4\u30fc\u3059\u308b\u3002\u3053\u308c\u306b\u3088\u308a<code>*(void **)$ebp<\/code>\u304c\u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u3059\u3053\u3068\u306b\u306a\u308b\u3002\u307e\u305f\u3001\u30b9\u30bf\u30c3\u30af\u5185\u306e\u76f4\u524d(\u4e00\u3064\u5965)\u306e\u4f4d\u7f6e\u306b\u306f\u95a2\u6570\u304b\u3089\u306e\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3001<code>((void **)$ebp)[1]<\/code>\u3067\u3053\u306e\u30a2\u30c9\u30ec\u30b9\u304c\u5f97\u3089\u308c\u308b\u3002<\/p>\n<p>\u4e00\u65b9\u3001-fomit-frame-pointer\u4ed8\u304d\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b:<\/p>\n<pre class=\"codefrag\">\r\nfoo:\r\n\tret\r\n<\/pre>\n<p>(\u3064\u307e\u308a\u3001\u672c\u5f53\u306b\u300c\u4f55\u3082\u3057\u306a\u3044\u300d\u95a2\u6570\u306b\u306a\u308b)\u3002\u5f53\u7136\u3001ebp\u30ec\u30b8\u30b9\u30bf\u306b\u306f\u3067\u305f\u3089\u3081\u306a\u5024\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3053\u308c\u306f\u4f7f\u3048\u306a\u3044\u3057\u3001\u4eee\u306b\u30b9\u30bf\u30c3\u30af\u306e\u59cb\u70b9\u304c\u308f\u304b\u3063\u305f\u3068\u3057\u3066\u3082\u3001\u305d\u306e\u5834\u6240\u306b\u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u3078\u306e\u30dd\u30a4\u30f3\u30bf\u304c\u5165\u3063\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001backtrace\u306e\u51e6\u7406\u3092\u518d\u5e30\u7684\u306b\u7d99\u7d9a\u3059\u308b\u305f\u3081\u306e\u5f79\u306b\u306f\u7acb\u305f\u306a\u3044\u3002<\/p>\n<p>i386\u306e\u5834\u5408\u3001\u95a2\u6570\u3078\u306e\u3059\u3079\u3066\u306e\u5f15\u6570\u304c\u30b9\u30bf\u30c3\u30af\u306b\u7a4d\u307e\u308c\u3066\u3044\u3066\u3001\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306a\u3057\u3060\u3068\u304b\u3048\u3063\u3066\u52b9\u7387\u306e\u60aa\u3044\u30b3\u30fc\u30c9\u306b\u306a\u308b\u3053\u3068\u3082\u3042\u308b\u305b\u3044\u304b\u3001\u3053\u306e\u6700\u9069\u5316\u304c\u4f7f\u7528\u3055\u308c\u308b\u4f8b\u306f\u7a00\u306a\u3088\u3046\u3060\u304c\u3001x86_64\u3067\u306f\u5f15\u6570\u304c\u5c11\u306a\u3044\u5834\u5408\u306f\u30ec\u30b8\u30b9\u30bf\u6e21\u3057\u306b\u306a\u308b\u305f\u3081\u306b\u3088\u308a\u7a4d\u6975\u7684\u306b\u7528\u3044\u3089\u308c\u308b\u50be\u5411\u304c\u3042\u308b\u3089\u3057\u3044\u3002\u5b9f\u969b\u3001x86_64\u306eDebian\u3067gcc\u306b-O2\u3092\u4ed8\u3051\u3066\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u81ea\u52d5\u7684\u306b-fomit-frame-pointer\u76f8\u5f53\u306e\u6700\u9069\u5316\u304c\u7528\u3044\u3089\u308c\u308b\u3088\u3046\u3060\u3002<\/p>\n<p><code>_Unwind_Backtrace()<\/code>\u306f\u3001\u3053\u3046\u3044\u3046\u5834\u5408\u3067\u3082\u5229\u7528\u3067\u304d\u308b\u3002\u305f\u3068\u3048\u3070\u3001<a href=\"http:\/\/www.jinmei.org\/blog\/2009\/06\/14\/1580\">\u4e00\u3064\u524d\u306e\u30a8\u30f3\u30c8\u30ea<\/a>\u3067\u793a\u3057\u305f<a href=\"http:\/\/www.jinmei.org\/download\/unwindtest.c\">\u691c\u8a3c\u7528\u306e\u30d7\u30ed\u30b0\u30e9\u30e0<\/a>\u306f-fomit-frame-pointer\u4ed8\u304d\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u3082\u52d5\u4f5c\u3059\u308b:<\/p>\n<pre class=\"codefrag\">\r\n% cc -fomit-frame-pointer -g -o unwindtest unwindtest.c\r\n\r\n% .\/unwindtest -e\r\nframe[0] 0x8048eda: entrance pt=0x8048eac, diff=46\r\nframe[1] 0x8048fa0: entrance pt=0x8048f98, diff=8\r\nframe[2] 0x8048fd6: entrance pt=0x8048fa4, diff=50\r\n<\/pre>\n<p>\u4ee5\u4e0b\u306f\u305d\u306e\u4ed5\u7d44\u307f\u306e\u8a73\u7d30\u306b\u3064\u3044\u3066\u8abf\u3079\u305f\u7d50\u679c\u306e\u8a73\u7d30\u3002<\/p>\n<h2>gcc builtin\u95a2\u6570\u3068\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf<\/h2>\n<p>\u307e\u305a\u3001<code>_Unwind_Backtrace()<\/code>\u304c\u4f9d\u5b58\u3057\u3066\u3044\u308bgcc\u306ebuiltin\u95a2\u6570\u304c\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306a\u3057\u3067\u3082\u52d5\u304f\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<p><code>__builtin_return_address(0)<\/code>\u306f\u3001(\u5b9f\u88c5\u306f\u898b\u3066\u306a\u3044\u3051\u3069)\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u6587\u8108\u306b\u3088\u3063\u3066\u52d5\u4f5c\u3092\u5909\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3089\u3057\u304f\u3001\u305f\u3068\u3048\u3070\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u304c\u5229\u7528\u3067\u304d\u308b\u304b\u3069\u3046\u304b\u306b\u3088\u3063\u3066\u751f\u6210\u3059\u308b\u30b3\u30fc\u30c9\u3092\u5909\u3048\u3066\u3044\u308b\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092i386\u3067\u4f55\u3082\u6307\u5b9a\u305b\u305a\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068<\/p>\n<pre class=\"codefrag\">\r\nvoid *foo() {\r\n\tvoid *p = __builtin_return_address(0);\r\n\treturn (p);\r\n}\r\n<\/pre>\n<p>\u751f\u6210\u3055\u308c\u308b\u30b3\u30fc\u30c9\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<pre class=\"codefrag\">\r\nfoo:\r\n\tpushl\t%ebp\r\n\tmovl\t%esp, %ebp\r\n\tsubl\t$4, %esp\r\n\tmovl\t4(%ebp), %eax\r\n\tmovl\t%eax, -4(%ebp)\r\n\tmovl\t-4(%ebp), %eax\r\n\tleave\r\n\tret\r\n<\/pre>\n<p>\u3053\u3053\u3067\u306febp\u30ec\u30b8\u30b9\u30bf\u3092\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u3068\u3057\u3066\u4f7f\u3048\u308b\u306e\u3067\u3001<code>__builtin_return_address(0)<\/code>\u306f<code>4(%ebp) (= ((void **)$ebp)[1])<\/code>\u306b\u5c55\u958b\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002<\/p>\n<p>\u4e00\u65b9\u3001\u540c\u3058\u30d7\u30ed\u30b0\u30e9\u30e0\u3092-fomit-frame-pointer\u4ed8\u304d\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u751f\u6210\u3055\u308c\u308b\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<pre class=\"codefrag\">\r\nfoo:\r\n\tsubl\t$4, %esp\r\n\tmovl\t4(%esp), %eax\r\n\tmovl\t%eax, (%esp)\r\n\tmovl\t(%esp), %eax\r\n\taddl\t$4, %esp\r\n\tret\r\n<\/pre>\n<p>\u3053\u306e\u5834\u5408\u306febp\u30dd\u30a4\u30f3\u30bf\u3092\u3042\u3066\u306b\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u30b9\u30bf\u30c3\u30af\u30dd\u30a4\u30f3\u30bf\u3092\u30b9\u30bf\u30c3\u30af\u306e\u30b5\u30a4\u30ba\u5206\u3060\u3051\u5dfb\u304d\u623b\u3057\u305f\u4f4d\u7f6e\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u5024<code>4(%esp) (= ((void **)$esp)[1])<\/code>\u304c<code>__builtin_return_address(0)<\/code>\u306e\u5024\u306b\u306a\u3063\u3066\u3044\u308b\u3002\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u3092\u4f7f\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u4f4d\u7f6e\u306b\u306f\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u306f\u305a\u3067\u3001\u3053\u308c\u306f\u6b63\u3057\u3044\u5024\u3067\u3042\u308b\u3002<\/p>\n<p>\u4ee5\u4e0a\u306e\u3088\u3046\u306b\u3001<code>__builtin_return_address(0)<\/code>\u306f\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306e\u6709\u7121\u306b\u95a2\u308f\u3089\u305a\u6b63\u3057\u3044\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u3092\u8fd4\u3059\u3053\u3068\u304c\u308f\u304b\u308b\u3002\u8a73\u7d30\u306f\u7701\u7565\u3059\u308b\u304c\u3001<code>__builtin_dwarf_cfa()<\/code>\u3082\u6587\u8108\u306b\u3088\u3063\u3066\u6319\u52d5\u304c\u5909\u308f\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u3066\u3001\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u304c\u5229\u7528\u3067\u304d\u306a\u304f\u3066\u3082\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u3002<\/p>\n<h2>\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306b\u983c\u3089\u306a\u3044DWARF2\u51e6\u7406(\u4e88\u5099\u77e5\u8b58)<\/h2>\n<p>gcc\u306ebuiltin\u95a2\u6570\u3092\u4f7f\u3063\u3066\u6700\u521d(\u6700\u4e0b\u5c64)\u306e\u30d5\u30ec\u30fc\u30e0\u306e\u60c5\u5831\u3092\u5f97\u305f\u5f8c\u306f\u3001DWARF2(\u3082\u3069\u304d)\u306e\u30d5\u30ec\u30fc\u30e0\u60c5\u5831\u3092\u3082\u3068\u306b\u30d5\u30ec\u30fc\u30e0\u3092\u9061\u308b\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<p>\u3053\u306e\u52d5\u4f5c\u3092\u3001\u524d\u56de\u793a\u3057\u305f\u691c\u8a3c\u7528\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u304a\u3044\u3066<code>show_backtrace()<\/code>\u304b\u3089<code>bar()<\/code>\u306b\u9061\u308b\u90e8\u5206\u306b\u3064\u3044\u3066\u5177\u4f53\u7684\u306b\u78ba\u8a8d\u3057\u3066\u307f\u308b\u3002\u3053\u308c\u3092\u7406\u89e3\u3059\u308b\u305f\u3081\u306b\u306f\u3001DWARF2\u306e\u4ed5\u69d8\u3068gcc\u306eunwind\u306b\u304a\u3051\u308b\u305d\u306e\u5b9f\u88c5\u306b\u95a2\u3059\u308b\u77e5\u8b58\u304c\u591a\u5c11\u5fc5\u8981\u306b\u306a\u308b\u3002<\/p>\n<ul>\n<li>CFA: Canonical Frame Address. \u5404\u30d5\u30ec\u30fc\u30e0\u3067\u5229\u7528\u3059\u308b\u30b9\u30bf\u30c3\u30af\u9818\u57df\u306e\u59cb\u70b9(=\u5e95)\u3092\u6307\u3059\u30a2\u30c9\u30ec\u30b9\u3002\u305f\u3060\u3057\u3001gcc unwind\u306b\u304a\u3051\u308bCFA\u306e\u5b9a\u7fa9\u306f\u4e00\u822c\u7684\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u306e\u30b9\u30bf\u30c3\u30af\u306e\u59cb\u70b9\u3068\u306f\u9055\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3001i386\u306e\u5834\u5408\u3067\u3044\u3048\u3070\u300c\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u304c\u5165\u3063\u3066\u3044\u308b\u5834\u6240 + 4\u30d0\u30a4\u30c8\u300d\u306e\u4f4d\u7f6e\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u3002\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306e\u3042\u308b\u5834\u5408\u306a\u3089<code>$ebp + 8<\/code>\u306b\u306a\u308b\u3002<\/li>\n<li>\u30ec\u30b8\u30b9\u30bf: DWARF2\u3067\u306f\u3001\u5bfe\u8c61\u3068\u3059\u308b\u30de\u30b7\u30f3\u306e\u72b6\u614b\u3092\u6a21\u5023\u3059\u308b\u305f\u3081\u306b\u4f7f\u3046\u4eee\u60f3\u7684\u306a\u30ec\u30b8\u30b9\u30bf\u3092\u7ba1\u7406\u3057\u3066\u3044\u308b\u3002i386\u306e\u5834\u5408\u3001r0\u304b\u3089r17\u307e\u3067\u306e18\u500b\u306e\u30ec\u30b8\u30b9\u30bf\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u3002\u3053\u308c\u3089\u306e\u3046\u3061\u3001\u3053\u3053\u3067\u306e\u8b70\u8ad6\u3067\u5fc5\u8981\u306b\u306a\u308b\u7279\u5225\u306a\u30ec\u30b8\u30b9\u30bf\u306f\u4ee5\u4e0b\u306e2\u3064:\n<ul>\n<li>return address register: \u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u3078\u306e\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u3092\u683c\u7d0d\u3059\u308b\u30ec\u30b8\u30b9\u30bf<\/li>\n<li>CFA\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u8a08\u7b97\u306b\u7528\u3044\u308b\u30ec\u30b8\u30b9\u30bf\u3002DWARF2\u306e\u51e6\u7406\u306e\u9014\u4e2d\u3067CFA\u304c\u5fc5\u8981\u306b\u306a\u3063\u305f\u3089\u3001\u3053\u306e\u30ec\u30b8\u30b9\u30bf\u306e\u5024\u306b\u4e0e\u3048\u3089\u308c\u305f\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u52a0\u3048\u3066\u6c42\u3081\u308b\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>gcc\u306e\u5b9f\u88c5\u306e\u4e2d\u3067\u306f\u3001DWARF2\u306e\u5185\u90e8\u72b6\u614b\u3092<code>context<\/code>\u3068\u3044\u3046<code>struct _Unwind_Context *<\/code>\u578b\u306e\u5909\u6570\u3067\u53c2\u7167\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u3002<code>context->cfa<\/code>\u304cCFA\u3067\u3042\u308a\u3001\u30ec\u30b8\u30b9\u30bf\u7fa4\u306f<code>context->reg[]<\/code>\u3068\u3044\u3046\u914d\u5217\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<p>\u307e\u305f\u3001CIE\u3068FDE\u3067\u6c7a\u307e\u308b\u5404\u30d5\u30ec\u30fc\u30e0\u3054\u3068\u306e\u72b6\u614b\u306f<code>_Unwind_FrameState<\/code>\u3068\u3044\u3046\u69cb\u9020\u4f53\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u3002\u3053\u308c\u306f\u3057\u3070\u3057\u3070<code>fs<\/code>\u3068\u3044\u3046\u30dd\u30a4\u30f3\u30bf\u3092\u901a\u3058\u3066\u53c2\u7167\u3055\u308c\u308b\u3002<code>fs->cfa_reg<\/code>\u304cCFA\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u8a08\u7b97\u3067\u4f7f\u3046\u30ec\u30b8\u30b9\u30bf\u306e\u756a\u53f7(<code>context->reg<\/code>\u306e\u914d\u5217\u30a4\u30f3\u30c7\u30c3\u30af\u30b9)\u3001<code>fs->retaddr_column<\/code>\u304creturn address register\u306e\u756a\u53f7\u306b\u306a\u308b\u3002\u307e\u305f\u3001CFA\u3092\u6c42\u3081\u308b\u969b\u306b\u4f7f\u3046\u30aa\u30d5\u30bb\u30c3\u30c8\u5024\u3068\u3057\u3066\u306f<code>fs->cfa_offset<\/code>\u304c\u4f7f\u308f\u308c\u308b\u3002<\/p>\n<h2>\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306b\u983c\u3089\u306a\u3044DWARF2\u51e6\u7406(\u672c\u7de8)<\/h2>\n<p><code>_Unwind_Backtrace()<\/code>\u304c\u30d5\u30ec\u30fc\u30e0\u3092\u9061\u3063\u3066\u3044\u304f\u969b\u306b\u306f\u3001\u8d77\u70b9\u3068\u306a\u308b\u30d5\u30ec\u30fc\u30e0\u5185\u306e\u30a2\u30c9\u30ec\u30b9(\u3053\u308c\u306f<code>_Unwind_Backtrace()<\/code>\u81ea\u8eab)\u3092\u3082\u3068\u306b\u3001\u5bfe\u5fdc\u3059\u308bFDE(\u3068\u305d\u308c\u306b\u4ed8\u968f\u3059\u308bCIE)\u3092\u6c42\u3081\u3001CIE\u306einstruction\u3001FDE\u306einstruction\u306e\u9806\u306bDWARF2\u4e0a\u306e\u30ec\u30b8\u30b9\u30bf\u3092\u64cd\u4f5c\u3059\u308b\u3002\u305d\u306e\u7d50\u679c\u3068\u3057\u3066return address register\u306b\u306f\u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u5185\u306e\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u304c\u683c\u7d0d\u3055\u308c\u3001CFA\u3092\u6c42\u3081\u308b\u305f\u3081\u306e\u30ec\u30b8\u30b9\u30bf\u3082\u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u306b\u304a\u3051\u308bCFA\u3092\u8a08\u7b97\u3059\u308b\u305f\u3081\u306e\u5024\u306b\u66f4\u65b0\u3055\u308c\u308b(\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u304c\u3042\u308b\u5834\u5408\u306a\u3089\u3001\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306e\u30ec\u30b8\u30b9\u30bf\u3092pop\u3059\u308b\u64cd\u4f5c\u306b\u76f8\u5f53\u3059\u308b)\u3002<\/p>\n<p>\u3044\u307e\u8003\u3048\u3066\u3044\u308b\u4f8b\u3001\u3064\u307e\u308a<code>show_backtrace()<\/code>\u304b\u3089<code>bar()<\/code>\u306b\u9061\u308b\u5834\u5408\u306b\u3069\u3046\u3044\u3046\u64cd\u4f5c\u304c\u8d77\u304d\u3066\u3044\u308b\u304b\u3092\u8abf\u3079\u308b\u305f\u3081\u306b\u3001\u307e\u305a<code>show_backtrace()<\/code>\u306eCIE\u3068FDE\u306e\u5185\u5bb9\u3092\u898b\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"codefrag\">\r\n% readelf --debug-dump=frames unwindtest(\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u540d)\r\n<\/pre>\n<p>\u306a\u3069\u3068\u3059\u308b\u3068\u3001.eh_frame\u3068.debug_frame section\u306e\u5185\u5bb9\u304c\u4eba\u9593\u304c\u8aad\u3081\u308b\u5f62\u5f0f(\u3068\u3044\u3063\u3066\u3082DWARF2\u306e\u4ed5\u69d8\u3092\u77e5\u3089\u306a\u3051\u308c\u3070\u307b\u3068\u3093\u3069\u6697\u53f7\u3060\u304c)\u3067\u30c0\u30f3\u30d7\u3055\u308c\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u53c2\u7167\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308b:<\/p>\n<pre class=\"codefrag\">\r\nCIE\r\n  Return address column: 8\r\n  DW_CFA_def_cfa: r4 ofs 4\r\n  DW_CFA_offset: r8 at cfa-4\r\n\r\nFDE cie=00000000 pc=08048e6c..08048eab\r\n  DW_CFA_advance_loc: 3 to 08048e6f\r\n  DW_CFA_def_cfa_offset: 32\r\n  DW_CFA_advance_loc: 34 to 08048e91\r\n  DW_CFA_def_cfa_offset: 40\r\n  DW_CFA_advance_loc: 5 to 08048e96\r\n  DW_CFA_def_cfa_offset: 44\r\n  DW_CFA_advance_loc: 5 to 08048e9b\r\n  DW_CFA_def_cfa_offset: 48\r\n  DW_CFA_advance_loc: 8 to 08048ea3\r\n  DW_CFA_def_cfa_offset: 32\r\n<\/pre>\n<p>(\u306a\u304a\u3001\u3053\u3053\u3067\u306e\u8a71\u306b\u95a2\u4fc2\u306a\u3044\u51fa\u529b\u3092\u524a\u308b\u306a\u3069\u3057\u3066\u4e00\u90e8\u7c21\u7565\u5316\u3057\u3066\u3044\u308b)<\/p>\n<p>\u307e\u305a\u3001CIE\u306einstruction\u306b\u3088\u308c\u3070\u3001<\/p>\n<ul>\n<li>CFA\u306f\u30ec\u30b8\u30b9\u30bfr4\u306e\u5024+4(gcc\u306e\u5185\u90e8\u7684\u306b\u306f<code>*((void **)context->reg[4])<\/code>)<\/li>\n<li>\u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u3078\u306e\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u306fr8\u306b\u683c\u7d0d\u3055\u308c\u308b<\/li>\n<li>r8\u306e\u5024\u306fCFA &#8211; 4\u756a\u5730\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b<\/li>\n<\/ul>\n<p>\u3053\u3068\u304c\u308f\u304b\u308b\u3002\u3064\u307e\u308a\u3001\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u304cCFA &#8211; 4\u306e\u4f4d\u7f6e\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u3053\u308c\u306f\u524d\u9805\u3067\u66f8\u3044\u305fi386\u306b\u304a\u3051\u308bCFA\u306e\u4e00\u822c\u7684\u306a\u7528\u6cd5\u3068\u5408\u81f4\u3059\u308b\u3002<\/p>\n<p>\u554f\u984c\u306fFDE\u306e\u90e8\u5206\u3067\u3001\u3053\u308c\u306f\u7d50\u5c40\u30b3\u30fc\u30c9\u5185\u306e5\u3064\u306e\u500b\u6240\u306b\u304a\u3051\u308b\u30b9\u30bf\u30c3\u30af\u306e\u4f38\u7e2e\u306e\u69d8\u5b50\u3092\u8a18\u9332\u3057\u3066\u3044\u308b\u3060\u3051\u306e\u3082\u306e\u306b\u306a\u3063\u3066\u3044\u3066\u3001\u3069\u306e\u30ec\u30b8\u30b9\u30bf\u3082\u66f4\u65b0\u3055\u308c\u3066\u3044\u306a\u3044\u3002\u3057\u305f\u304c\u3063\u3066\u3001CIE\u3068FDE\u306einstruction\u3092\u901a\u3058\u3066\u66f4\u65b0\u3055\u308c\u308b\u30ec\u30b8\u30b9\u30bf\u306fr8\u3060\u3051\u3060\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<p>\u4e00\u65b9\u3001\u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u306b\u76f8\u5f53\u3059\u308b<code>bar()<\/code>\u306eFDE\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b(\u306a\u304a\u3001CIE\u306f\u4e0a\u3068\u5171\u901a):<\/p>\n<pre class=\"codefrag\">\r\nFDE cie=00000000 pc=08048eac..08048f95\r\n  DW_CFA_advance_loc: 3 to 08048eaf\r\n  DW_CFA_def_cfa_offset: 48\r\n  DW_CFA_advance_loc: 11 to 08048eba\r\n  DW_CFA_def_cfa_offset: 52\r\n[...\u4ee5\u4e0b\u57fa\u672c\u7684\u306b\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u7e70\u308a\u8fd4\u3057]\r\n<\/pre>\n<p>\u3059\u306a\u308f\u3061\u3001<code>show_backtrace()<\/code>\u3068\u540c\u69d8\u3001\u30b9\u30bf\u30c3\u30af\u306e\u4f38\u7e2e\u304c\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\u3060\u3051\u3067\u3042\u308b\u3002\u3057\u305f\u304c\u3063\u3066\u3001DWARF2\u306e\u898f\u5247\u306b\u3088\u308c\u3070\u3001<code>bar()<\/code>\u306eCFA\u306f\u30ec\u30b8\u30b9\u30bfr4\u3092\u7528\u3044\u3066\u8a08\u7b97\u3055\u308c\u308b\u306f\u305a\u3060\u304c\u3001r4\u306f<code>show_backtrace()<\/code>\u306e\u30d5\u30ec\u30fc\u30e0\u3067\u306e\u64cd\u4f5c\u3092\u901a\u3058\u3066\u5909\u66f4\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u5f53\u7136\u6b63\u3057\u3044\u5024\u3067\u306f\u3042\u308a\u5f97\u306a\u3044\u3002<\/p>\n<p>\u5b9f\u306f\u3001gcc\u306e<code>_Unwind_Backtrace()<\/code>\u306f\u3001\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u304c\u306a\u3044\u5834\u5408\u306b\u306f\u3061\u3087\u3063\u3068\u7279\u5225\u306a\u51e6\u7406\u3092\u3057\u3066\u72ec\u81ea\u306bCFA\u3092\u8a08\u7b97\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u305d\u306e\u4ed5\u639b\u3051\u306f<a href=\"http:\/\/gcc.gnu.org\/viewcvs\/tags\/gcc_3_4_6_release\/gcc\/unwind-dw2.c?revision=111785&#038;view=markup\">unwind-dw2.c<\/a>\u306e<code>uw_update_context_1()<\/code>\u3068\u3044\u3046\u95a2\u6570\u306e\u4e2d\u306b\u3042\u308b\u4ee5\u4e0b\u306e\u90e8\u5206:<\/p>\n<pre class=\"codefrag\">\r\n  \/* Special handling here: Many machines do not use a frame pointer,\r\n     [...]\r\n     the value over from one frame to another doesn't make sense.  *\/\r\n\r\n  _Unwind_SpTmp tmp_sp;\r\n\r\n  if (!_Unwind_GetGRPtr (&orig_context, __builtin_dwarf_sp_column ()))\r\n    _Unwind_SetSpColumn (&orig_context, context->cfa, &tmp_sp);\r\n  _Unwind_SetGRPtr (context, __builtin_dwarf_sp_column (), NULL);\r\n<\/pre>\n<p>\u3053\u3053\u3067\u3001<code>orig_context<\/code>\u306f<code>uw_update_context_1()<\/code>\u5185\u3067\u306e\u4f5c\u696d\u7528\u306b\u4f5c\u3089\u308c\u305f<code>context<\/code>\u306e\u30b3\u30d4\u30fc\u3002<code>__builtin_dwarf_sp_column ()<\/code>\u306f\u3053\u306e\u74b0\u5883\u3067\u306f4\u3001\u3064\u307e\u308a\u30ec\u30b8\u30b9\u30bfr4\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u8fd4\u3059\u3002<code>_Unwind_SetSpColumn()<\/code>\u306f\u3001\u3053\u306e\u74b0\u5883\u3067\u306f\u3001\u4e0e\u3048\u3089\u308c\u305fcontext(\u7b2c\u4e00\u5f15\u6570)\u306er4\u306b\u6307\u5b9a\u3055\u308c\u305f\u5024(\u7b2c\u4e8c\u5f15\u6570)\u3092\u683c\u7d0d\u3059\u308b\u3002\u3064\u307e\u308a\u3001\u3053\u306e\u7279\u5225\u6271\u3044\u90e8\u5206\u306e\u30b3\u30fc\u30c9\u306f\u3001\u30ec\u30b8\u30b9\u30bfr4\u304c\u672a\u5b9a\u7fa9\u3067\u3042\u308c\u3070\u3001<code>orig_context<\/code>\u5185\u306b\u304a\u3051\u308br4\u306b\u306f\u4e00\u6642\u7684\u306b\u4e00\u3064\u524d\u306eCFA\u306e\u5024\u3092\u4fdd\u6301\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u3002\u307e\u305f\u3001\u6b21\u306e\u30d5\u30ec\u30fc\u30e0\u4ee5\u964dr4\u306e\u5024\u304c(CIE\u307e\u305f\u306fFDE\u3067\u8a2d\u5b9a\u3055\u308c\u306a\u3044\u9650\u308a)\u672a\u5b9a\u7fa9\u306b\u306a\u308b\u3088\u3046\u306b\u4fee\u6b63\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u3053\u306e\u7279\u5225\u30b3\u30fc\u30c9\u306f<code>show_backtrace()<\/code>\u306e\u51e6\u7406\u306e\u90e8\u5206\u3067\u3082\u8d70\u3063\u3066\u3044\u308b\u3002<code>show_backtrace()<\/code>\u306eCIE\u30fbFDE\u51e6\u7406\u3067\u306fr4\u306f\u66f4\u65b0\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001<code>bar()<\/code>\u306e\u51e6\u7406\u306e\u6bb5\u968e\u3067\u306f<code>if<\/code>\u306e\u4e2d\u3082\u5b9f\u65bd\u3055\u308c\u3066\u3001r4\u306b\u306f\u4e00\u6642\u7684\u306b<code>show_backtrace()<\/code>\u306eCFA\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u3002\u3053\u306e\u4ed5\u639b\u3051\u3092\u7528\u3044\u308b\u3068\u3001<code>bar()<\/code>\u306e\u305f\u3081\u306eCFA\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b:<\/p>\n<pre class=\"codefrag\">\r\n  show_backtrace()\u306eCFA + bar()\u306eFDE\u3067\u6307\u5b9a\u3055\u308c\u305f\u30aa\u30d5\u30bb\u30c3\u30c8\r\n<\/pre>\n<p>\u3053\u308c\u3067\u6574\u5408\u6027\u304c\u53d6\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u8abf\u3079\u308b\u305f\u3081\u306b\u3001<code>bar()<\/code>\u306e\u30a2\u30bb\u30f3\u30d6\u30ea\u30b3\u30fc\u30c9\u3092\u898b\u3066\u5b9f\u969b\u306e\u30b9\u30bf\u30c3\u30af\u306e\u69d8\u5b50\u3068\u4ed8\u304d\u5408\u308f\u305b\u3066\u307f\u308b\u3002\u30a2\u30bb\u30f3\u30d6\u30ea\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u901a\u308a(<code>show_backtrace()<\/code>\u3092\u547c\u3076\u90e8\u5206\u307e\u3067):<\/p>\n<pre class=\"codefrag\">\r\n08048eac &lt;bar&gt;:\r\n 8048eac: sub    $0x2c,%esp\r\n 8048eaf: movl   $0x0,0x14(%esp)\r\n 8048eb6:\t\t\t\t\r\n 8048eb7: sub    $0x4,%esp\r\n 8048eba: push   $0xc\r\n 8048ebc: push   $0x0\r\n 8048ebe: lea    0xc(%esp),%eax\r\n 8048ec2: push   %eax\r\n 8048ec3: call   8048694 &lt;_init+0xc4&gt;\r\n 8048ec8: add    $0x10,%esp\r\n 8048ecb: sub    $0x8,%esp\r\n 8048ece: push   $0x3\r\n 8048ed0: lea    0xc(%esp),%eax\r\n 8048ed4: push   %eax\t\t\t\r\n 8048ed5: call   8048e6c &lt;show_backtrace&gt;\r\n<\/pre>\n<p>\u3057\u305f\u304c\u3063\u3066\u3001<code>show_backtrace()<\/code>\u304c\u547c\u3070\u308c\u305f\u6642\u70b9\u3067\u306e\u30b9\u30bf\u30c3\u30af\u306e\u69d8\u5b50\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306f\u305a:<\/p>\n<pre class=\"codefrag\">\r\nsp0+4  &lt;should be cfa for bar()&gt;\r\nsp0->  [retaddr in foo()]\r\n...\r\nsp0-44 (sub $0x2c\u306e\u7d50\u679c)\r\nsp0-52 (sub $0x8\u306e\u7d50\u679c)\r\nsp0-56 [0x3]\r\nsp0-60 [%eax]  &lt;cfa for show_backtrace()&gt;\r\nsp0-64 [retaddr in bar()]\r\n<\/pre>\n<p>\u3053\u3053\u3067\u3001<code>bar()<\/code>\u306e\u958b\u59cb\u6642\u70b9\u3067\u306e\u30b9\u30bf\u30c3\u30af\u30dd\u30a4\u30f3\u30bf\u306e\u5024\u3092sp0\u3068\u3057\u3066\u3044\u308b\u3002sp0\u306b\u306f\u4e00\u3064\u4e0a\u306e\u30d5\u30ec\u30fc\u30e0\u3067\u3042\u308b<code>foo()<\/code>\u5185\u3078\u306e\u623b\u308a\u30a2\u30c9\u30ec\u30b9\u306e\u5024\u304c\u5165\u3063\u3066\u3044\u3066\u3001sp0 + 4\u304c<code>bar()<\/code>\u306eCFA\u3068\u306a\u308b\u306f\u305a\u3002\u307e\u305f\u3001\u30a2\u30bb\u30f3\u30d6\u30ea\u30b3\u30fc\u30c9\u306e\u5185\u5bb9\u304b\u3089\u3001<code>show_backtrace()<\/code>\u304c\u547c\u3070\u308c\u305f\u6642\u70b9\u3067\u306f\u30b9\u30bf\u30c3\u30af\u306fsp0\u304b\u308964\u30d0\u30a4\u30c8\u307e\u3067\u4f38\u3073\u3066\u3044\u3066\u3001\u305d\u306e\u4f4d\u7f6e\u306b<code>bar()<\/code>\u306b\u623b\u3063\u3066\u304f\u308b\u3068\u304d\u306e\u30a2\u30c9\u30ec\u30b9\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u306f\u305a\u3002\u3057\u305f\u304c\u3063\u3066sp0-60\u304c<code>show_backtrace()<\/code>\u306b\u304a\u3051\u308bCFA\u306e\u5024\u3068\u306a\u3063\u3066\u3044\u308b\u306f\u305a\u3067\u3042\u308b\u3002<\/p>\n<p>\u3053\u306e\u56f3\u306b\u3088\u308c\u3070\u3001\u4fee\u6b63\u3059\u3079\u304d\u30aa\u30d5\u30bb\u30c3\u30c8\u306fsp0+4\u3068sp0-60\u306e\u5dee\u5206\u3067\u3042\u308b64\u3068\u306a\u308b\u306f\u305a\u3002\u4e00\u65b9\u3001\u5b9f\u969b\u306eFDE\u306e\u5185\u5bb9\u3092\u898b\u308b\u3068\u3001<\/p>\n<pre class=\"codefrag\">\r\nFDE cie=00000000 pc=08048eac..08048f95\r\n  DW_CFA_advance_loc: 3 to 08048eaf\r\n  DW_CFA_def_cfa_offset: 48\r\n[...]\r\n  DW_CFA_advance_loc: 5 to 08048ed5\r\n  DW_CFA_def_cfa_offset: 64\r\n  DW_CFA_advance_loc: 8 to 08048edd\r\n  DW_CFA_def_cfa_offset: 48\r\n[...]\r\n<\/pre>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3001\u78ba\u304b\u306b64\u306b\u306a\u3063\u3066\u3044\u308b(\u3082\u3063\u3068\u3082\u3001\u3053\u3053\u307e\u3067\u611a\u76f4\u306b\u78ba\u304b\u3081\u305a\u3068\u3082\u3001FDE\u304c\u30b9\u30bf\u30c3\u30af\u306e\u4f38\u7e2e\u3092\u30b3\u30fc\u30c9\u306b\u5fe0\u5b9f\u306b\u8a18\u9332\u3057\u3066\u3044\u3066\u3001CFA\u306e\u4f4d\u7f6e\u304c\u898f\u5247\u901a\u308a\u3067\u3042\u308c\u3070\u3001\u66f4\u65b0\u5f8c\u306eCFA\u306e\u5024\u3082\u6b63\u3057\u3044\u3053\u3068\u306f\u660e\u3089\u304b\u3067\u306f\u3042\u308b)\u3002\u306a\u304a\u3001FDE\u306einstruction\u306f\u3001\u5b9f\u969b\u306b\u3053\u306e\u30d5\u30ec\u30fc\u30e0\u5185\u3067\u51e6\u7406\u304c\u9032\u3093\u3067\u3044\u308b\u4f4d\u7f6e\u3001\u3059\u306a\u308f\u3061<code>show_backtrace()<\/code>\u306ecall\u304b\u3089\u623b\u308b\u76f4\u524d(8048ed5\u756a\u5730\u306e\u76f4\u5f8c)\u307e\u3067\u306e\u307f\u5b9f\u65bd\u3055\u308c\u308b\u3002\u3057\u305f\u304c\u3063\u3066\u30aa\u30d5\u30bb\u30c3\u30c8\u304c64\u306b\u306a\u3063\u305f\u72b6\u614b\u3067instruction\u51e6\u7406\u306f\u6b62\u307e\u3063\u3066\u3044\u308b\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u3053\u308c\u306f\u7d50\u69cb\u969b\u3069\u3044\u6280\u3060\u2026FDE\u306e\u30eb\u30fc\u30eb\u304c\u30b9\u30bf\u30c3\u30af\u306e\u69d8\u5b50\u3092\u7d30\u304b\u304f\u8a18\u9332\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u3066\u306f\u3058\u3081\u3066\u6210\u7acb\u3059\u308b\u65b9\u6cd5\u306a\u306e\u3067\u3002<code>_Unwind_SetSpColumn()<\/code>\u306e\u5834\u5408\u3001FDE\u3092\u4f5c\u308b\u306e\u3082\u8ffd\u3044\u304b\u3051\u308b\u306e\u3082\u5b9f\u8ceagcc\u3060\u304b\u3089\u554f\u984c\u306a\u3044\u3051\u3069\u3001gcc\u3067\u5410\u3044\u305f\u30b3\u30fc\u30c9\u3092\u6bdb\u4e26\u306e\u9055\u3046\u30c7\u30d0\u30c3\u30ac\u3067\u8ffd\u3044\u304b\u3051\u305f\u308a\u3059\u308b\u3068\u306f\u307e\u308b\u3053\u3068\u3082\u3042\u308a\u305d\u3046\u3060\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3064\u524d\u306e\u30a8\u30f3\u30c8\u30ea\u306e\u7d9a\u304d\u3002gcc\u306e_Unwind_Backtrace()\u306b\u306f\u3001\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306a\u3057\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u305f\u30b3\u30fc\u30c9\u306b\u5bfe\u3057\u3066\u3082\u52d5\u304f\u3068\u3044\u3046\u7279\u9577\u304c\u3042\u308b\u3002\u306f\u3058\u3081\u306f\u3001\u6700\u521d\u306e\u30d5\u30ec\u30fc\u30e0\u306e\u3068\u304d\u3060\u3051builtin\u95a2\u6570\u306b\u983c\u3063\u305f\u5f8c\u306f\u30ec\u30b8\u30b9\u30bf\u306e\u5024\u3092\u5fa9\u5143\u3057\u306a\u304c\u3089\u5dfb\u304d\u623b\u3057\u3066\u3044\u304f\u306e\u3067\u305d\u3046\u3044\u3046\u3053\u3068\u3082\u3067\u304d\u3066\u5f53\u7136\u3001\u304f\u3089\u3044\u306b\u601d\u3063\u3066\u3044\u305f\u306e\u3060\u304c\u3001\u8abf\u3079\u3066\u307f\u305f\u3089\u304b\u306a\u308atricky\u3060\u3068\u3044\u3046\u3053\u3068\u304c\u5224\u660e\u3057\u305f: (\u5c11\u306a\u304f\u3068\u3082FreeBSD\/i386\u306e\u5834\u5408)\u30d5\u30ec\u30fc\u30e0\u30dd\u30a4\u30f3\u30bf\u306a\u3057\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u3001gcc\u306f\u5404\u30d5\u30ec\u30fc\u30e0\u306b\u304a\u3051\u308b\u30b9\u30bf\u30c3\u30af\u306e\u4f38\u7e2e\u72b6\u6cc1\u3092\u7d30\u304b\u304f\u8a18\u9332\u3059\u308bFDE\u3092\u4f5c\u308b\u3002_Unwind_Backtrace()\u3067\u5dfb\u304d\u623b\u3059\u3068\u304d\u306f\u3001\u30ec\u30b8\u30b9\u30bf\u306e\u72b6\u6cc1\u306b\u306f\u307b\u3068\u3093\u3069\u983c\u3089\u305a\u3001\u4e00\u3064\u524d\u306e\u30d5\u30ec\u30fc\u30e0\u306b\u304a\u3051\u308b\u30b9\u30bf\u30c3\u30af\u306e\u958b\u59cb\u4f4d\u7f6e\u304b\u3089\u3001FDE\u306b\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\u73fe\u5728\u306e\u30d5\u30ec\u30fc\u30e0\u306e\u30b9\u30bf\u30c3\u30af\u306e\u30b5\u30a4\u30ba\u5206\u3092\u5dee\u3057\u5f15\u3044\u3066\u3001\u76f4\u63a5\u73fe\u5728\u30d5\u30ec\u30fc\u30e0\u306e\u30b9\u30bf\u30c3\u30af\u306e\u4f4d\u7f6e\u3092\u8a08\u7b97\u3057\u3066\u3044\u308b\u3002 \u5358\u306b_Unwind_Backtrace()\u3092\u4f7f\u3046\u3060\u3051\u306a\u3089\u3001\u3053\u3093\u306a\u3053\u3068\u307e\u3067\u77e5\u3063\u3066\u308b\u5fc5\u8981\u306f\u307e\u3063\u305f\u304f\u306a\u3044\u306e\u3060\u304c\u3001\u305b\u3063\u304b\u304f\u6642\u9593\u3092\u304b\u3051\u3066\u8abf\u3079\u305f\u306e\u3067\u3053\u308c\u3082\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u3066\u304a\u304f\u3053\u3068\u306b\u3059\u308b\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1602","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/posts\/1602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/comments?post=1602"}],"version-history":[{"count":13,"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/posts\/1602\/revisions"}],"predecessor-version":[{"id":1616,"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/posts\/1602\/revisions\/1616"}],"wp:attachment":[{"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/media?parent=1602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/categories?post=1602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jinmei.org\/blog\/wp-json\/wp\/v2\/tags?post=1602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}