18 #include "be_dbgout.h"
23 N_GSYM = 32, /**< global symbol */
24 N_FUN = 36, /**< procedure */
25 N_STSYM = 38, /**< Initialized static variable */
26 N_LCSYM = 40, /**< uninitialized static var */
27 N_RSYM = 64, /**< global register variable */
29 N_SO = 100, /**< name and path of the source file */
30 N_LSYM = 128, /**< local symbol */
31 N_PSYM = 160, /**< parameters to a function */
32 N_LBRAC = 192, /**< left brace */
33 N_RBRAC = 224, /**< right brace */
39 typedef struct stabs_handle {
40 dbg_handle base; /**< the base class */
41 FILE *f; /**< the file write to */
46 * Returns the stabs type number of a Firm type.
48 static unsigned get_type_number(ir_type *tp) {
50 } /* get_type_number */
55 static void stabs_begin(dbg_handle *handle, const char *filename) {
56 stabs_handle *h = (stabs_handle *)handle;
57 fprintf(h->f, ".stabs \"%s\",%d,0,0,.Ltext0\n", filename, N_SO);
61 * prints a line number
63 static void stabs_line(dbg_handle *handle, unsigned lineno, const char *address) {
64 stabs_handle *h = (stabs_handle *)handle;
65 fprintf(h->f, ".stabn %d, 0, %u, %s-%s\n", N_SLINE, lineno, address, get_entity_ld_name(h->cur_ent));
69 * prints the stabs for a function
71 static void stabs_method(dbg_handle *handle, entity *ent) {
72 stabs_handle *h = (stabs_handle *)handle;
78 tp = get_entity_type(ent);
79 if (get_method_n_ress(tp) > 0)
80 tp = get_method_res_type(tp, 0);
83 type_num = get_type_number(tp);
84 fprintf(h->f, ".stabs \"%s:%c%u\",%u,0,0,%s\n",
86 get_entity_visibility(ent) == visibility_external_visible ? 'F' : 'f',
89 get_entity_ld_name(ent));
92 /* close the stabs handler */
93 static void stabs_close(dbg_handle *handle) {
94 stabs_handle *h = (stabs_handle *)handle;
98 /** The stabs operations. */
99 static const debug_ops stabs_ops = {
106 /* Opens a stabs handler */
107 dbg_handle *be_stabs_open(FILE *out) {
108 stabs_handle *h = xmalloc(sizeof(*h));
110 h->base.ops = &stabs_ops;
115 /** close a debug handler. */
116 void be_dbg_close(dbg_handle *h) {
124 void be_dbg_begin(dbg_handle *h, const char *filename) {
126 h->ops->begin(h, filename);
129 /** debug for a function */
130 void be_dbg_method(dbg_handle *h, entity *ent) {
132 h->ops->method(h, ent);
133 } /* be_dbg_method */
135 /** debug for line number */
136 void be_dbg_line(dbg_handle *h, unsigned lineno, const char *address) {
138 h->ops->line(h, lineno, address);