Skip to content

Commit

Permalink
Added a few hbdb types necessary for breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
soh-cah-toa committed May 27, 2011
1 parent 7e90c71 commit fe34052
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config/gen/makefiles/root.in
Expand Up @@ -1041,13 +1041,14 @@ $(INSTALLABLEPROVE) : parrot-prove.pbc $(PBC_TO_EXE) src/install_config$(O)
$(PBC_TO_EXE) parrot-prove.pbc --install

#
# Parrot Debugger
# Honey Bee Debugger (hbdb)
#

frontend/hbdb/main$(O) : \
$(PARROT_H_HEADERS) \
frontend/hbdb/main.c \
$(INC_DIR)/api.h
$(INC_DIR)/api.h \
$(INC_DIR)/hbdb.h

$(HBDB) : frontend/hbdb/main$(O) src/parrot_config$(O) $(LIBPARROT)
$(LINK) @ld_out@$@ \
Expand Down
7 changes: 7 additions & 0 deletions frontend/hbdb/main.c
Expand Up @@ -2,6 +2,7 @@

#include <stdio.h>
#include <stdlib.h>
#include "parrot/hbdb.h"
#include "parrot/api.h"

/* TODO Check for command line arguments */
Expand Down Expand Up @@ -50,6 +51,12 @@ main(int argc, char *argv[])
fail("Failed to prepare bytecode");
}

/* Run bytecode */
if (!Parrot_api_run_bytecode(interp, pbc, NULL)) {
Parrot_api_destroy_interpreter(interp);
fail("Failed to run bytecode");
}

/* DEBUG */
printf("Reached line %d\n", __LINE__);
/* DEBUG */
Expand Down
81 changes: 81 additions & 0 deletions include/parrot/hbdb.h
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2002-2009, Parrot Foundation.
*
* hbdb.h
*
* Overview:
* Honey bee debugger (hbdb) types and function declarations
*/

#ifndef PARROT_HBDB_H_GUARD
#define PARROT_HBDB_H_GUARD

#include <stdio.h>

/* Type: hbdb_breakpoint_t
*
* Fields:
* id - identification number
* pc - address of opcode to break at
* line - line number in source file
* skip - number of times to skip breakpoint
* condition - condition attached to breakpoint
* prev - previous breakpoint in the list
* next - next breakpoint in the list
*
* Node type in linked list of breakpoints.
*/

typedef struct hbdb_breakpoint {
unsigned long id;
opcode_t *pc;
unsigned long line;
long skip;
/*hbdb_condition_t *condition;*/
hbdb_breakpoint *prev;
hbdb_breakpoint *next;
} hbdb_breakpoint_t;

/* Type: hbdb_t
*
* Fields:
* file - source code file
* breakpoint - first breakpoint in list
* watchpoint - first watchpoint
* breakpoint_skip - number of breakpoints to skip
* current_command - command being executed
* last_command - last command executed
* current_opcode - current opcode
* state - status of the program being debugged
* debugee - interpreter we are debugging
* debugger - debugger interpreter
*
* The debugger's core type. Contains information that's used by the hbdb
* runcore.
*/

typedef struct {
/*hbdb_file_t *file;*/
hbdb_breakpoint_t *breakpoint;
/*hbdb_condition_t *watchpoint;*/
unsigned long breakpoint_skip;
char *current_command;
char *last_command;
opcode_t *current_opcode;
int state;
/*Interp *debugee;*/
/*Interp *debugger;*/
unsigned long tracing;
FILE *script_file;
unsigned long script_line;
} hbdb_t;

#endif /* PARROT_HBDB_H_GUARD */

/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
*/

2 changes: 2 additions & 0 deletions include/parrot/interpreter.h
Expand Up @@ -198,7 +198,9 @@ struct parrot_interp_t {

Hash *op_hash; /* mapping from op names to op_info_t */

/* TODO Remove PDB_t? */
PDB_t *pdb; /* debug /trace system */
hbdb_t hbdb; /* hbdb debugger */

void *lo_var_ptr; /* Pointer to memory on runops
* system stack */
Expand Down

0 comments on commit fe34052

Please sign in to comment.