- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-1.3.0
- Files:
-
- 12 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
r321 r331 5 5 6 6 #include <string.h> 7 #include "mruby.h"8 #include "mruby/irep.h"7 #include <mruby.h> 8 #include <mruby/irep.h> 9 9 #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> 15 15 #include "mrdberror.h" 16 16 #include "apibreak.h" … … 21 21 22 22 static uint16_t 23 check_lineno( mrb_irep_debug_info_file *info_file, uint16_t lineno)23 check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno) 24 24 { 25 25 uint32_t count = info_file->line_entry_count; 26 26 uint16_t l_idx; 27 27 28 if ( info_file->line_type == mrb_debug_line_ary) {28 if (info_file->line_type == mrb_debug_line_ary) { 29 29 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]) { 31 31 return lineno; 32 32 } 33 33 } 34 } else { 34 } 35 else { 35 36 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) { 37 38 return lineno; 38 39 } … … 44 45 45 46 static int32_t 46 get_break_index( mrb_debug_context *dbg, int32_t bpno)47 get_break_index(mrb_debug_context *dbg, uint32_t bpno) 47 48 { 48 49 uint32_t i; … … 51 52 52 53 for(i = 0 ; i < dbg->bpnum; i++) { 53 if (dbg->bp[i].bpno == bpno) {54 if (dbg->bp[i].bpno == bpno) { 54 55 hit = TRUE; 55 56 index = i; … … 58 59 } 59 60 60 if (hit == FALSE) {61 if (hit == FALSE) { 61 62 return MRB_DEBUG_BREAK_INVALID_NO; 62 63 } … … 66 67 67 68 static void 68 free_breakpoint( mrb_state *mrb, mrb_debug_breakpoint *bp)69 free_breakpoint(mrb_state *mrb, mrb_debug_breakpoint *bp) 69 70 { 70 71 switch(bp->type) { … … 74 75 case MRB_DEBUG_BPTYPE_METHOD: 75 76 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) { 77 78 mrb_free(mrb, (void*)bp->point.methodpoint.class_name); 78 79 } … … 84 85 85 86 static uint16_t 86 check_file_lineno( struct mrb_irep *irep, const char *file, uint16_t lineno)87 check_file_lineno(struct mrb_irep *irep, const char *file, uint16_t lineno) 87 88 { 88 89 mrb_irep_debug_info_file *info_file; … … 94 95 for (f_idx = 0; f_idx < irep->debug_info->flen; ++f_idx) { 95 96 info_file = irep->debug_info->files[f_idx]; 96 if (!strcmp(info_file->filename, file)) {97 if (!strcmp(info_file->filename, file)) { 97 98 result = MRB_DEBUG_BP_FILE_OK; 98 99 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) { 101 102 return result | MRB_DEBUG_BP_LINENO_OK; 102 103 } 103 104 } 104 for ( i=0; i < irep->rlen; ++i) {105 for (i=0; i < irep->rlen; ++i) { 105 106 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)) { 107 108 return result; 108 109 } … … 113 114 114 115 static const char* 115 get_class_name( mrb_state *mrb, struct RClass *class_obj)116 get_class_name(mrb_state *mrb, struct RClass *class_obj) 116 117 { 117 118 struct RClass *outer; … … 124 125 125 126 static int32_t 126 compare_break_method( mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)127 compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc) 127 128 { 128 129 const char* class_name; … … 138 139 139 140 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) { 141 142 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) { 144 145 return bp->bpno; 145 146 } 146 147 } 147 else if (method_p->class_name != NULL) {148 else if (method_p->class_name != NULL) { 148 149 m = mrb_method_search_vm(mrb, &class_obj, method_sym); 149 if (m == NULL) {150 if (m == NULL) { 150 151 return MRB_DEBUG_OK; 151 152 } 152 if (MRB_PROC_CFUNC_P(m)) {153 if (MRB_PROC_CFUNC_P(m)) { 153 154 *isCfunc = TRUE; 154 155 } 155 156 156 157 is_defined = mrb_class_defined(mrb, method_p->class_name); 157 if (is_defined == FALSE) {158 if (is_defined == FALSE) { 158 159 return MRB_DEBUG_OK; 159 160 } … … 162 163 ssym = mrb_symbol(mrb_check_intern_cstr(mrb, method_p->method_name)); 163 164 m = mrb_method_search_vm(mrb, &sc, ssym); 164 if (m == NULL) {165 if (m == NULL) { 165 166 return MRB_DEBUG_OK; 166 167 } … … 168 169 class_name = get_class_name(mrb, class_obj); 169 170 sn = get_class_name(mrb, sc); 170 if (strcmp(sn, class_name) == 0) {171 if (strcmp(sn, class_name) == 0) { 171 172 return bp->bpno; 172 173 } … … 177 178 178 179 int32_t 179 mrb_debug_set_break_line( 180 mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno) 180 181 { 181 182 int32_t index; … … 183 184 uint16_t result; 184 185 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) { 190 191 return MRB_DEBUG_BREAK_NUM_OVER; 191 192 } 192 193 193 if (dbg->next_bpno > MAX_BREAKPOINTNO) {194 if (dbg->next_bpno > MAX_BREAKPOINTNO) { 194 195 return MRB_DEBUG_BREAK_NO_OVER; 195 196 } 196 197 197 198 /* 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) { 200 201 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) { 202 204 return MRB_DEBUG_BREAK_INVALID_LINENO; 203 } 205 } 204 206 205 207 set_file = mrb_malloc(mrb, strlen(file) + 1); … … 221 223 222 224 int32_t 223 mrb_debug_set_break_method( mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name)225 mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name) 224 226 { 225 227 int32_t index; … … 227 229 char* set_method; 228 230 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) { 234 236 return MRB_DEBUG_BREAK_NUM_OVER; 235 237 } 236 238 237 if (dbg->next_bpno > MAX_BREAKPOINTNO) {239 if (dbg->next_bpno > MAX_BREAKPOINTNO) { 238 240 return MRB_DEBUG_BREAK_NO_OVER; 239 241 } 240 242 241 if (class_name != NULL) {243 if (class_name != NULL) { 242 244 set_class = mrb_malloc(mrb, strlen(class_name) + 1); 243 245 strncpy(set_class, class_name, strlen(class_name) + 1); … … 264 266 265 267 int32_t 266 mrb_debug_get_breaknum( mrb_state *mrb, mrb_debug_context *dbg)267 { 268 if ((mrb == NULL) || (dbg == NULL)) {268 mrb_debug_get_breaknum(mrb_state *mrb, mrb_debug_context *dbg) 269 { 270 if ((mrb == NULL) || (dbg == NULL)) { 269 271 return MRB_DEBUG_INVALID_ARGUMENT; 270 272 } … … 273 275 } 274 276 275 int32_t 276 mrb_debug_get_break_all( mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp)277 int32_t 278 mrb_debug_get_break_all(mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp) 277 279 { 278 280 uint32_t get_size = 0; 279 281 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) { 285 287 get_size = size; 286 288 } … … 295 297 296 298 int32_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)) {299 mrb_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)) { 302 304 return MRB_DEBUG_INVALID_ARGUMENT; 303 305 } 304 306 305 307 index = get_break_index(dbg, bpno); 306 if (index == MRB_DEBUG_BREAK_INVALID_NO) {308 if (index == MRB_DEBUG_BREAK_INVALID_NO) { 307 309 return MRB_DEBUG_BREAK_INVALID_NO; 308 310 } … … 316 318 } 317 319 318 int32_t 319 mrb_debug_delete_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)320 int32_t 321 mrb_debug_delete_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno) 320 322 { 321 323 uint32_t i; 322 324 int32_t index; 323 325 324 if ((mrb == NULL) ||(dbg == NULL)) {326 if ((mrb == NULL) ||(dbg == NULL)) { 325 327 return MRB_DEBUG_INVALID_ARGUMENT; 326 328 } 327 329 328 330 index = get_break_index(dbg, bpno); 329 if (index == MRB_DEBUG_BREAK_INVALID_NO) {331 if (index == MRB_DEBUG_BREAK_INVALID_NO) { 330 332 return MRB_DEBUG_BREAK_INVALID_NO; 331 333 } … … 334 336 335 337 for(i = index ; i < dbg->bpnum; i++) { 336 if ((i + 1) == dbg->bpnum) {338 if ((i + 1) == dbg->bpnum) { 337 339 memset(&dbg->bp[i], 0, sizeof(mrb_debug_breakpoint)); 338 340 } … … 347 349 } 348 350 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)) {351 int32_t 352 mrb_debug_delete_break_all(mrb_state *mrb, mrb_debug_context *dbg) 353 { 354 uint32_t i; 355 356 if ((mrb == NULL) || (dbg == NULL)) { 355 357 return MRB_DEBUG_INVALID_ARGUMENT; 356 358 } … … 365 367 } 366 368 367 int32_t 368 mrb_debug_enable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)369 int32_t 370 mrb_debug_enable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno) 369 371 { 370 372 int32_t index = 0; 371 373 372 if ((mrb == NULL) || (dbg == NULL)) {374 if ((mrb == NULL) || (dbg == NULL)) { 373 375 return MRB_DEBUG_INVALID_ARGUMENT; 374 376 } 375 377 376 378 index = get_break_index(dbg, bpno); 377 if (index == MRB_DEBUG_BREAK_INVALID_NO) {379 if (index == MRB_DEBUG_BREAK_INVALID_NO) { 378 380 return MRB_DEBUG_BREAK_INVALID_NO; 379 381 } … … 385 387 386 388 int32_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)) {389 mrb_debug_enable_break_all(mrb_state *mrb, mrb_debug_context *dbg) 390 { 391 uint32_t i; 392 393 if ((mrb == NULL) || (dbg == NULL)) { 392 394 return MRB_DEBUG_INVALID_ARGUMENT; 393 395 } … … 400 402 } 401 403 402 int32_t 403 mrb_debug_disable_break( mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)404 int32_t 405 mrb_debug_disable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno) 404 406 { 405 407 int32_t index = 0; 406 408 407 if ((mrb == NULL) || (dbg == NULL)) {409 if ((mrb == NULL) || (dbg == NULL)) { 408 410 return MRB_DEBUG_INVALID_ARGUMENT; 409 411 } 410 412 411 413 index = get_break_index(dbg, bpno); 412 if (index == MRB_DEBUG_BREAK_INVALID_NO) {414 if (index == MRB_DEBUG_BREAK_INVALID_NO) { 413 415 return MRB_DEBUG_BREAK_INVALID_NO; 414 416 } … … 419 421 } 420 422 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)) {423 int32_t 424 mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg) 425 { 426 uint32_t i; 427 428 if ((mrb == NULL) || (dbg == NULL)) { 427 429 return MRB_DEBUG_INVALID_ARGUMENT; 428 430 } … … 436 438 437 439 static 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))) {440 check_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))) { 442 444 return FALSE; 443 445 } … … 447 449 448 450 int32_t 449 mrb_debug_check_breakpoint_line( mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line)451 mrb_debug_check_breakpoint_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line) 450 452 { 451 453 mrb_debug_breakpoint *bp; 452 454 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)) { 460 462 return MRB_DEBUG_OK; 461 463 } … … 465 467 switch (bp->type) { 466 468 case MRB_DEBUG_BPTYPE_LINE: 467 if (bp->enable == TRUE) {469 if (bp->enable == TRUE) { 468 470 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)) { 470 472 return bp->bpno; 471 473 } … … 484 486 485 487 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)488 int32_t 489 mrb_debug_check_breakpoint_method(mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc) 488 490 { 489 491 mrb_debug_breakpoint *bp; 490 492 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)) { 494 496 return MRB_DEBUG_INVALID_ARGUMENT; 495 497 } … … 497 499 bp = dbg->bp; 498 500 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) { 501 503 bpno = compare_break_method(mrb, bp, class_obj, method_sym, isCfunc); 502 if (bpno > 0) {504 if (bpno > 0) { 503 505 return bpno; 504 506 } 505 507 } 506 508 } 507 else if (bp->type == MRB_DEBUG_BPTYPE_NONE) {509 else if (bp->type == MRB_DEBUG_BPTYPE_NONE) { 508 510 break; 509 511 } -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.h
r321 r331 7 7 #define APIBREAK_H_ 8 8 9 #include "mruby.h"9 #include <mruby.h> 10 10 #include "mrdb.h" 11 11 12 int32_t mrb_debug_set_break_line( mrb_state *, mrb_debug_context *, const char *, uint16_t);13 int32_t mrb_debug_set_break_method( mrb_state *, mrb_debug_context *, const char *, const char *);14 int32_t mrb_debug_get_breaknum( mrb_state *, mrb_debug_context *);15 int32_t mrb_debug_get_break_all( 16 int32_t mrb_debug_get_break( mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint *);17 int32_t mrb_debug_delete_break( mrb_state *, mrb_debug_context *, uint32_t);18 int32_t mrb_debug_delete_break_all( mrb_state *, mrb_debug_context *);19 int32_t mrb_debug_enable_break( mrb_state *, mrb_debug_context *, uint32_t);20 int32_t mrb_debug_enable_break_all( mrb_state *, mrb_debug_context *);21 int32_t mrb_debug_disable_break( mrb_state *, mrb_debug_context *, uint32_t);22 int32_t mrb_debug_disable_break_all( mrb_state *, mrb_debug_context *);23 int32_t mrb_debug_check_breakpoint_line( mrb_state *, mrb_debug_context *, const char *, uint16_t);24 int32_t mrb_debug_check_breakpoint_method( mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool*);12 int32_t mrb_debug_set_break_line(mrb_state *, mrb_debug_context *, const char *, uint16_t); 13 int32_t mrb_debug_set_break_method(mrb_state *, mrb_debug_context *, const char *, const char *); 14 int32_t mrb_debug_get_breaknum(mrb_state *, mrb_debug_context *); 15 int32_t mrb_debug_get_break_all(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]); 16 int32_t mrb_debug_get_break(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint *); 17 int32_t mrb_debug_delete_break(mrb_state *, mrb_debug_context *, uint32_t); 18 int32_t mrb_debug_delete_break_all(mrb_state *, mrb_debug_context *); 19 int32_t mrb_debug_enable_break(mrb_state *, mrb_debug_context *, uint32_t); 20 int32_t mrb_debug_enable_break_all(mrb_state *, mrb_debug_context *); 21 int32_t mrb_debug_disable_break(mrb_state *, mrb_debug_context *, uint32_t); 22 int32_t mrb_debug_disable_break_all(mrb_state *, mrb_debug_context *); 23 int32_t mrb_debug_check_breakpoint_line(mrb_state *, mrb_debug_context *, const char *, uint16_t); 24 int32_t mrb_debug_check_breakpoint_method(mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool*); 25 25 26 26 #endif /* APIBREAK_H_ */ -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
r321 r331 10 10 #include "mrdberror.h" 11 11 #include "apilist.h" 12 #include "mruby/compile.h"13 #include "mruby/irep.h"14 #include "mruby/debug.h"12 #include <mruby/compile.h> 13 #include <mruby/irep.h> 14 #include <mruby/debug.h> 15 15 16 16 #define LINE_BUF_SIZE MAX_COMMAND_LINE … … 72 72 73 73 p = strrchr(path, '/'); 74 len = p != NULL ? p - path: strlen(path);74 len = p != NULL ? (size_t)(p - path) : strlen(path); 75 75 76 76 dir = mrb_malloc(mrb, len + 1); -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.h
r321 r331 6 6 #define APILIST_H_ 7 7 8 #include "mruby.h"8 #include <mruby.h> 9 9 #include "mrdb.h" 10 10 -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c
r321 r331 6 6 #include <string.h> 7 7 #include "mrdb.h" 8 #include "mruby/value.h"9 #include "mruby/class.h"10 #include "mruby/compile.h"11 #include "mruby/error.h"12 #include "mruby/numeric.h"13 #include "mruby/string.h"8 #include <mruby/value.h> 9 #include <mruby/class.h> 10 #include <mruby/compile.h> 11 #include <mruby/error.h> 12 #include <mruby/numeric.h> 13 #include <mruby/string.h> 14 14 #include "apiprint.h" 15 15 -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.h
r321 r331 6 6 #define APIPRINT_H_ 7 7 8 #include "mruby.h"8 #include <mruby.h> 9 9 #include "mrdb.h" 10 10 -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c
r321 r331 6 6 #include <ctype.h> 7 7 #include <string.h> 8 #include "mruby.h"9 #include "mruby/dump.h"10 #include "mruby/debug.h"11 #include "mruby/string.h"8 #include <mruby.h> 9 #include <mruby/dump.h> 10 #include <mruby/debug.h> 11 #include <mruby/string.h> 12 12 #include "mrdb.h" 13 13 #include "mrdberror.h" … … 71 71 uint32_t l; 72 72 73 if ((*ps == '0')||(strlen(ps) >= BPNO_LETTER_NUM)) {73 if ((*ps == '0')||(strlen(ps) >= BPNO_LETTER_NUM)) { 74 74 return 0; 75 75 } 76 76 77 while ( !(ISBLANK(*ps)||ISCNTRL(*ps))) {78 if (!ISDIGIT(*ps)) {77 while (!(ISBLANK(*ps)||ISCNTRL(*ps))) { 78 if (!ISDIGIT(*ps)) { 79 79 return 0; 80 80 } … … 91 91 int32_t ret = MRB_DEBUG_OK; 92 92 93 if (mrdb->wcnt == 1) {93 if (mrdb->wcnt == 1) { 94 94 ret = func(mrb, mrdb->dbg); 95 95 print_api_common_error(ret); … … 110 110 ps = mrdb->words[i]; 111 111 bpno = parse_breakpoint_no(ps); 112 if (bpno == 0) {112 if (bpno == 0) { 113 113 printf(BREAK_ERR_MSG_INVALIDBPNO, ps); 114 114 break; 115 115 } 116 116 ret = func(mrb, mrdb->dbg, (uint32_t)bpno); 117 if (ret == MRB_DEBUG_BREAK_INVALID_NO) {117 if (ret == MRB_DEBUG_BREAK_INVALID_NO) { 118 118 printf(BREAK_ERR_MSG_NOBPNO, bpno); 119 119 } 120 else if (ret != MRB_DEBUG_OK) {120 else if (ret != MRB_DEBUG_OK) { 121 121 print_api_common_error(ret); 122 122 } … … 129 129 char* ps = args; 130 130 131 if (ISBLANK(*ps)||ISCNTRL(*ps)) {131 if (ISBLANK(*ps)||ISCNTRL(*ps)) { 132 132 puts(BREAK_ERR_MSG_BLANK); 133 133 return MRB_DEBUG_BPTYPE_NONE; 134 134 } 135 135 136 if (!ISDIGIT(*ps)) {136 if (!ISDIGIT(*ps)) { 137 137 return MRB_DEBUG_BPTYPE_METHOD; 138 138 } 139 139 140 while ( !(ISBLANK(*ps)||ISCNTRL(*ps))) {141 if (!ISDIGIT(*ps)) {140 while (!(ISBLANK(*ps)||ISCNTRL(*ps))) { 141 if (!ISDIGIT(*ps)) { 142 142 printf(BREAK_ERR_MSG_INVALIDSTR, args); 143 143 return MRB_DEBUG_BPTYPE_NONE; … … 146 146 } 147 147 148 if ((*args == '0')||(strlen(args) >= LINENO_MAX_DIGIT)) {148 if ((*args == '0')||(strlen(args) >= LINENO_MAX_DIGIT)) { 149 149 puts(BREAK_ERR_MSG_RANGEOVER); 150 150 return MRB_DEBUG_BPTYPE_NONE; … … 159 159 const char* enable_letter[] = {BREAK_INFO_MSG_DISABLE, BREAK_INFO_MSG_ENABLE}; 160 160 161 if (bp->type == MRB_DEBUG_BPTYPE_LINE) {161 if (bp->type == MRB_DEBUG_BPTYPE_LINE) { 162 162 printf(BREAK_INFO_MSG_LINEBREAK, 163 163 bp->bpno, enable_letter[bp->enable], bp->point.linepoint.file, bp->point.linepoint.lineno); 164 164 } 165 165 else { 166 if (bp->point.methodpoint.class_name == NULL) {166 if (bp->point.methodpoint.class_name == NULL) { 167 167 printf(BREAK_INFO_MSG_METHODBREAK_NOCLASS, 168 168 bp->bpno, enable_letter[bp->enable], bp->point.methodpoint.method_name); … … 184 184 185 185 bpnum = mrb_debug_get_breaknum(mrb, mrdb->dbg); 186 if (bpnum < 0) {186 if (bpnum < 0) { 187 187 print_api_common_error(bpnum); 188 188 return; 189 189 } 190 else if (bpnum == 0) {190 else if (bpnum == 0) { 191 191 puts(BREAK_ERR_MSG_NOBPNO_INFOALL); 192 192 return; … … 195 195 196 196 ret = mrb_debug_get_break_all(mrb, mrdb->dbg, (uint32_t)bpnum, bp_list); 197 if (ret < 0) {197 if (ret < 0) { 198 198 print_api_common_error(ret); 199 199 return; … … 220 220 ps = mrdb->words[i]; 221 221 bpno = parse_breakpoint_no(ps); 222 if (bpno == 0) {222 if (bpno == 0) { 223 223 puts(BREAK_ERR_MSG_INVALIDBPNO_INFO); 224 224 break; … … 226 226 227 227 ret = mrb_debug_get_break(mrb, mrdb->dbg, bpno, &bp); 228 if (ret == MRB_DEBUG_BREAK_INVALID_NO) {228 if (ret == MRB_DEBUG_BREAK_INVALID_NO) { 229 229 printf(BREAK_ERR_MSG_NOBPNO_INFO, bpno); 230 230 break; 231 231 } 232 else if (ret != MRB_DEBUG_OK) {232 else if (ret != MRB_DEBUG_OK) { 233 233 print_api_common_error(ret); 234 234 break; 235 235 } 236 else if (isFirst == TRUE) {236 else if (isFirst == TRUE) { 237 237 isFirst = FALSE; 238 238 puts(BREAK_INFO_MSG_HEADER); … … 251 251 uint32_t l; 252 252 253 if (mrdb->wcnt <= 1) {253 if (mrdb->wcnt <= 1) { 254 254 puts(BREAK_ERR_MSG_BLANK); 255 255 return MRB_DEBUG_BPTYPE_NONE; … … 257 257 258 258 args = mrdb->words[1]; 259 if ((body = strrchr(args, ':')) == NULL) {259 if ((body = strrchr(args, ':')) == NULL) { 260 260 body = args; 261 261 type = check_bptype(body); 262 } else { 263 if(body == args) { 262 } 263 else { 264 if (body == args) { 264 265 printf(BREAK_ERR_MSG_INVALIDSTR, args); 265 266 return MRB_DEBUG_BPTYPE_NONE; … … 272 273 case MRB_DEBUG_BPTYPE_LINE: 273 274 STRTOUL(l, body); 274 if ( l <= 65535) {275 if (l <= 65535) { 275 276 *line = l; 276 277 *file = (body == args)? mrb_debug_get_filename(dbg->irep, (uint32_t)(dbg->pc - dbg->irep->iseq)): args; 277 } else { 278 } 279 else { 278 280 puts(BREAK_ERR_MSG_RANGEOVER); 279 281 type = MRB_DEBUG_BPTYPE_NONE; … … 281 283 break; 282 284 case MRB_DEBUG_BPTYPE_METHOD: 283 if (body == args) {285 if (body == args) { 284 286 /* method only */ 285 if ( ISUPPER(*body)||ISLOWER(*body)||(*body == '_')) {287 if (ISUPPER(*body)||ISLOWER(*body)||(*body == '_')) { 286 288 *method = body; 287 289 *cname = NULL; 288 } else { 290 } 291 else { 289 292 printf(BREAK_ERR_MSG_INVALIDMETHOD, args); 290 293 type = MRB_DEBUG_BPTYPE_NONE; 291 294 } 292 } else { 293 if( ISUPPER(*args) ) { 295 } 296 else { 297 if (ISUPPER(*args)) { 294 298 switch(*body) { 295 299 case '@': case '$': case '?': case '.': case ',': case ':': … … 303 307 break; 304 308 } 305 } else { 309 } 310 else { 306 311 printf(BREAK_ERR_MSG_INVALIDCLASS, args); 307 312 type = MRB_DEBUG_BPTYPE_NONE; … … 344 349 if (type == MRB_DEBUG_BPTYPE_LINE) { 345 350 printf(BREAK_SET_MSG_LINE, ret, file, line); 346 } else if ((type == MRB_DEBUG_BPTYPE_METHOD)&&(cname == NULL)) { 351 } 352 else if ((type == MRB_DEBUG_BPTYPE_METHOD)&&(cname == NULL)) { 347 353 printf(BREAK_SET_MSG_METHOD, ret, method); 348 } else { 354 } 355 else { 349 356 printf(BREAK_SET_MSG_CLASS_METHOD, ret, cname, method); 350 357 } 351 } else { 358 } 359 else { 352 360 switch (ret) { 353 361 case MRB_DEBUG_BREAK_INVALID_LINENO: … … 380 388 dbgcmd_info_break(mrb_state *mrb, mrdb_state *mrdb) 381 389 { 382 if (mrdb->wcnt == 2) {390 if (mrdb->wcnt == 2) { 383 391 info_break_all(mrb, mrdb); 384 392 } … … 396 404 397 405 ret = exe_set_command_all(mrb, mrdb, mrb_debug_delete_break_all); 398 if (ret != TRUE) {406 if (ret != TRUE) { 399 407 exe_set_command_select(mrb, mrdb, mrb_debug_delete_break); 400 408 } … … 409 417 410 418 ret = exe_set_command_all(mrb, mrdb, mrb_debug_enable_break_all); 411 if (ret != TRUE) {419 if (ret != TRUE) { 412 420 exe_set_command_select(mrb, mrdb, mrb_debug_enable_break); 413 421 } … … 422 430 423 431 ret = exe_set_command_all(mrb, mrdb, mrb_debug_disable_break_all); 424 if (ret != TRUE) {432 if (ret != TRUE) { 425 433 exe_set_command_select(mrb, mrdb, mrb_debug_disable_break); 426 434 } -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
r321 r331 9 9 10 10 #include "apilist.h" 11 #include "mruby/compile.h"11 #include <mruby/compile.h> 12 12 13 13 typedef struct help_msg { … … 334 334 return FALSE; 335 335 } 336 if ((lbracket = strchr(pattern, '[')) == NULL) {336 if ((lbracket = strchr(pattern, '[')) == NULL) { 337 337 return !strcmp(pattern, cmd); 338 338 } -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c
r321 r331 6 6 #include <string.h> 7 7 #include "mrdb.h" 8 #include "mruby/value.h"9 #include "mruby/class.h"10 #include "mruby/compile.h"11 #include "mruby/error.h"12 #include "mruby/numeric.h"13 #include "mruby/string.h"8 #include <mruby/value.h> 9 #include <mruby/class.h> 10 #include <mruby/compile.h> 11 #include <mruby/error.h> 12 #include <mruby/numeric.h> 13 #include <mruby/string.h> 14 14 #include "apiprint.h" 15 15 -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdrun.c
r321 r331 4 4 */ 5 5 6 #include "mruby/opcode.h"6 #include <mruby/opcode.h> 7 7 #include "mrdb.h" 8 8 … … 12 12 mrb_debug_context *dbg = mrdb->dbg; 13 13 14 if ( dbg->xm == DBG_INIT){14 if (dbg->xm == DBG_INIT){ 15 15 dbg->xm = DBG_RUN; 16 } else { 16 } 17 else { 17 18 dbg->xm = DBG_QUIT; 18 if ( dbg->xphase == DBG_PHASE_RUNNING){19 if (dbg->xphase == DBG_PHASE_RUNNING){ 19 20 struct RClass *exc; 20 21 puts("Start it from the beginning."); … … 23 24 } 24 25 } 25 26 26 27 return DBGST_RESTART; 27 28 } … … 33 34 int ccnt = 1; 34 35 35 if ( mrdb->wcnt > 1){36 if (mrdb->wcnt > 1){ 36 37 sscanf(mrdb->words[1], "%d", &ccnt); 37 38 } 38 39 dbg->ccnt = (uint16_t)(ccnt > 0 ? ccnt : 1); /* count of continue */ 39 40 40 if ( dbg->xphase == DBG_PHASE_AFTER_RUN){41 if (dbg->xphase == DBG_PHASE_AFTER_RUN){ 41 42 puts("The program is not running."); 42 43 dbg->xm = DBG_QUIT; 43 } else { 44 } 45 else { 44 46 dbg->xm = DBG_RUN; 45 47 } … … 53 55 return DBGST_CONTINUE; 54 56 } 57 58 dbgcmd_state 59 dbgcmd_next(mrb_state *mrb, mrdb_state *mrdb) 60 { 61 mrdb->dbg->xm = DBG_NEXT; 62 mrdb->dbg->prvci = mrb->c->ci; 63 return DBGST_CONTINUE; 64 } -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
r321 r331 9 9 #include <ctype.h> 10 10 11 #include "mruby.h"12 #include "mruby/dump.h"13 #include "mruby/debug.h"14 #include "mruby/class.h"15 #include "mruby/opcode.h"16 #include "mruby/variable.h"11 #include <mruby.h> 12 #include <mruby/dump.h> 13 #include <mruby/debug.h> 14 #include <mruby/class.h> 15 #include <mruby/opcode.h> 16 #include <mruby/variable.h> 17 17 18 18 #include "mrdb.h" … … 58 58 {"run", NULL, 1, 0, 0, DBGCMD_RUN, dbgcmd_run}, /* r[un] */ 59 59 {"step", NULL, 1, 0, 1, DBGCMD_STEP, dbgcmd_step}, /* s[tep] */ 60 {"next", NULL, 1, 0, 1, DBGCMD_NEXT, dbgcmd_next}, /* n[ext] */ 60 61 {NULL} 61 62 }; … … 406 407 407 408 ret = mrb_debug_get_break(mrb, mrdb->dbg, mrdb->dbg->stopped_bpno, &bp); 408 if (ret == 0) {409 if (ret == 0) { 409 410 switch(bp.type) { 410 411 case MRB_DEBUG_BPTYPE_LINE: … … 416 417 method_name = bp.point.methodpoint.method_name; 417 418 class_name = bp.point.methodpoint.class_name; 418 if (class_name == NULL) {419 if (class_name == NULL) { 419 420 printf("Breakpoint %d, %s\n", bp.bpno, method_name); 420 421 } … … 422 423 printf("Breakpoint %d, %s:%s\n", bp.bpno, class_name, method_name); 423 424 } 424 if (mrdb->dbg->isCfunc) {425 if (mrdb->dbg->isCfunc) { 425 426 printf("Stopped before calling the C function.\n"); 426 427 } … … 445 446 char* file = mrb_debug_get_source(mrb, mrdb, mrdb->srcpath, mrdb->dbg->prvfile); 446 447 uint16_t lineno = mrdb->dbg->prvline; 447 if (file != NULL) {448 if (file != NULL) { 448 449 mrb_debug_list(mrb, mrdb->dbg, file, lineno, lineno); 449 450 mrb_free(mrb, file); … … 531 532 break; 532 533 } 533 if (sym != 0) {534 if (sym != 0) { 534 535 dbg->method_bpno = mrb_debug_check_breakpoint_method(mrb, dbg, c, sym, &isCfunc); 535 if (isCfunc) {536 if (isCfunc) { 536 537 bpno = dbg->method_bpno; 537 538 dbg->method_bpno = 0; … … 557 558 dbg->regs = regs; 558 559 559 if (dbg->xphase == DBG_PHASE_RESTART) {560 if (dbg->xphase == DBG_PHASE_RESTART) { 560 561 dbg->root_irep = irep; 561 562 dbg->prvfile = NULL; 562 563 dbg->prvline = 0; 564 dbg->prvci = NULL; 563 565 dbg->xm = DBG_RUN; 564 566 dbg->xphase = DBG_PHASE_RUNNING; … … 570 572 switch (dbg->xm) { 571 573 case DBG_STEP: 572 case DBG_NEXT: // temporary573 574 if (!file || (dbg->prvfile == file && dbg->prvline == line)) { 574 575 return; … … 576 577 dbg->method_bpno = 0; 577 578 dbg->bm = BRK_STEP; 579 break; 580 581 case DBG_NEXT: 582 if (!file || (dbg->prvfile == file && dbg->prvline == line)) { 583 return; 584 } 585 if ((intptr_t)(dbg->prvci) < (intptr_t)(mrb->c->ci)) { 586 return; 587 } 588 dbg->prvci = NULL; 589 dbg->method_bpno = 0; 590 dbg->bm = BRK_NEXT; 578 591 break; 579 592 … … 611 624 dbg->prvline = line; 612 625 613 if (dbg->bm == BRK_BREAK && --dbg->ccnt > 0) {626 if (dbg->bm == BRK_BREAK && --dbg->ccnt > 0) { 614 627 return; 615 628 } … … 634 647 st = cmd->func(mrb, mrdb); 635 648 636 if ( (st == DBGST_CONTINUE) || (st == DBGST_RESTART)) break;649 if ((st == DBGST_CONTINUE) || (st == DBGST_RESTART)) break; 637 650 } 638 651 return dbg->xm; … … 671 684 mrdb->srcpath = args.srcpath; 672 685 673 if (mrdb->dbg->xm == DBG_QUIT) {686 if (mrdb->dbg->xm == DBG_QUIT) { 674 687 mrdb->dbg->xphase = DBG_PHASE_RESTART; 675 688 } … … 679 692 mrdb->dbg->xm = DBG_INIT; 680 693 mrdb->dbg->ccnt = 1; 681 694 682 695 /* setup hook functions */ 683 696 mrb->code_fetch_hook = mrb_code_fetch_hook; … … 726 739 } 727 740 } 728 741 729 742 mrdb->dbg->prvfile = "-"; 730 743 mrdb->dbg->prvline = 0; 731 744 732 745 while (1) { 733 746 cmd = get_and_parse_command(mrb, mrdb); 734 747 mrb_assert(cmd); 735 748 736 749 if (cmd->id == DBGCMD_QUIT) { 737 750 break; 738 751 } 739 740 if ( cmd->func(mrb, mrdb) == DBGST_RESTART ) goto l_restart;741 } 742 752 753 if ( cmd->func(mrb, mrdb) == DBGST_RESTART ) goto l_restart; 754 } 755 743 756 cleanup(mrb, &args); 744 757 -
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h
r321 r331 7 7 #define MRDB_H 8 8 9 #include "mruby.h"9 #include <mruby.h> 10 10 11 11 #include "mrdbconf.h" … … 110 110 const char *prvfile; 111 111 int32_t prvline; 112 mrb_callinfo *prvci; 112 113 113 114 mrdb_exemode xm; … … 147 148 dbgcmd_state dbgcmd_continue(mrb_state*, mrdb_state*); 148 149 dbgcmd_state dbgcmd_step(mrb_state*, mrdb_state*); 150 dbgcmd_state dbgcmd_next(mrb_state*, mrdb_state*); 149 151 /* cmdbreak.c */ 150 152 dbgcmd_state dbgcmd_break(mrb_state*, mrdb_state*);
Note:
See TracChangeset
for help on using the changeset viewer.