Line 25... |
Line 25... |
#include <stdio.h>
|
#include <stdio.h>
|
#include <ctype.h>
|
#include <ctype.h>
|
#include <string.h>
|
#include <string.h>
|
|
|
#include "config.h"
|
#include "config.h"
|
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
#include <inttypes.h>
|
|
#endif
|
|
|
|
#include "port.h"
|
|
#include "config.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
|
|
|
#include "arch.h"
|
#include "labels.h"
|
#include "labels.h"
|
|
|
static struct label_entry *label_hash[LABELS_HASH_SIZE];
|
static struct label_entry *label_hash[LABELS_HASH_SIZE];
|
struct breakpoint_entry *breakpoints;
|
struct breakpoint_entry *breakpoints;
|
|
|
Line 38... |
Line 46... |
int i;
|
int i;
|
for (i = 0; i < LABELS_HASH_SIZE; i++)
|
for (i = 0; i < LABELS_HASH_SIZE; i++)
|
label_hash[i] = NULL;
|
label_hash[i] = NULL;
|
}
|
}
|
|
|
void add_label (unsigned long addr, char *name) {
|
void add_label (oraddr_t addr, char *name) {
|
struct label_entry **tmp;
|
struct label_entry **tmp;
|
tmp = &(label_hash[addr % LABELS_HASH_SIZE]);
|
tmp = &(label_hash[addr % LABELS_HASH_SIZE]);
|
for (; *tmp; tmp = &((*tmp)->next));
|
for (; *tmp; tmp = &((*tmp)->next));
|
*tmp = malloc(sizeof(**tmp));
|
*tmp = malloc(sizeof(**tmp));
|
(*tmp)->name = malloc(strlen(name) + 1);
|
(*tmp)->name = malloc(strlen(name) + 1);
|
(*tmp)->addr = addr;
|
(*tmp)->addr = addr;
|
strcpy((*tmp)->name, name);
|
strcpy((*tmp)->name, name);
|
(*tmp)->next = NULL;
|
(*tmp)->next = NULL;
|
}
|
}
|
|
|
struct label_entry *get_label (unsigned long addr) {
|
struct label_entry *get_label (oraddr_t addr) {
|
struct label_entry *tmp = label_hash[addr % LABELS_HASH_SIZE];
|
struct label_entry *tmp = label_hash[addr % LABELS_HASH_SIZE];
|
while (tmp) {
|
while (tmp) {
|
if (tmp->addr == addr)
|
if (tmp->addr == addr)
|
return tmp;
|
return tmp;
|
tmp = tmp->next;
|
tmp = tmp->next;
|
Line 74... |
Line 82... |
return NULL;
|
return NULL;
|
}
|
}
|
|
|
/* Searches mem array for a particular label and returns label's address.
|
/* Searches mem array for a particular label and returns label's address.
|
If label does not exist, returns 0. */
|
If label does not exist, returns 0. */
|
unsigned long eval_label (char *name) {
|
oraddr_t eval_label (char *name) {
|
struct label_entry *le;
|
struct label_entry *le;
|
char *plus;
|
char *plus;
|
char *minus;
|
char *minus;
|
int positive_offset = 0;
|
int positive_offset = 0;
|
int negative_offset = 0;
|
int negative_offset = 0;
|
Line 101... |
Line 109... |
|
|
void init_breakpoints () {
|
void init_breakpoints () {
|
breakpoints = 0;
|
breakpoints = 0;
|
}
|
}
|
|
|
void add_breakpoint (unsigned long addr) {
|
void add_breakpoint (oraddr_t addr) {
|
struct breakpoint_entry *tmp;
|
struct breakpoint_entry *tmp;
|
tmp = (struct breakpoint_entry *) malloc (sizeof (struct breakpoint_entry));
|
tmp = (struct breakpoint_entry *) malloc (sizeof (struct breakpoint_entry));
|
tmp->next = breakpoints;
|
tmp->next = breakpoints;
|
tmp->addr = addr;
|
tmp->addr = addr;
|
breakpoints = tmp;
|
breakpoints = tmp;
|
}
|
}
|
|
|
void remove_breakpoint (unsigned long addr) {
|
void remove_breakpoint (oraddr_t addr) {
|
struct breakpoint_entry **tmp = &breakpoints;
|
struct breakpoint_entry **tmp = &breakpoints;
|
while (*tmp) {
|
while (*tmp) {
|
if ((*tmp)->addr == addr) {
|
if ((*tmp)->addr == addr) {
|
struct breakpoint_entry *t = *tmp;
|
struct breakpoint_entry *t = *tmp;
|
(*tmp) = t->next;
|
(*tmp) = t->next;
|
Line 126... |
Line 134... |
void print_breakpoints () {
|
void print_breakpoints () {
|
struct breakpoint_entry **tmp = &breakpoints;
|
struct breakpoint_entry **tmp = &breakpoints;
|
int i = 1;
|
int i = 1;
|
printf ("---[breakpoints]------------------\n");
|
printf ("---[breakpoints]------------------\n");
|
while (*tmp) {
|
while (*tmp) {
|
printf ("Breakpoint %i at 0x%08lX\n", i, (*tmp)->addr);
|
printf ("Breakpoint %i at 0x%"PRIxADDR"\n", i, (*tmp)->addr);
|
tmp = &((*tmp)->next);
|
tmp = &((*tmp)->next);
|
}
|
}
|
printf ("---[breakpoints end]--------------\n");
|
printf ("---[breakpoints end]--------------\n");
|
}
|
}
|
|
|
inline int has_breakpoint (unsigned long addr) {
|
inline int has_breakpoint (oraddr_t addr) {
|
struct breakpoint_entry *tmp = breakpoints;
|
struct breakpoint_entry *tmp = breakpoints;
|
while (tmp) {
|
while (tmp) {
|
if (tmp->addr == addr)
|
if (tmp->addr == addr)
|
return 1;
|
return 1;
|
tmp = tmp->next;
|
tmp = tmp->next;
|