[svn:parrot] r44077 - in branches/sys_mem_reduce: include/parrot src
bacek at svn.parrot.org
bacek at svn.parrot.org
Wed Feb 17 08:53:13 UTC 2010
Author: bacek
Date: Wed Feb 17 08:53:11 2010
New Revision: 44077
URL: https://trac.parrot.org/parrot/changeset/44077
Log:
Switch debugger to GC allocations
Modified:
branches/sys_mem_reduce/include/parrot/debugger.h
branches/sys_mem_reduce/src/debug.c
Modified: branches/sys_mem_reduce/include/parrot/debugger.h
==============================================================================
--- branches/sys_mem_reduce/include/parrot/debugger.h Wed Feb 17 07:51:33 2010 (r44076)
+++ branches/sys_mem_reduce/include/parrot/debugger.h Wed Feb 17 08:53:11 2010 (r44077)
@@ -214,12 +214,13 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-long PDB_add_label(
+long PDB_add_label(PARROT_INTERP,
ARGMOD(PDB_file_t *file),
ARGIN(const opcode_t *cur_opcode),
opcode_t offset)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
+ __attribute__nonnull__(3)
FUNC_MODIFIES(*file);
void PDB_assign(PARROT_INTERP, ARGIN(const char *command))
@@ -256,7 +257,9 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-void PDB_delete_condition(SHIM_INTERP, ARGMOD(PDB_breakpoint_t *breakpoint))
+void PDB_delete_condition(PARROT_INTERP,
+ ARGMOD(PDB_breakpoint_t *breakpoint))
+ __attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*breakpoint);
@@ -289,8 +292,9 @@
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
PARROT_MALLOC
-char * PDB_escape(ARGIN(const char *string), UINTVAL length)
- __attribute__nonnull__(1);
+char * PDB_escape(PARROT_INTERP, ARGIN(const char *string), UINTVAL length)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
void PDB_eval(PARROT_INTERP, ARGIN(const char *command))
__attribute__nonnull__(1)
@@ -303,7 +307,9 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-void PDB_free_file(SHIM_INTERP, ARGIN_NULLOK(PDB_file_t *file));
+void PDB_free_file(PARROT_INTERP, ARGIN_NULLOK(PDB_file_t *file))
+ __attribute__nonnull__(1);
+
void PDB_get_command(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -379,7 +385,8 @@
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(command))
#define ASSERT_ARGS_PDB_add_label __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(file) \
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(file) \
, PARROT_ASSERT_ARG(cur_opcode))
#define ASSERT_ARGS_PDB_assign __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -403,7 +410,8 @@
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(command))
#define ASSERT_ARGS_PDB_delete_condition __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(breakpoint))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(breakpoint))
#define ASSERT_ARGS_PDB_disable_breakpoint __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(command))
@@ -418,14 +426,16 @@
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(command))
#define ASSERT_ARGS_PDB_escape __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(string))
+ PARROT_ASSERT_ARG(interp) \
+ , PARROT_ASSERT_ARG(string))
#define ASSERT_ARGS_PDB_eval __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(command))
#define ASSERT_ARGS_PDB_find_breakpoint __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(command))
-#define ASSERT_ARGS_PDB_free_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_PDB_free_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_PDB_get_command __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_PDB_hasinstruction __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
Modified: branches/sys_mem_reduce/src/debug.c
==============================================================================
--- branches/sys_mem_reduce/src/debug.c Wed Feb 17 07:51:33 2010 (r44076)
+++ branches/sys_mem_reduce/src/debug.c Wed Feb 17 08:53:11 2010 (r44077)
@@ -1001,7 +1001,7 @@
TRACEDEB_MSG("Parrot_debugger_init");
if (! interp->pdb) {
- PDB_t *pdb = mem_allocate_zeroed_typed(PDB_t);
+ PDB_t *pdb = gc_mem_allocate_zeroed_typed(interp, PDB_t);
Parrot_Interp debugger = Parrot_new(interp);
interp->pdb = pdb;
debugger->pdb = pdb;
@@ -1009,8 +1009,8 @@
pdb->debugger = debugger;
/* Allocate space for command line buffers, NUL terminated c strings */
- pdb->cur_command = (char *)mem_sys_allocate_zeroed(DEBUG_CMD_BUFFER_LENGTH + 1);
- pdb->last_command = (char *)mem_sys_allocate_zeroed(DEBUG_CMD_BUFFER_LENGTH + 1);
+ pdb->cur_command = gc_mem_allocate_n_typed(interp, DEBUG_CMD_BUFFER_LENGTH + 1, char);
+ pdb->last_command = gc_mem_allocate_n_typed(interp, DEBUG_CMD_BUFFER_LENGTH + 1, char);
pdb->file = mem_allocate_zeroed_typed(PDB_file_t);
}
@@ -1044,10 +1044,10 @@
PARROT_ASSERT(pdb);
PARROT_ASSERT(pdb->debugee == interp);
- mem_sys_free(pdb->last_command);
- mem_sys_free(pdb->cur_command);
+ gc_mem_free(interp, pdb->last_command);
+ gc_mem_free(interp, pdb->cur_command);
- mem_sys_free(pdb);
+ gc_mem_free(interp, pdb);
interp->pdb = NULL;
}
@@ -1627,7 +1627,7 @@
}
/* Allocate new condition */
- condition = mem_allocate_zeroed_typed(PDB_condition_t);
+ condition = gc_mem_allocate_zeroed_typed(interp, PDB_condition_t);
condition->type = cond_argleft | cond_type;
@@ -1640,7 +1640,7 @@
if (cond_argright != cond_argleft) {
Parrot_io_eprintf(interp->pdb->debugger, "Register types don't agree\n");
- mem_sys_free(condition);
+ gc_mem_free(interp, condition);
return NULL;
}
@@ -1649,28 +1649,28 @@
reg_number = (int)get_uint(&command, 0);
if (auxcmd == command) {
Parrot_io_eprintf(interp->pdb->debugger, "Invalid register\n");
- mem_sys_free(condition);
+ gc_mem_free(interp, condition);
return NULL;
}
if (reg_number < 0) {
Parrot_io_eprintf(interp->pdb->debugger, "Out-of-bounds register\n");
- mem_sys_free(condition);
+ gc_mem_free(interp, condition);
return NULL;
}
- condition->value = mem_allocate_typed(int);
+ condition->value = gc_mem_allocate_typed(interp, int);
*(int *)condition->value = reg_number;
}
/* If the first argument was an integer */
else if (condition->type & PDB_cond_int) {
/* This must be either an integer constant or register */
- condition->value = mem_allocate_typed(INTVAL);
+ condition->value = gc_mem_allocate_typed(interp, INTVAL);
*(INTVAL *)condition->value = (INTVAL)atoi(command);
condition->type |= PDB_cond_const;
}
else if (condition->type & PDB_cond_num) {
- condition->value = mem_allocate_typed(FLOATVAL);
+ condition->value = gc_mem_allocate_typed(interp, FLOATVAL);
*(FLOATVAL *)condition->value = (FLOATVAL)atof(command);
condition->type |= PDB_cond_const;
}
@@ -1690,7 +1690,7 @@
/* TT #1259: Need to figure out what to do in this case.
* For the time being, we just bail. */
Parrot_io_eprintf(interp->pdb->debugger, "Can't compare PMC with constant\n");
- mem_sys_free(condition);
+ gc_mem_free(interp, condition);
return NULL;
}
@@ -1813,7 +1813,7 @@
TRACEDEB_MSG("PDB_set_break allocate breakpoint");
/* Allocate the new break point */
- newbreak = mem_allocate_zeroed_typed(PDB_breakpoint_t);
+ newbreak = gc_mem_allocate_zeroed_typed(interp, PDB_breakpoint_t);
if (command) {
/*command = skip_command(command);*/
@@ -2104,7 +2104,7 @@
}
bp_id = breakpoint->id;
/* Kill the breakpoint */
- mem_sys_free(breakpoint);
+ gc_mem_free(interp, breakpoint);
Parrot_io_eprintf(interp->pdb->debugger, "Breakpoint %li deleted\n", bp_id);
}
@@ -2121,7 +2121,7 @@
*/
void
-PDB_delete_condition(SHIM_INTERP, ARGMOD(PDB_breakpoint_t *breakpoint))
+PDB_delete_condition(PARROT_INTERP, ARGMOD(PDB_breakpoint_t *breakpoint))
{
ASSERT_ARGS(PDB_delete_condition)
if (breakpoint->condition->value) {
@@ -2134,12 +2134,12 @@
}
else {
/* 'value' is a float or an int, so we can just free it */
- mem_sys_free(breakpoint->condition->value);
+ gc_mem_free(interp, breakpoint->condition->value);
breakpoint->condition->value = NULL;
}
}
- mem_sys_free(breakpoint->condition);
+ gc_mem_free(interp, breakpoint->condition);
breakpoint->condition = NULL;
}
@@ -2397,7 +2397,7 @@
/*
-=item C<char * PDB_escape(const char *string, UINTVAL length)>
+=item C<char * PDB_escape(PARROT_INTERP, const char *string, UINTVAL length)>
Escapes C<">, C<\r>, C<\n>, C<\t>, C<\a> and C<\\>.
@@ -2411,7 +2411,7 @@
PARROT_CAN_RETURN_NULL
PARROT_MALLOC
char *
-PDB_escape(ARGIN(const char *string), UINTVAL length)
+PDB_escape(PARROT_INTERP, ARGIN(const char *string), UINTVAL length)
{
ASSERT_ARGS(PDB_escape)
const char *end;
@@ -2424,7 +2424,7 @@
if (!string)
return NULL;
- fill = _new = (char *)mem_sys_allocate(length * 2 + 1);
+ fill = _new = gc_mem_allocate_n_typed(interp, length * 2 + 1, char);
for (; string < end; string++) {
switch (*string) {
@@ -2584,7 +2584,7 @@
(info->jump & PARROT_JUMP_RELATIVE)) {
if (file) {
dest[size++] = 'L';
- i = PDB_add_label(file, op, op[j]);
+ i = PDB_add_label(interp, file, op, op[j]);
}
else if (code_start) {
dest[size++] = 'O';
@@ -2624,12 +2624,12 @@
Parrot_str_to_cstring(interp, interp->code->
const_table->constants[op[j]]->u.string);
char * const escaped =
- PDB_escape(unescaped, interp->code->const_table->
+ PDB_escape(interp, unescaped, interp->code->const_table->
constants[op[j]]->u.string->strlen);
if (escaped) {
strcpy(&dest[size], escaped);
size += strlen(escaped);
- mem_sys_free(escaped);
+ gc_mem_free(interp, escaped);
}
Parrot_str_free_cstring(unescaped);
}
@@ -2855,8 +2855,8 @@
TRACEDEB_MSG("PDB_disassemble");
- pfile = mem_allocate_zeroed_typed(PDB_file_t);
- pline = mem_allocate_zeroed_typed(PDB_line_t);
+ pfile = gc_mem_allocate_zeroed_typed(interp, PDB_file_t);
+ pline = gc_mem_allocate_zeroed_typed(interp, PDB_line_t);
/* If we already got a source, free it */
if (pdb->file) {
@@ -2866,7 +2866,7 @@
pfile->line = pline;
pline->number = 1;
- pfile->source = (char *)mem_sys_allocate(default_size);
+ pfile->source = gc_mem_allocate_n_typed(interp, default_size, char);
alloced = space = default_size;
code_end = pc + interp->code->base.size;
@@ -2876,7 +2876,7 @@
if (space < default_size) {
alloced += default_size;
space += default_size;
- pfile->source = (char *)mem_sys_realloc(pfile->source, alloced);
+ pfile->source = gc_mem_realloc_n_typed(interp, pfile->source, alloced, char);
}
size = PDB_disassemble_op(interp, pfile->source + pfile->size,
@@ -2893,7 +2893,7 @@
pc += n;
/* Prepare for next line */
- newline = mem_allocate_typed(PDB_line_t);
+ newline = gc_mem_allocate_zeroed_typed(interp, PDB_line_t);
newline->label = NULL;
newline->next = NULL;
newline->number = pline->number + 1;
@@ -2931,8 +2931,8 @@
/*
-=item C<long PDB_add_label(PDB_file_t *file, const opcode_t *cur_opcode,
-opcode_t offset)>
+=item C<long PDB_add_label(PARROT_INTERP, PDB_file_t *file, const opcode_t
+*cur_opcode, opcode_t offset)>
Add a label to the label list.
@@ -2941,7 +2941,8 @@
*/
long
-PDB_add_label(ARGMOD(PDB_file_t *file), ARGIN(const opcode_t *cur_opcode),
+PDB_add_label(PARROT_INTERP, ARGMOD(PDB_file_t *file),
+ ARGIN(const opcode_t *cur_opcode),
opcode_t offset)
{
ASSERT_ARGS(PDB_add_label)
@@ -2957,7 +2958,7 @@
/* Allocate a new label */
label = file->label;
- _new = mem_allocate_typed(PDB_label_t);
+ _new = gc_mem_allocate_zeroed_typed(interp, PDB_label_t);
_new->opcode = cur_opcode + offset;
_new->next = NULL;
@@ -2987,7 +2988,7 @@
*/
void
-PDB_free_file(SHIM_INTERP, ARGIN_NULLOK(PDB_file_t *file))
+PDB_free_file(PARROT_INTERP, ARGIN_NULLOK(PDB_file_t *file))
{
ASSERT_ARGS(PDB_free_file)
while (file) {
@@ -2998,7 +2999,7 @@
while (line) {
PDB_line_t * const nline = line->next;
- mem_sys_free(line);
+ gc_mem_free(interp, line);
line = nline;
}
@@ -3008,19 +3009,19 @@
while (label) {
PDB_label_t * const nlabel = label->next;
- mem_sys_free(label);
+ gc_mem_free(interp, label);
label = nlabel;
}
/* Free the remaining allocated portions of the file structure */
if (file->sourcefilename)
- mem_sys_free(file->sourcefilename);
+ gc_mem_free(interp, file->sourcefilename);
if (file->source)
- mem_sys_free(file->source);
+ gc_mem_free(interp, file->source);
nfile = file->next;
- mem_sys_free(file);
+ gc_mem_free(interp, file);
file = nfile;
}
}
@@ -3076,10 +3077,10 @@
return;
}
- pfile = mem_allocate_zeroed_typed(PDB_file_t);
- pline = mem_allocate_zeroed_typed(PDB_line_t);
+ pfile = gc_mem_allocate_zeroed_typed(interp, PDB_file_t);
+ pline = gc_mem_allocate_zeroed_typed(interp, PDB_line_t);
- pfile->source = (char *)mem_sys_allocate(1024);
+ pfile->source = gc_mem_allocate_n_typed(interp, 1024, char);
pfile->line = pline;
pline->number = 1;
@@ -3089,8 +3090,8 @@
while ((c = fgetc(file)) != EOF) {
/* Grow it */
if (++size == 1024) {
- pfile->source = (char *)mem_sys_realloc(pfile->source,
- (size_t)pfile->size + 1024);
+ pfile->source = gc_mem_realloc_n_typed(interp, pfile->source,
+ (size_t)pfile->size + 1024, char);
size = 0;
}
pfile->source[pfile->size] = (char)c;
@@ -3100,7 +3101,7 @@
if (c == '\n') {
/* If the line has an opcode move to the next one,
otherwise leave it with NULL to skip it. */
- PDB_line_t *newline = mem_allocate_zeroed_typed(PDB_line_t);
+ PDB_line_t *newline = gc_mem_allocate_zeroed_typed(interp, PDB_line_t);
if (PDB_hasinstruction(pfile->source + pline->source_offset)) {
size_t n = interp->op_info_table[*pc].op_count;
More information about the parrot-commits
mailing list