Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

Location:
EcnlProtoTool/trunk/mruby-1.3.0
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c

    r321 r331  
    55
    66#include <string.h>
    7 #include "mruby.h"
    8 #include "mruby/irep.h"
     7#include <mruby.h>
     8#include <mruby/irep.h>
    99#include "mrdb.h"
    10 #include "mruby/debug.h"
    11 #include "mruby/opcode.h"
    12 #include "mruby/class.h"
    13 #include "mruby/proc.h"
    14 #include "mruby/variable.h"
     10#include <mruby/debug.h>
     11#include <mruby/opcode.h>
     12#include <mruby/class.h>
     13#include <mruby/proc.h>
     14#include <mruby/variable.h>
    1515#include "mrdberror.h"
    1616#include "apibreak.h"
     
    2121
    2222static uint16_t
    23 check_lineno( mrb_irep_debug_info_file *info_file, uint16_t lineno )
     23check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
    2424{
    2525  uint32_t count = info_file->line_entry_count;
    2626  uint16_t l_idx;
    2727
    28   if( info_file->line_type == mrb_debug_line_ary ) {
     28  if (info_file->line_type == mrb_debug_line_ary) {
    2929    for (l_idx = 0; l_idx < count; ++l_idx) {
    30       if(lineno == info_file->lines.ary[l_idx]) {
     30      if (lineno == info_file->lines.ary[l_idx]) {
    3131        return lineno;
    3232      }
    3333    }
    34   } else {
     34  }
     35  else {
    3536    for (l_idx = 0; l_idx < count; ++l_idx) {
    36       if(lineno == info_file->lines.flat_map[l_idx].line) {
     37      if (lineno == info_file->lines.flat_map[l_idx].line) {
    3738        return lineno;
    3839      }
     
    4445
    4546static int32_t
    46 get_break_index( mrb_debug_context *dbg, int32_t bpno )
     47get_break_index(mrb_debug_context *dbg, uint32_t bpno)
    4748{
    4849  uint32_t i;
     
    5152
    5253  for(i = 0 ; i < dbg->bpnum; i++) {
    53     if(dbg->bp[i].bpno == bpno) {
     54    if (dbg->bp[i].bpno == bpno) {
    5455      hit = TRUE;
    5556      index = i;
     
    5859  }
    5960
    60   if(hit == FALSE) {
     61  if (hit == FALSE) {
    6162    return MRB_DEBUG_BREAK_INVALID_NO;
    6263  }
     
    6667
    6768static void
    68 free_breakpoint( mrb_state *mrb, mrb_debug_breakpoint *bp )
     69free_breakpoint(mrb_state *mrb, mrb_debug_breakpoint *bp)
    6970{
    7071  switch(bp->type) {
     
    7475    case MRB_DEBUG_BPTYPE_METHOD:
    7576      mrb_free(mrb, (void*)bp->point.methodpoint.method_name);
    76       if(bp->point.methodpoint.class_name != NULL) {
     77      if (bp->point.methodpoint.class_name != NULL) {
    7778        mrb_free(mrb, (void*)bp->point.methodpoint.class_name);
    7879      }
     
    8485
    8586static uint16_t
    86 check_file_lineno( struct mrb_irep *irep, const char *file, uint16_t lineno )
     87check_file_lineno(struct mrb_irep *irep, const char *file, uint16_t lineno)
    8788{
    8889  mrb_irep_debug_info_file *info_file;
     
    9495  for (f_idx = 0; f_idx < irep->debug_info->flen; ++f_idx) {
    9596    info_file = irep->debug_info->files[f_idx];
    96     if(!strcmp(info_file->filename, file)) {
     97    if (!strcmp(info_file->filename, file)) {
    9798      result = MRB_DEBUG_BP_FILE_OK;
    9899
    99       fix_lineno = check_lineno( info_file, lineno );
    100       if(fix_lineno != 0) {
     100      fix_lineno = check_lineno(info_file, lineno);
     101      if (fix_lineno != 0) {
    101102        return result | MRB_DEBUG_BP_LINENO_OK;
    102103      }
    103104    }
    104     for ( i=0; i < irep->rlen; ++i ) {
     105    for (i=0; i < irep->rlen; ++i) {
    105106      result  |= check_file_lineno(irep->reps[i], file, lineno);
    106       if(result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
     107      if (result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
    107108        return result;
    108109      }
     
    113114
    114115static const char*
    115 get_class_name( mrb_state *mrb, struct RClass *class_obj )
     116get_class_name(mrb_state *mrb, struct RClass *class_obj)
    116117{
    117118  struct RClass *outer;
     
    124125
    125126static int32_t
    126 compare_break_method( mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc )
     127compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
    127128{
    128129  const char* class_name;
     
    138139
    139140  method_p = &bp->point.methodpoint;
    140   if(strcmp(method_p->method_name, method_name) == 0) {
     141  if (strcmp(method_p->method_name, method_name) == 0) {
    141142    class_name = get_class_name(mrb, class_obj);
    142     if(class_name == NULL) {
    143       if(method_p->class_name == NULL) {
     143    if (class_name == NULL) {
     144      if (method_p->class_name == NULL) {
    144145        return bp->bpno;
    145146      }
    146147    }
    147     else if(method_p->class_name != NULL) {
     148    else if (method_p->class_name != NULL) {
    148149      m = mrb_method_search_vm(mrb, &class_obj, method_sym);
    149       if(m == NULL) {
     150      if (m == NULL) {
    150151        return MRB_DEBUG_OK;
    151152      }
    152       if(MRB_PROC_CFUNC_P(m)) {
     153      if (MRB_PROC_CFUNC_P(m)) {
    153154        *isCfunc = TRUE;
    154155      }
    155156
    156157      is_defined = mrb_class_defined(mrb, method_p->class_name);
    157       if(is_defined == FALSE) {
     158      if (is_defined == FALSE) {
    158159        return MRB_DEBUG_OK;
    159160      }
     
    162163      ssym = mrb_symbol(mrb_check_intern_cstr(mrb, method_p->method_name));
    163164      m = mrb_method_search_vm(mrb, &sc, ssym);
    164       if(m == NULL) {
     165      if (m == NULL) {
    165166        return MRB_DEBUG_OK;
    166167      }
     
    168169      class_name = get_class_name(mrb, class_obj);
    169170      sn = get_class_name(mrb, sc);
    170       if(strcmp(sn, class_name) == 0) {
     171      if (strcmp(sn, class_name) == 0) {
    171172        return bp->bpno;
    172173      }
     
    177178
    178179int32_t
    179 mrb_debug_set_break_line( mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
     180mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
    180181{
    181182  int32_t index;
     
    183184  uint16_t result;
    184185
    185   if((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
    186     return MRB_DEBUG_INVALID_ARGUMENT;
    187   }
    188 
    189   if(dbg->bpnum >= MAX_BREAKPOINT) {
     186  if ((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
     187    return MRB_DEBUG_INVALID_ARGUMENT;
     188  }
     189
     190  if (dbg->bpnum >= MAX_BREAKPOINT) {
    190191    return MRB_DEBUG_BREAK_NUM_OVER;
    191192  }
    192193
    193   if(dbg->next_bpno > MAX_BREAKPOINTNO) {
     194  if (dbg->next_bpno > MAX_BREAKPOINTNO) {
    194195    return MRB_DEBUG_BREAK_NO_OVER;
    195196  }
    196197
    197198  /* file and lineno check (line type mrb_debug_line_ary only.) */
    198   result = check_file_lineno( dbg->root_irep, file, lineno );
    199   if(result == 0) {
     199  result = check_file_lineno(dbg->root_irep, file, lineno);
     200  if (result == 0) {
    200201    return MRB_DEBUG_BREAK_INVALID_FILE;
    201   }else if(result == MRB_DEBUG_BP_FILE_OK) {
     202  }
     203  else if (result == MRB_DEBUG_BP_FILE_OK) {
    202204    return MRB_DEBUG_BREAK_INVALID_LINENO;
    203   } 
     205  }
    204206
    205207  set_file = mrb_malloc(mrb, strlen(file) + 1);
     
    221223
    222224int32_t
    223 mrb_debug_set_break_method( mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name )
     225mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name)
    224226{
    225227  int32_t index;
     
    227229  char* set_method;
    228230
    229   if((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
    230     return MRB_DEBUG_INVALID_ARGUMENT;
    231   }
    232 
    233   if(dbg->bpnum >= MAX_BREAKPOINT) {
     231  if ((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
     232    return MRB_DEBUG_INVALID_ARGUMENT;
     233  }
     234
     235  if (dbg->bpnum >= MAX_BREAKPOINT) {
    234236    return MRB_DEBUG_BREAK_NUM_OVER;
    235237  }
    236238
    237   if(dbg->next_bpno > MAX_BREAKPOINTNO) {
     239  if (dbg->next_bpno > MAX_BREAKPOINTNO) {
    238240    return MRB_DEBUG_BREAK_NO_OVER;
    239241  }
    240242
    241   if(class_name != NULL) {
     243  if (class_name != NULL) {
    242244    set_class = mrb_malloc(mrb, strlen(class_name) + 1);
    243245    strncpy(set_class, class_name, strlen(class_name) + 1);
     
    264266
    265267int32_t
    266 mrb_debug_get_breaknum( mrb_state *mrb, mrb_debug_context *dbg )
    267 {
    268   if((mrb == NULL) || (dbg == NULL)) {
     268mrb_debug_get_breaknum(mrb_state *mrb, mrb_debug_context *dbg)
     269{
     270  if ((mrb == NULL) || (dbg == NULL)) {
    269271    return MRB_DEBUG_INVALID_ARGUMENT;
    270272  }
     
    273275}
    274276
    275 int32_t 
    276 mrb_debug_get_break_all( mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp )
     277int32_t
     278mrb_debug_get_break_all(mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp)
    277279{
    278280  uint32_t get_size = 0;
    279281
    280   if((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
    281     return MRB_DEBUG_INVALID_ARGUMENT;
    282   }
    283 
    284   if(dbg->bpnum >= size) {
     282  if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
     283    return MRB_DEBUG_INVALID_ARGUMENT;
     284  }
     285
     286  if (dbg->bpnum >= size) {
    285287    get_size = size;
    286288  }
     
    295297
    296298int32_t
    297 mrb_debug_get_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp )
    298 {
    299   uint32_t index;
    300 
    301   if((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
     299mrb_debug_get_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp)
     300{
     301  int32_t index;
     302
     303  if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
    302304    return MRB_DEBUG_INVALID_ARGUMENT;
    303305  }
    304306
    305307  index = get_break_index(dbg, bpno);
    306   if(index == MRB_DEBUG_BREAK_INVALID_NO) {
     308  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
    307309    return MRB_DEBUG_BREAK_INVALID_NO;
    308310  }
     
    316318}
    317319
    318 int32_t 
    319 mrb_debug_delete_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
     320int32_t
     321mrb_debug_delete_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
    320322{
    321323  uint32_t i;
    322324  int32_t index;
    323325
    324   if((mrb == NULL) ||(dbg == NULL)) {
     326  if ((mrb == NULL) ||(dbg == NULL)) {
    325327    return MRB_DEBUG_INVALID_ARGUMENT;
    326328  }
    327329
    328330  index = get_break_index(dbg, bpno);
    329   if(index == MRB_DEBUG_BREAK_INVALID_NO) {
     331  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
    330332    return MRB_DEBUG_BREAK_INVALID_NO;
    331333  }
     
    334336
    335337  for(i = index ; i < dbg->bpnum; i++) {
    336     if((i + 1) == dbg->bpnum) {
     338    if ((i + 1) == dbg->bpnum) {
    337339      memset(&dbg->bp[i], 0, sizeof(mrb_debug_breakpoint));
    338340    }
     
    347349}
    348350
    349 int32_t 
    350 mrb_debug_delete_break_all( mrb_state *mrb, mrb_debug_context *dbg )
    351 {
    352   uint32_t i;
    353 
    354   if((mrb == NULL) || (dbg == NULL)) {
     351int32_t
     352mrb_debug_delete_break_all(mrb_state *mrb, mrb_debug_context *dbg)
     353{
     354  uint32_t i;
     355
     356  if ((mrb == NULL) || (dbg == NULL)) {
    355357    return MRB_DEBUG_INVALID_ARGUMENT;
    356358  }
     
    365367}
    366368
    367 int32_t 
    368 mrb_debug_enable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
     369int32_t
     370mrb_debug_enable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
    369371{
    370372  int32_t index = 0;
    371373
    372   if((mrb == NULL) || (dbg == NULL)) {
     374  if ((mrb == NULL) || (dbg == NULL)) {
    373375    return MRB_DEBUG_INVALID_ARGUMENT;
    374376  }
    375377
    376378  index = get_break_index(dbg, bpno);
    377   if(index == MRB_DEBUG_BREAK_INVALID_NO) {
     379  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
    378380    return MRB_DEBUG_BREAK_INVALID_NO;
    379381  }
     
    385387
    386388int32_t
    387 mrb_debug_enable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
    388 {
    389   uint32_t i;
    390 
    391   if((mrb == NULL) || (dbg == NULL)) {
     389mrb_debug_enable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
     390{
     391  uint32_t i;
     392
     393  if ((mrb == NULL) || (dbg == NULL)) {
    392394    return MRB_DEBUG_INVALID_ARGUMENT;
    393395  }
     
    400402}
    401403
    402 int32_t 
    403 mrb_debug_disable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno )
     404int32_t
     405mrb_debug_disable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
    404406{
    405407  int32_t index = 0;
    406408
    407   if((mrb == NULL) || (dbg == NULL)) {
     409  if ((mrb == NULL) || (dbg == NULL)) {
    408410    return MRB_DEBUG_INVALID_ARGUMENT;
    409411  }
    410412
    411413  index = get_break_index(dbg, bpno);
    412   if(index == MRB_DEBUG_BREAK_INVALID_NO) {
     414  if (index == MRB_DEBUG_BREAK_INVALID_NO) {
    413415    return MRB_DEBUG_BREAK_INVALID_NO;
    414416  }
     
    419421}
    420422
    421 int32_t 
    422 mrb_debug_disable_break_all( mrb_state *mrb, mrb_debug_context *dbg )
    423 {
    424   uint32_t i;
    425 
    426   if((mrb == NULL) || (dbg == NULL)) {
     423int32_t
     424mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
     425{
     426  uint32_t i;
     427
     428  if ((mrb == NULL) || (dbg == NULL)) {
    427429    return MRB_DEBUG_INVALID_ARGUMENT;
    428430  }
     
    436438
    437439static mrb_bool
    438 check_start_pc_for_line( mrb_irep *irep, mrb_code *pc, uint16_t line )
    439 {
    440   if( pc > irep->iseq ) {
    441     if( line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
     440check_start_pc_for_line(mrb_irep *irep, mrb_code *pc, uint16_t line)
     441{
     442  if (pc > irep->iseq) {
     443    if (line == mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq - 1))) {
    442444      return FALSE;
    443445    }
     
    447449
    448450int32_t
    449 mrb_debug_check_breakpoint_line( mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line )
     451mrb_debug_check_breakpoint_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line)
    450452{
    451453  mrb_debug_breakpoint *bp;
    452454  mrb_debug_linepoint *line_p;
    453   int i;
    454 
    455   if((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
    456     return MRB_DEBUG_INVALID_ARGUMENT;
    457   }
    458 
    459   if(!check_start_pc_for_line(dbg->irep, dbg->pc, line)) {
     455  uint32_t i;
     456
     457  if ((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
     458    return MRB_DEBUG_INVALID_ARGUMENT;
     459  }
     460
     461  if (!check_start_pc_for_line(dbg->irep, dbg->pc, line)) {
    460462    return MRB_DEBUG_OK;
    461463  }
     
    465467    switch (bp->type) {
    466468      case MRB_DEBUG_BPTYPE_LINE:
    467         if(bp->enable == TRUE) {
     469        if (bp->enable == TRUE) {
    468470          line_p = &bp->point.linepoint;
    469           if((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
     471          if ((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
    470472            return bp->bpno;
    471473          }
     
    484486
    485487
    486 int32_t 
    487 mrb_debug_check_breakpoint_method( mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc )
     488int32_t
     489mrb_debug_check_breakpoint_method(mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
    488490{
    489491  mrb_debug_breakpoint *bp;
    490492  int32_t bpno;
    491   int i;
    492 
    493   if((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
     493  uint32_t i;
     494
     495  if ((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
    494496    return MRB_DEBUG_INVALID_ARGUMENT;
    495497  }
     
    497499  bp = dbg->bp;
    498500  for(i=0; i<dbg->bpnum; i++) {
    499     if(bp->type == MRB_DEBUG_BPTYPE_METHOD) {
    500       if(bp->enable == TRUE) {
     501    if (bp->type == MRB_DEBUG_BPTYPE_METHOD) {
     502      if (bp->enable == TRUE) {
    501503        bpno = compare_break_method(mrb, bp, class_obj, method_sym, isCfunc);
    502         if(bpno > 0) {
     504        if (bpno > 0) {
    503505          return bpno;
    504506        }
    505507      }
    506508    }
    507     else if(bp->type == MRB_DEBUG_BPTYPE_NONE) {
     509    else if (bp->type == MRB_DEBUG_BPTYPE_NONE) {
    508510      break;
    509511    }
Note: See TracChangeset for help on using the changeset viewer.