pancake wrote: > (...) > Ok, after the presentations.. I have some problems for writing the patches > because more than one bug report matches the same source file, and i have to > wait everytime for commits before doing anything more. I understand that this > is my problem and I should be pacient, but on pdb there are a lot of broken > things that are difficult to split into multiple patches.
I had the same problem, and I currently use the git version control system with the git-svn wrapper to read from Parrot's repos. I can commit without pushing it to the Parrot servers. I can also branch easily, for instance I have a branch where all kinds of changes are in in no particular order, and when I want to spit out a patch, I branch from a parent and apply the commits that I want to have in that patch. Then git diff <begin> <end> > offs.patch and I can delete the branch. It's way better than when I used subversion, I think I had three checkouts because I had to test patches. Now one suffices. I hear svk (based on, and compatible with svn) does a pretty good decentralized job too. The Parrot web site mentions svk, so you can probably get help from more people if you want. > (..) > > My question is. How can I translate a opcode_t into a file:line message? > > Thanks! > > --pancake > There's code to get file and line in src/sub.c. Attached patch puts the code in a function Parrot_offs_get_info. I think you can call it like this: char *file; int line; if (Parrot_offs_get_info(interp, offs, interp->code, &file, &line) { <here, file and line are set correctly.> string_cstring_free(file); } else { <we get here if we can't retrieve file:line.> } I think it would be good if the patch were applied. 0:) Thanks, -- Bram Geron | GPG 0xE7B9E65E
--- a/src/sub.c +++ b/src/sub.c @@ -297,6 +297,49 @@ Parrot_full_sub_name(Interp *interp, PMC* sub) return NULL; } +/* + +=item C<Parrot_offs_get_info> + +Get file and line number of bytecode offset. On success, true is returned, +*file is set to a char * holding the file name, and *line is set to an int +holding the line number. *file is a newly allocated string, you are supposed to +free it yourself with string_cstring_free(*file). + +=cut + +*/ + +int +Parrot_offs_get_info (Interp *interp, int offs, PackFile_ByteCode *seg, char **file, int *line) +{ + size_t i; /* index in debug segment */ + size_t n; + opcode_t *pc = seg->base.data; /* starting pc of this sub */ + PackFile_Debug * const debug = seg->debugs; + + if (!debug) + return 0; + for (i = n = 0; n < seg->base.size; i++) { + op_info_t * const op_info = &interp->op_info_table[*pc]; + opcode_t var_args = 0; + + if (i >= debug->base.size) + return 0; + if (n >= offs) { + /* set source line and file */ + *line = debug->base.data[i]; + *file = string_to_cstring(interp, + Parrot_debug_pc_to_filename(interp, debug, i)); + break; + } + ADD_OP_VAR_PART(interp, seg, pc, var_args); + n += op_info->op_count + var_args; + pc += op_info->op_count + var_args; + } + return 1; +} + int Parrot_Context_get_info(Interp *interp, parrot_context_t *ctx, Parrot_Context_info *info) @@ -349,30 +392,8 @@ Parrot_Context_get_info(Interp *interp, parrot_context_t *ctx, /* determine the current source file/line */ if (ctx->current_pc) { - const size_t offs = info->pc; - size_t i, n; - opcode_t *pc = sub->seg->base.data; - PackFile_Debug * const debug = sub->seg->debugs; - - if (!debug) + if (0 == Parrot_offs_get_info(interp, info->pc, sub->seg, &info->file, &info->line)) return 0; - for (i = n = 0; n < sub->seg->base.size; i++) { - op_info_t * const op_info = &interp->op_info_table[*pc]; - opcode_t var_args = 0; - - if (i >= debug->base.size) - return 0; - if (n >= offs) { - /* set source line and file */ - info->line = debug->base.data[i]; - info->file = string_to_cstring(interp, - Parrot_debug_pc_to_filename(interp, debug, i)); - break; - } - ADD_OP_VAR_PART(interp, sub->seg, pc, var_args); - n += op_info->op_count + var_args; - pc += op_info->op_count + var_args; - } } return 1; }