Skip to content

Commit 142f303

Browse files
committed
basic_stacktrace : GCCで動作確認
1 parent ba9a494 commit 142f303

24 files changed

+185
-110
lines changed

reference/stacktrace/basic_stacktrace.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,15 @@ int main() {
173173
```
174174
* current()[link basic_stacktrace/current.md]
175175

176-
#### 出力例
176+
#### 出力例 (GCC)
177177
```
178-
0# g() at main.cpp:5
179-
1# f() at main.cpp:9
180-
2# main at main.cpp:13
178+
0# g() at /app/example.cpp:5
179+
1# f() at /app/example.cpp:10
180+
2# main at /app/example.cpp:14
181+
3# at :0
182+
4# __libc_start_main at :0
183+
5# _start at :0
184+
6#
181185
```
182186

183187
### スタックトレースを出力するアサーションマクロを作る
@@ -208,9 +212,9 @@ int main() {
208212
* std::abort()[link /reference/cstdlib/abort.md]
209213
* std::cerr[link /reference/iostream/cerr.md]
210214
211-
#### 出力例
215+
#### 出力例 (GCC)
212216
```
213-
Expression 'i >= 0' is false in f() at main.cpp:15
217+
Expression 'i >= 0' is false in f(int) at /app/example.cpp:15
214218
```
215219
216220
## バージョン
@@ -219,5 +223,12 @@ Expression 'i >= 0' is false in f() at main.cpp:15
219223
220224
### 処理系
221225
- [Clang](/implementation.md#clang): ??
222-
- [GCC](/implementation.md#gcc): ??
226+
- [GCC](/implementation.md#gcc): 12
223227
- [Visual C++](/implementation.md#visual_cpp): ??
228+
229+
230+
### 備考
231+
- GCCでは、以下のコンパイルオプションを追加で指定する必要がある:
232+
- 13まで : `-lstdc++_libbacktrace`
233+
- 14以降 : `-lstdc++exp`
234+

reference/stacktrace/basic_stacktrace/at.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ int main() {
4242
* st.at[color ff0000]
4343
* current()[link current.md]
4444

45-
### 出力例
45+
### 出力例 (GCC)
4646
```
47-
g() at main.cpp:5
47+
g() at /app/example.cpp:5
4848
```
4949

5050

@@ -54,5 +54,5 @@ g() at main.cpp:5
5454

5555
### 処理系
5656
- [Clang](/implementation.md#clang): ??
57-
- [GCC](/implementation.md#gcc): ??
57+
- [GCC](/implementation.md#gcc): 12
5858
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/begin.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void g() {
2727
std::stacktrace st = std::stacktrace::current();
2828
std::for_each(st.begin(), st.end(), [](const std::stacktrace_entry& x) {
2929
std::cout << x << std::endl;
30-
}):
30+
});
3131
}
3232

3333
void f() {
@@ -43,11 +43,15 @@ int main() {
4343
* current()[link current.md]
4444
* std::stacktrace_entry[link /reference/stacktrace/stacktrace_entry.md]
4545

46-
### 出力
46+
### 出力例 (GCC)
4747
```
48-
g() at main.cpp:6
49-
f() at main.cpp:13
50-
main at main.cpp:17
48+
g() at /app/example.cpp:6
49+
f() at /app/example.cpp:13
50+
main at /app/example.cpp:17
51+
at :0
52+
__libc_start_main at :0
53+
_start at :0
54+
5155
```
5256

5357

@@ -57,5 +61,5 @@ main at main.cpp:17
5761

5862
### 処理系
5963
- [Clang](/implementation.md#clang): ??
60-
- [GCC](/implementation.md#gcc): ??
64+
- [GCC](/implementation.md#gcc): 12
6165
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/cbegin.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void g() {
2727
std::stacktrace st = std::stacktrace::current();
2828
std::for_each(st.cbegin(), st.cend(), [](const std::stacktrace_entry& x) {
2929
std::cout << x << std::endl;
30-
}):
30+
});
3131
}
3232

3333
void f() {
@@ -43,11 +43,15 @@ int main() {
4343
* current()[link current.md]
4444
* std::stacktrace_entry[link /reference/stacktrace/stacktrace_entry.md]
4545

46-
### 出力
46+
### 出力例 (GCC)
4747
```
48-
g() at main.cpp:6
49-
f() at main.cpp:13
50-
main at main.cpp:17
48+
g() at /app/example.cpp:6
49+
f() at /app/example.cpp:13
50+
main at /app/example.cpp:17
51+
at :0
52+
__libc_start_main at :0
53+
_start at :0
54+
5155
```
5256

5357

@@ -57,5 +61,5 @@ main at main.cpp:17
5761

5862
### 処理系
5963
- [Clang](/implementation.md#clang): ??
60-
- [GCC](/implementation.md#gcc): ??
64+
- [GCC](/implementation.md#gcc): 12
6165
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/cend.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void g() {
2727
std::stacktrace st = std::stacktrace::current();
2828
std::for_each(st.cbegin(), st.cend(), [](const std::stacktrace_entry& x) {
2929
std::cout << x << std::endl;
30-
}):
30+
});
3131
}
3232

3333
void f() {
@@ -43,11 +43,15 @@ int main() {
4343
* current()[link current.md]
4444
* std::stacktrace_entry[link /reference/stacktrace/stacktrace_entry.md]
4545

46-
### 出力
46+
### 出力例 (GCC)
4747
```
48-
g() at main.cpp:6
49-
f() at main.cpp:13
50-
main at main.cpp:17
48+
g() at /app/example.cpp:6
49+
f() at /app/example.cpp:13
50+
main at /app/example.cpp:17
51+
at :0
52+
__libc_start_main at :0
53+
_start at :0
54+
5155
```
5256

5357

@@ -57,5 +61,5 @@ main at main.cpp:17
5761

5862
### 処理系
5963
- [Clang](/implementation.md#clang): ??
60-
- [GCC](/implementation.md#gcc): ??
64+
- [GCC](/implementation.md#gcc): 12
6165
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/crbegin.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void g() {
3030
std::stacktrace st = std::stacktrace::current();
3131
std::for_each(st.crbegin(), st.crend(), [](const std::stacktrace_entry& x) {
3232
std::cout << x << std::endl;
33-
}):
33+
});
3434
}
3535

3636
void f() {
@@ -46,11 +46,15 @@ int main() {
4646
* current()[link current.md]
4747
* std::stacktrace_entry[link /reference/stacktrace/stacktrace_entry.md]
4848

49-
### 出力
49+
### 出力例 (GCC)
5050
```
51-
main at main.cpp:17
52-
f() at main.cpp:13
53-
g() at main.cpp:6
51+
52+
_start at :0
53+
__libc_start_main at :0
54+
at :0
55+
main at /app/example.cpp:17
56+
f() at /app/example.cpp:13
57+
g() at /app/example.cpp:6
5458
```
5559

5660

@@ -60,5 +64,5 @@ g() at main.cpp:6
6064

6165
### 処理系
6266
- [Clang](/implementation.md#clang): ??
63-
- [GCC](/implementation.md#gcc): ??
67+
- [GCC](/implementation.md#gcc): 12
6468
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/crend.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void g() {
3030
std::stacktrace st = std::stacktrace::current();
3131
std::for_each(st.crbegin(), st.crend(), [](const std::stacktrace_entry& x) {
3232
std::cout << x << std::endl;
33-
}):
33+
});
3434
}
3535

3636
void f() {
@@ -46,11 +46,15 @@ int main() {
4646
* current()[link current.md]
4747
* std::stacktrace_entry[link /reference/stacktrace/stacktrace_entry.md]
4848

49-
### 出力
49+
### 出力例 (GCC)
5050
```
51-
main at main.cpp:17
52-
f() at main.cpp:13
53-
g() at main.cpp:6
51+
52+
_start at :0
53+
__libc_start_main at :0
54+
at :0
55+
main at /app/example.cpp:17
56+
f() at /app/example.cpp:13
57+
g() at /app/example.cpp:6
5458
```
5559

5660

@@ -60,5 +64,5 @@ g() at main.cpp:6
6064

6165
### 処理系
6266
- [Clang](/implementation.md#clang): ??
63-
- [GCC](/implementation.md#gcc): ??
67+
- [GCC](/implementation.md#gcc): 12
6468
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/current.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ int main() {
6767
```
6868
* current()[color ff0000]
6969

70-
#### 出力例
70+
#### 出力例 (GCC)
7171
```
72-
0# g() at main.cpp:5
73-
1# f() at main.cpp:9
74-
2# main at main.cpp:13
72+
0# g() at /app/example.cpp:5
73+
1# f() at /app/example.cpp:9
74+
2# main at /app/example.cpp:13
75+
3# at :0
76+
4# __libc_start_main at :0
77+
5# _start at :0
78+
6#
7579
```
7680

7781
### 現在位置からN個を除いたスタックトレースを取得する
@@ -93,10 +97,14 @@ int main() {
9397
```
9498
* current[color ff0000]
9599

96-
#### 出力例
100+
#### 出力例 (GCC)
97101
```
98-
0# f() at main.cpp:9
99-
1# main at main.cpp:13
102+
0# f() at /app/example.cpp:9
103+
1# main at /app/example.cpp:13
104+
2# at :0
105+
3# __libc_start_main at :0
106+
4# _start at :0
107+
5#
100108
```
101109

102110
### 指定範囲のスタックトレースを取得する
@@ -118,10 +126,10 @@ int main() {
118126
```
119127
* current[color ff0000]
120128

121-
#### 出力例
129+
#### 出力例 (GCC)
122130
```
123-
0# f() at main.cpp:9
124-
1# main at main.cpp:13
131+
0# f() at /app/example.cpp:9
132+
1# main at /app/example.cpp:13
125133
```
126134

127135

@@ -131,5 +139,5 @@ int main() {
131139

132140
### 処理系
133141
- [Clang](/implementation.md#clang): ??
134-
- [GCC](/implementation.md#gcc): ??
142+
- [GCC](/implementation.md#gcc): 12
135143
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/empty.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ int main() {
5252

5353
### 処理系
5454
- [Clang](/implementation.md#clang): ??
55-
- [GCC](/implementation.md#gcc): ??
55+
- [GCC](/implementation.md#gcc): 12
5656
- [Visual C++](/implementation.md#visual_cpp): ??

reference/stacktrace/basic_stacktrace/end.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void g() {
2727
std::stacktrace st = std::stacktrace::current();
2828
std::for_each(st.begin(), st.end(), [](const std::stacktrace_entry& x) {
2929
std::cout << x << std::endl;
30-
}):
30+
});
3131
}
3232

3333
void f() {
@@ -43,11 +43,15 @@ int main() {
4343
* current()[link current.md]
4444
* std::stacktrace_entry[link /reference/stacktrace/stacktrace_entry.md]
4545

46-
### 出力
46+
### 出力例 (GCC)
4747
```
48-
g() at main.cpp:6
49-
f() at main.cpp:13
50-
main at main.cpp:17
48+
g() at /app/example.cpp:6
49+
f() at /app/example.cpp:13
50+
main at /app/example.cpp:17
51+
at :0
52+
__libc_start_main at :0
53+
_start at :0
54+
5155
```
5256

5357

@@ -57,5 +61,5 @@ main at main.cpp:17
5761

5862
### 処理系
5963
- [Clang](/implementation.md#clang): ??
60-
- [GCC](/implementation.md#gcc): ??
64+
- [GCC](/implementation.md#gcc): 12
6165
- [Visual C++](/implementation.md#visual_cpp): ??

0 commit comments

Comments
 (0)