#include "bemodule.h"
#include "beemitter.h"
#include "dbginfo.h"
+#include "begnuas.h"
/* Non-Stab Symbol and Stab Symbol Types */
enum stabs_types {
*/
typedef struct stabs_handle {
dbg_handle base; /**< the base class */
- ir_entity *cur_ent; /**< current method entity */
+ const ir_entity *cur_ent; /**< current method entity */
const be_stack_layout_t *layout; /**< current stack layout */
unsigned next_type_nr; /**< next type number */
pmap *type_map; /**< a map from type to type number */
/**
* Returns the stabs type number of a Firm type.
*/
-static unsigned get_type_number(stabs_handle *h, ir_type *tp) {
+static unsigned get_type_number(stabs_handle *h, ir_type *tp)
+{
pmap_entry *entry;
unsigned num;
/**
* Map a given Type to void by assigned the type number 0.
*/
-static void map_to_void(stabs_handle *h, ir_type *tp) {
+static void map_to_void(stabs_handle *h, ir_type *tp)
+{
pmap_insert(h->type_map, tp, INT_TO_PTR(0));
}
/**
* generate the void type.
*/
-static void gen_void_type(stabs_handle *h) {
+static void gen_void_type(stabs_handle *h)
+{
(void) h;
be_emit_irprintf("\t.stabs\t\"void:t%u=%u\",%d,0,0,0\n", 0, 0, N_LSYM);
be_emit_write_line();
do { \
set_type_link(tp, (void *)1); \
waitq_put(wq, tp); \
- } while(0)
+ } while (0)
/* a the is ready */
#define SET_TYPE_READY(tp) set_type_link(tp, NULL)
/**
* emit a tarval as decimal
*/
-static void be_emit_tv_as_decimal(tarval *tv) {
+static void be_emit_tv_as_decimal(tarval *tv)
+{
ir_mode *mode = get_tarval_mode(tv);
const tarval_mode_info *old = get_tarval_mode_output_option(mode);
static void emit_type_name(const ir_type *type)
{
+ char *c;
char buf[256];
ir_print_type(buf, sizeof(buf), type);
+ /* replace special chars to be on the safe side */
+ for (c = buf; *c != '\0'; ++c) {
+ if (*c == '\n' || *c == '"' || *c == '\\')
+ *c = '?';
+ }
be_emit_string(buf);
}
* @param h the stabs handle
* @param tp the type
*/
-static void gen_primitive_type(stabs_handle *h, ir_type *tp) {
+static void gen_primitive_type(stabs_handle *h, ir_type *tp)
+{
ir_mode *mode = get_type_mode(tp);
unsigned type_num;
* @param h the stabs handle
* @param tp the type
*/
-static void gen_enum_type(stabs_handle *h, ir_type *tp) {
+static void gen_enum_type(stabs_handle *h, ir_type *tp)
+{
unsigned type_num = get_type_number(h, tp);
int i, n;
/**
* print a pointer type
*/
-void print_pointer_type(stabs_handle *h, ir_type *tp, int local) {
+static void print_pointer_type(stabs_handle *h, ir_type *tp, int local)
+{
unsigned type_num = local ? h->next_type_nr++ : get_type_number(h, tp);
ir_type *el_tp = get_pointer_points_to_type(tp);
unsigned el_num = get_type_number(h, el_tp);
* @param env the walker environment
* @param tp the type
*/
-static void gen_pointer_type(wenv_t *env, ir_type *tp) {
+static void gen_pointer_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
ir_type *el_tp = get_pointer_points_to_type(tp);
/**
* print an array type
*/
-static void print_array_type(stabs_handle *h, ir_type *tp, int local) {
+static void print_array_type(stabs_handle *h, ir_type *tp, int local)
+{
ir_type *etp = get_array_element_type(tp);
int i, n = get_array_n_dimensions(tp);
unsigned type_num = local ? h->next_type_nr++ : get_type_number(h, tp);
* @param env the walker environment
* @param tp the type
*/
-static void gen_array_type(wenv_t *env, ir_type *tp) {
+static void gen_array_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
ir_type *etp = get_array_element_type(tp);
* @param env the walker environment
* @param tp the type
*/
-static void gen_struct_union_type(wenv_t *env, ir_type *tp) {
+static void gen_struct_union_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
unsigned type_num = get_type_number(h, tp);
int i, n;
* @param env the walker environment
* @param tp the type
*/
-static void gen_method_type(wenv_t *env, ir_type *tp) {
+static void gen_method_type(wenv_t *env, ir_type *tp)
+{
stabs_handle *h = env->h;
unsigned type_num = get_type_number(h, tp);
ir_type *rtp = NULL;
/**
* generate all types.
*/
-static void gen_types(stabs_handle *h) {
+static void gen_types(stabs_handle *h)
+{
wenv_t env;
env.h = h;
/**
* start a new source object (compilation unit)
*/
-static void stabs_so(dbg_handle *handle, const char *filename) {
+static void stabs_so(dbg_handle *handle, const char *filename)
+{
stabs_handle *h = (stabs_handle *)handle;
h->main_file = h->curr_file = filename;
- be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,.Ltext0\n", filename, N_SO);
+ be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,%stext0\n", filename, N_SO, be_gas_get_private_prefix());
be_emit_write_line();
} /* stabs_so */
/**
* Main Program
*/
-static void stabs_main_program(dbg_handle *handle) {
+static void stabs_main_program(dbg_handle *handle)
+{
ir_graph *irg = get_irp_main_irg();
(void) handle;
/**
* dump the stabs for a method begin
*/
-static void stabs_method_begin(dbg_handle *handle, ir_entity *ent, const be_stack_layout_t *layout)
+static void stabs_method_begin(dbg_handle *handle, const ir_entity *ent)
{
stabs_handle *h = (stabs_handle *)handle;
+ ir_graph *irg = get_entity_irg(ent);
ir_type *mtp, *rtp;
unsigned type_num;
int i, n, between_size;
+ be_stack_layout_t *layout = be_get_irg_stack_layout(irg);
h->cur_ent = ent;
h->layout = layout;
/**
* dump the stabs for a method end
*/
-static void stabs_method_end(dbg_handle *handle) {
+static void stabs_method_end(dbg_handle *handle)
+{
stabs_handle *h = (stabs_handle *)handle;
- ir_entity *ent = h->cur_ent;
+ const ir_entity *ent = h->cur_ent;
const be_stack_layout_t *layout = h->layout;
const char *ld_name = get_entity_ld_name(ent);
int i, n, frame_size;
/**
* dump types
*/
-static void stabs_types(dbg_handle *handle) {
+static void stabs_types(dbg_handle *handle)
+{
stabs_handle *h = (stabs_handle *)handle;
/* allocate the zero for the void type */
/**
* dump a variable in the global type
*/
-static void stabs_variable(dbg_handle *handle, ir_entity *ent) {
+static void stabs_variable(dbg_handle *handle, const ir_entity *ent)
+{
stabs_handle *h = (stabs_handle *)handle;
unsigned tp_num = get_type_number(h, get_entity_type(ent));
char buf[1024];
/**
* Close the stabs handler.
*/
-static void stabs_close(dbg_handle *handle) {
+static void stabs_close(dbg_handle *handle)
+{
stabs_handle *h = (stabs_handle *)handle;
pmap_destroy(h->type_map);
free(h);
};
/* Opens a stabs handler */
-dbg_handle *be_stabs_open(void) {
+static dbg_handle *be_stabs_open(void)
+{
stabs_handle *h = XMALLOCZ(stabs_handle);
h->base.ops = &stabs_ops;
return &h->base;
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_stabs);
void be_init_stabs(void)
{
be_register_dbgout_module("stabs", be_stabs_open);
}
-
-BE_REGISTER_MODULE_CONSTRUCTOR(be_init_stabs);