Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
96b12b98
Unverified
Commit
96b12b98
authored
Feb 25, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Feb 25, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4297 from shuujii/refactor-src-backtrace.c
Refactor `src/backtrace.c`
parents
ad87fd22
c49a10f9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
src/backtrace.c
src/backtrace.c
+10
-12
No files found.
src/backtrace.c
View file @
96b12b98
...
@@ -21,7 +21,7 @@ struct backtrace_location {
...
@@ -21,7 +21,7 @@ struct backtrace_location {
const
char
*
filename
;
const
char
*
filename
;
};
};
typedef
void
(
*
each_backtrace_func
)(
mrb_state
*
,
struct
backtrace_location
*
,
void
*
);
typedef
void
(
*
each_backtrace_func
)(
mrb_state
*
,
const
struct
backtrace_location
*
,
void
*
);
static
const
mrb_data_type
bt_type
=
{
"Backtrace"
,
mrb_free
};
static
const
mrb_data_type
bt_type
=
{
"Backtrace"
,
mrb_free
};
...
@@ -57,11 +57,11 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, mrb_code *pc0, each_backtrace_fu
...
@@ -57,11 +57,11 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, mrb_code *pc0, each_backtrace_fu
else
{
else
{
pc
=
pc0
;
pc
=
pc0
;
}
}
loc
.
filename
=
mrb_debug_get_filename
(
irep
,
pc
-
irep
->
iseq
);
loc
.
lineno
=
mrb_debug_get_line
(
irep
,
pc
-
irep
->
iseq
);
loc
.
lineno
=
mrb_debug_get_line
(
irep
,
pc
-
irep
->
iseq
);
if
(
loc
.
lineno
==
-
1
)
continue
;
if
(
loc
.
lineno
==
-
1
)
continue
;
loc
.
filename
=
mrb_debug_get_filename
(
irep
,
pc
-
irep
->
iseq
);
if
(
!
loc
.
filename
)
{
if
(
!
loc
.
filename
)
{
loc
.
filename
=
"(unknown)"
;
loc
.
filename
=
"(unknown)"
;
}
}
...
@@ -80,8 +80,6 @@ print_backtrace(mrb_state *mrb, mrb_value backtrace)
...
@@ -80,8 +80,6 @@ print_backtrace(mrb_state *mrb, mrb_value backtrace)
mrb_int
n
;
mrb_int
n
;
FILE
*
stream
=
stderr
;
FILE
*
stream
=
stderr
;
if
(
!
mrb_array_p
(
backtrace
))
return
;
n
=
RARRAY_LEN
(
backtrace
)
-
1
;
n
=
RARRAY_LEN
(
backtrace
)
-
1
;
if
(
n
==
0
)
return
;
if
(
n
==
0
)
return
;
...
@@ -96,7 +94,7 @@ print_backtrace(mrb_state *mrb, mrb_value backtrace)
...
@@ -96,7 +94,7 @@ print_backtrace(mrb_state *mrb, mrb_value backtrace)
}
}
static
int
static
int
packed_bt_len
(
struct
backtrace_location
*
bt
,
int
n
)
packed_bt_len
(
const
struct
backtrace_location
*
bt
,
int
n
)
{
{
int
len
=
0
;
int
len
=
0
;
int
i
;
int
i
;
...
@@ -113,7 +111,7 @@ static void
...
@@ -113,7 +111,7 @@ static void
print_packed_backtrace
(
mrb_state
*
mrb
,
mrb_value
packed
)
print_packed_backtrace
(
mrb_state
*
mrb
,
mrb_value
packed
)
{
{
FILE
*
stream
=
stderr
;
FILE
*
stream
=
stderr
;
struct
backtrace_location
*
bt
;
const
struct
backtrace_location
*
bt
;
int
n
,
i
;
int
n
,
i
;
int
ai
=
mrb_gc_arena_save
(
mrb
);
int
ai
=
mrb_gc_arena_save
(
mrb
);
...
@@ -124,7 +122,7 @@ print_packed_backtrace(mrb_state *mrb, mrb_value packed)
...
@@ -124,7 +122,7 @@ print_packed_backtrace(mrb_state *mrb, mrb_value packed)
if
(
packed_bt_len
(
bt
,
n
)
==
0
)
return
;
if
(
packed_bt_len
(
bt
,
n
)
==
0
)
return
;
fprintf
(
stream
,
"trace (most recent call last):
\n
"
);
fprintf
(
stream
,
"trace (most recent call last):
\n
"
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
struct
backtrace_location
*
entry
=
&
bt
[
n
-
i
-
1
];
const
struct
backtrace_location
*
entry
=
&
bt
[
n
-
i
-
1
];
if
(
entry
->
filename
==
NULL
)
continue
;
if
(
entry
->
filename
==
NULL
)
continue
;
fprintf
(
stream
,
"
\t
[%d] %s:%d"
,
i
,
entry
->
filename
,
entry
->
lineno
);
fprintf
(
stream
,
"
\t
[%d] %s:%d"
,
i
,
entry
->
filename
,
entry
->
lineno
);
if
(
entry
->
method_id
!=
0
)
{
if
(
entry
->
method_id
!=
0
)
{
...
@@ -172,7 +170,7 @@ mrb_print_backtrace(mrb_state *mrb)
...
@@ -172,7 +170,7 @@ mrb_print_backtrace(mrb_state *mrb)
static
void
static
void
count_backtrace_i
(
mrb_state
*
mrb
,
count_backtrace_i
(
mrb_state
*
mrb
,
struct
backtrace_location
*
loc
,
const
struct
backtrace_location
*
loc
,
void
*
data
)
void
*
data
)
{
{
int
*
lenp
=
(
int
*
)
data
;
int
*
lenp
=
(
int
*
)
data
;
...
@@ -183,7 +181,7 @@ count_backtrace_i(mrb_state *mrb,
...
@@ -183,7 +181,7 @@ count_backtrace_i(mrb_state *mrb,
static
void
static
void
pack_backtrace_i
(
mrb_state
*
mrb
,
pack_backtrace_i
(
mrb_state
*
mrb
,
struct
backtrace_location
*
loc
,
const
struct
backtrace_location
*
loc
,
void
*
data
)
void
*
data
)
{
{
struct
backtrace_location
**
pptr
=
(
struct
backtrace_location
**
)
data
;
struct
backtrace_location
**
pptr
=
(
struct
backtrace_location
**
)
data
;
...
@@ -229,7 +227,7 @@ mrb_keep_backtrace(mrb_state *mrb, mrb_value exc)
...
@@ -229,7 +227,7 @@ mrb_keep_backtrace(mrb_state *mrb, mrb_value exc)
mrb_value
mrb_value
mrb_unpack_backtrace
(
mrb_state
*
mrb
,
mrb_value
backtrace
)
mrb_unpack_backtrace
(
mrb_state
*
mrb
,
mrb_value
backtrace
)
{
{
struct
backtrace_location
*
bt
;
const
struct
backtrace_location
*
bt
;
mrb_int
n
,
i
;
mrb_int
n
,
i
;
int
ai
;
int
ai
;
...
@@ -244,7 +242,7 @@ mrb_unpack_backtrace(mrb_state *mrb, mrb_value backtrace)
...
@@ -244,7 +242,7 @@ mrb_unpack_backtrace(mrb_state *mrb, mrb_value backtrace)
backtrace
=
mrb_ary_new_capa
(
mrb
,
n
);
backtrace
=
mrb_ary_new_capa
(
mrb
,
n
);
ai
=
mrb_gc_arena_save
(
mrb
);
ai
=
mrb_gc_arena_save
(
mrb
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
struct
backtrace_location
*
entry
=
&
bt
[
i
];
const
struct
backtrace_location
*
entry
=
&
bt
[
i
];
mrb_value
btline
;
mrb_value
btline
;
if
(
entry
->
filename
==
NULL
)
continue
;
if
(
entry
->
filename
==
NULL
)
continue
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment