-/**
- * prints a line number
- */
-static void stabs_line(dbg_handle *handle, unsigned lineno, const char *address) {
- stabs_handle *h = (stabs_handle *)handle;
- fprintf(h->f, "\t.stabn\t%d, 0, %u, %s-%s\n", N_SLINE, lineno, address, get_entity_ld_name(h->cur_ent));
-} /* stabs_line */
+static void stabs_set_dbg_info(dbg_handle *h, dbg_info *dbgi)
+{
+ stabs_handle *handle = (stabs_handle*) h;
+ unsigned lineno;
+ const char *fname = ir_retrieve_dbg_info(dbgi, &lineno);
+
+ if (fname == NULL)
+ return;
+
+ if (handle->curr_file != fname) {
+ /* TODO: escape filename correctly */
+ if (handle->curr_file != handle->main_file) {
+ be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,0\n", handle->curr_file,
+ N_EINCL);
+ be_emit_write_line();
+ }
+ if (fname != handle->main_file) {
+ be_emit_irprintf("\t.stabs\t\"%s\",%d,0,0,0\n", fname, N_SOL);
+ be_emit_write_line();
+ }
+ handle->curr_file = fname;
+ }
+ if (handle->last_line != lineno) {
+ char label[64];
+
+ snprintf(label, sizeof(label), ".LM%u", ++handle->label_num);
+ handle->last_line = lineno;
+
+ be_emit_irprintf("\t.stabn\t%d, 0, %u, %s-%s\n", N_SLINE, lineno,
+ label, get_entity_ld_name(handle->cur_ent));
+ be_emit_write_line();
+
+ be_emit_string(label);
+ be_emit_cstring(":\n");
+ be_emit_write_line();
+ }
+}