Commit aab52be1 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2156 from cremno/fix-disabled-stdio-2

fix disabled stdio
parents 5fb5c2a4 01b76630
......@@ -14,9 +14,10 @@
#include "mruby/debug.h"
#include "mruby/error.h"
#ifdef ENABLE_STDIO
typedef void (*output_stream_func)(mrb_state*, void*, int, const char*, ...);
#ifdef ENABLE_STDIO
static void
print_backtrace_i(mrb_state *mrb, void *stream, int level, const char *format, ...)
{
......@@ -26,7 +27,7 @@ print_backtrace_i(mrb_state *mrb, void *stream, int level, const char *format, .
vfprintf((FILE*)stream, format, ap);
va_end(ap);
}
#endif
#define MIN_BUFSIZE 127
......@@ -142,14 +143,12 @@ exc_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun
function to retrieve backtrace information from the exception.
note that if you call method after the exception, call stack will be
overwritten. So invoke these functions just after detecting exceptions.
*/
*/
void
mrb_print_backtrace(mrb_state *mrb)
{
#ifdef ENABLE_STDIO
exc_output_backtrace(mrb, mrb->exc, print_backtrace_i, (void*)stderr);
#endif
}
mrb_value
......@@ -177,3 +176,24 @@ mrb_get_backtrace(mrb_state *mrb)
return ary;
}
#else
void
mrb_print_backtrace(mrb_state *mrb)
{
}
mrb_value
mrb_exc_backtrace(mrb_state *mrb, mrb_value self)
{
return mrb_ary_new(mrb);
}
mrb_value
mrb_get_backtrace(mrb_state *mrb)
{
return mrb_ary_new(mrb);
}
#endif
......@@ -13,6 +13,8 @@
#include "mruby/numeric.h"
#include "mruby/debug.h"
#ifdef ENABLE_STDIO
static size_t get_irep_record_size_1(mrb_state *mrb, mrb_irep *irep);
#if UINT32_MAX > SIZE_MAX
......@@ -252,7 +254,7 @@ get_irep_record_size(mrb_state *mrb, mrb_irep *irep)
{
size_t size = 0;
size_t irep_no;
size = get_irep_record_size_1(mrb, irep);
for (irep_no = 0; irep_no < irep->rlen; irep_no++) {
size += get_irep_record_size(mrb, irep->reps[irep_no]);
......@@ -603,7 +605,7 @@ write_debug_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const*
{
size_t size, len;
size_t irep_no;
size = len = write_debug_record_1(mrb, irep, bin, filenames, filenames_len);
bin += len;
for (irep_no = 0; irep_no < irep->rlen; irep_no++) {
......@@ -802,9 +804,6 @@ error_exit:
return result;
}
#ifdef ENABLE_STDIO
int
mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, int debug_info, FILE* fp)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment