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
868ba846
Unverified
Commit
868ba846
authored
Dec 19, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Dec 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4882 from shuujii/simplify-print_backtrace
Simplify `print_backtrace()`
parents
429f6def
6df6bd4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
22 deletions
+12
-22
src/backtrace.c
src/backtrace.c
+7
-17
src/error.c
src/error.c
+5
-5
No files found.
src/backtrace.c
View file @
868ba846
...
...
@@ -25,8 +25,7 @@ typedef void (*each_backtrace_func)(mrb_state*, const struct backtrace_location*
static
const
mrb_data_type
bt_type
=
{
"Backtrace"
,
mrb_free
};
mrb_value
mrb_exc_to_s
(
mrb_state
*
mrb
,
mrb_value
exc
);
mrb_value
mrb_mod_to_s
(
mrb_state
*
mrb
,
mrb_value
klass
);
mrb_value
mrb_exc_inspect
(
mrb_state
*
mrb
,
mrb_value
exc
);
mrb_value
mrb_unpack_backtrace
(
mrb_state
*
mrb
,
mrb_value
backtrace
);
static
void
...
...
@@ -82,7 +81,7 @@ print_backtrace(mrb_state *mrb, struct RObject *exc, mrb_value backtrace)
{
int
i
;
mrb_int
n
=
RARRAY_LEN
(
backtrace
);
mrb_value
*
loc
,
mesg
,
cname
;
mrb_value
*
loc
,
mesg
;
FILE
*
stream
=
stderr
;
if
(
n
!=
0
)
{
...
...
@@ -93,21 +92,12 @@ print_backtrace(mrb_state *mrb, struct RObject *exc, mrb_value backtrace)
i
,
(
int
)
RSTRING_LEN
(
*
loc
),
RSTRING_PTR
(
*
loc
));
}
}
if
(
mrb_string_p
(
*
loc
))
{
fprintf
(
stream
,
"%.*s: "
,
(
int
)
RSTRING_LEN
(
*
loc
),
RSTRING_PTR
(
*
loc
));
}
}
if
(
n
!=
0
)
{
fprintf
(
stream
,
"%.*s: "
,
(
int
)
RSTRING_LEN
(
*
loc
),
RSTRING_PTR
(
*
loc
));
}
mesg
=
mrb_exc_to_s
(
mrb
,
mrb_obj_value
(
exc
));
cname
=
mrb_mod_to_s
(
mrb
,
mrb_obj_value
(
exc
->
c
));
if
(
RSTRING_LEN
(
mesg
)
==
0
)
{
fprintf
(
stream
,
"%.*s
\n
"
,
(
int
)
RSTRING_LEN
(
cname
),
RSTRING_PTR
(
cname
));
}
else
{
fprintf
(
stream
,
"%.*s (%.*s)
\n
"
,
(
int
)
RSTRING_LEN
(
mesg
),
RSTRING_PTR
(
mesg
),
(
int
)
RSTRING_LEN
(
cname
),
RSTRING_PTR
(
cname
));
}
mesg
=
mrb_exc_inspect
(
mrb
,
mrb_obj_value
(
exc
));
fprintf
(
stream
,
"%.*s
\n
"
,
(
int
)
RSTRING_LEN
(
mesg
),
RSTRING_PTR
(
mesg
));
}
/* mrb_print_backtrace
...
...
src/error.c
View file @
868ba846
...
...
@@ -88,7 +88,7 @@ exc_exception(mrb_state *mrb, mrb_value self)
*/
mrb_value
mrb_
exc_to_s
(
mrb_state
*
mrb
,
mrb_value
exc
)
exc_to_s
(
mrb_state
*
mrb
,
mrb_value
exc
)
{
mrb_value
mesg
=
mrb_attr_get
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"mesg"
));
struct
RObject
*
p
;
...
...
@@ -127,8 +127,8 @@ exc_message(mrb_state *mrb, mrb_value exc)
* returns message and class name.
*/
static
mrb_value
exc_inspect
(
mrb_state
*
mrb
,
mrb_value
exc
)
mrb_value
mrb_
exc_inspect
(
mrb_state
*
mrb
,
mrb_value
exc
)
{
mrb_value
mesg
=
mrb_attr_get
(
mrb
,
exc
,
mrb_intern_lit
(
mrb
,
"mesg"
));
mrb_value
cname
=
mrb_mod_to_s
(
mrb
,
mrb_obj_value
(
mrb_obj_class
(
mrb
,
exc
)));
...
...
@@ -543,9 +543,9 @@ mrb_init_exception(mrb_state *mrb)
mrb_define_class_method
(
mrb
,
exception
,
"exception"
,
mrb_instance_new
,
MRB_ARGS_OPT
(
1
));
mrb_define_method
(
mrb
,
exception
,
"exception"
,
exc_exception
,
MRB_ARGS_OPT
(
1
));
mrb_define_method
(
mrb
,
exception
,
"initialize"
,
exc_initialize
,
MRB_ARGS_OPT
(
1
));
mrb_define_method
(
mrb
,
exception
,
"to_s"
,
mrb_exc_to_s
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
exception
,
"to_s"
,
exc_to_s
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
exception
,
"message"
,
exc_message
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
exception
,
"inspect"
,
exc_inspect
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
exception
,
"inspect"
,
mrb_exc_inspect
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
exception
,
"backtrace"
,
mrb_exc_backtrace
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
exception
,
"set_backtrace"
,
exc_set_backtrace
,
MRB_ARGS_REQ
(
1
));
...
...
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