Commit 668a0466 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #1500 from take-cheeze/debug_info_file_updating

Fix insufficient preparation to call mrb_debug_info_append_file.
parents 385e5d6e af73a740
......@@ -1111,12 +1111,14 @@ static void
codegen(codegen_scope *s, node *tree, int val)
{
int nt;
mrb_irep_debug_info_file const *finished_file;
if (!tree) return;
if (s->irep && s->pc > 0 && s->filename_index != tree->filename) {
s->irep->filename = s->filename = mrb_parser_get_filename(s->parser, s->filename_index);
mrb_debug_info_append_file(s->mrb, s->irep, s->debug_start_pos, s->pc);
s->irep->filename = mrb_parser_get_filename(s->parser, s->filename_index);
finished_file = mrb_debug_info_append_file(s->mrb, s->irep, s->debug_start_pos, s->pc);
mrb_assert(finished_file);
s->debug_start_pos = s->pc;
s->filename_index = tree->filename;
s->filename = mrb_parser_get_filename(s->parser, tree->filename);
......@@ -2434,6 +2436,7 @@ scope_finish(codegen_scope *s)
mrb_irep *irep = s->irep;
size_t fname_len;
char *fname;
mrb_irep_debug_info_file const *finished_file;
irep->flags = 0;
if (s->iseq) {
......@@ -2449,7 +2452,9 @@ scope_finish(codegen_scope *s)
irep->pool = (mrb_value *)codegen_realloc(s, irep->pool, sizeof(mrb_value)*irep->plen);
irep->syms = (mrb_sym *)codegen_realloc(s, irep->syms, sizeof(mrb_sym)*irep->slen);
if (s->filename) {
mrb_debug_info_append_file(mrb, s->irep, s->debug_start_pos, s->pc);
s->irep->filename = mrb_parser_get_filename(s->parser, s->filename_index);
finished_file = mrb_debug_info_append_file(mrb, s->irep, s->debug_start_pos, s->pc);
mrb_assert(finished_file);
fname_len = strlen(s->filename);
fname = codegen_malloc(s, fname_len + 1);
......
......@@ -73,8 +73,8 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)
else if ((f = get_file(irep->debug_info, pc))) {
switch(f->line_type) {
case mrb_debug_line_ary:
mrb_assert(pc < (f->start_pos + f->line_entry_count));
return f->line_ary[pc];
mrb_assert(f->start_pos <= pc && pc < (f->start_pos + f->line_entry_count));
return f->line_ary[pc - f->start_pos];
case mrb_debug_line_flat_map: {
// get upper bound
......
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