* listing.c, config/obj-aout.c: added intermixed

source/assembler file listings to files with stabs in them.
This commit is contained in:
Steve Chamberlain 1992-01-25 00:51:20 +00:00
parent ac5939079f
commit b3ca913f74
2 changed files with 148 additions and 44 deletions

View File

@ -1,3 +1,8 @@
Fri Jan 24 16:48:32 1992 Steve Chamberlain (sac at rtl.cygnus.com)
* listing.c, config/obj-aout.c: added intermixed
source/assembler file listings to files with stabs in them.
Thu Jan 23 17:30:08 1992 Steve Chamberlain (sac at rtl.cygnus.com) Thu Jan 23 17:30:08 1992 Steve Chamberlain (sac at rtl.cygnus.com)
* symbols.c(colon): if a symbol is being multiply defined as exactly * symbols.c(colon): if a symbol is being multiply defined as exactly

View File

@ -119,7 +119,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This structure remembers which files were used */ /* This structure remembers which .s were used */
typedef struct file_info_struct typedef struct file_info_struct
{ {
char *filename; char *filename;
@ -145,6 +145,14 @@ typedef struct list_info_struct
struct list_info_struct *next; struct list_info_struct *next;
/* Pointer to the file info struct for the high level language
source line that belongs here */
file_info_type *hll_file;
/* High level language source line */
unsigned int hll_line;
/* Pointer to any error message associated with this line */ /* Pointer to any error message associated with this line */
char *message; char *message;
@ -218,11 +226,12 @@ DEFUN(listing_error,(message),
extern char *file_name;
static file_info_type *file_info_head; static file_info_type *file_info_head;
static file_info_type * static file_info_type *
DEFUN_VOID(file_info) DEFUN(file_info, (file_name),
char *file_name)
{ {
/* Find an entry with this file name */ /* Find an entry with this file name */
file_info_type *p = file_info_head; file_info_type *p = file_info_head;
@ -248,12 +257,21 @@ DEFUN_VOID(file_info)
} }
static void
DEFUN_VOID(new_frag)
{
frag_wane(frag_now);
frag_new(0);
}
void void
DEFUN(listing_newline,(ps), DEFUN(listing_newline,(ps),
char *ps) char *ps)
{ {
char *s = ps; char *s = ps;
extern char *file_name;
static unsigned int last_line =0xffff ; static unsigned int last_line =0xffff ;
@ -261,12 +279,12 @@ DEFUN(listing_newline,(ps),
if (physical_input_line != last_line) if (physical_input_line != last_line)
{ {
last_line = physical_input_line; last_line = physical_input_line;
frag_wane(frag_now); new_frag();
frag_new(0);
new = (list_info_type *)malloc(sizeof(list_info_type)); new = (list_info_type *)malloc(sizeof(list_info_type));
new->frag = frag_now; new->frag = frag_now;
new->line = physical_input_line ; new->line = physical_input_line ;
new->file = file_info(); new->file = file_info(file_name);
if (listing_tail) if (listing_tail)
{ {
@ -280,8 +298,7 @@ DEFUN(listing_newline,(ps),
new->next = (list_info_type *)NULL; new->next = (list_info_type *)NULL;
new->message = (char *)NULL; new->message = (char *)NULL;
new->edict = EDICT_NONE; new->edict = EDICT_NONE;
frag_wane(frag_now); new_frag();
frag_new(0);
} }
} }
@ -289,14 +306,21 @@ DEFUN(listing_newline,(ps),
static char * static char *
DEFUN(buffer_line,(ptr,line, size), DEFUN(buffer_line,(file, line, size),
list_info_type *ptr AND file_info_type *file AND
char *line AND char *line AND
unsigned int size) unsigned int size)
{ {
unsigned int count = 0; unsigned int count = 0;
int c;
char *p = line; char *p = line;
int c = fgetc(ptr->file->file); if (file->file == (FILE*)NULL)
{
return "";
}
c = fgetc(file->file);
size -= 1; /* leave room for null */ size -= 1; /* leave room for null */
while (c != EOF && c != '\n') while (c != EOF && c != '\n')
{ {
@ -304,13 +328,15 @@ DEFUN(buffer_line,(ptr,line, size),
*p++ = c; *p++ = c;
count++; count++;
c= fgetc(ptr->file->file); c= fgetc(file->file);
} }
if (c == EOF) if (c == EOF)
{ {
rewind(ptr->file->file); rewind(file->file);
file->linenum = 0;
} }
file->linenum++;
*p++ = 0; *p++ = 0;
return line; return line;
} }
@ -575,22 +601,44 @@ DEFUN_VOID(list_symbol_table)
for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr)) for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr))
{ {
if (ptr->sy_frag->line == 0) if (strlen(S_GET_NAME(ptr)) != 0)
{ {
if (ptr->sy_frag->line == 0)
{
printf("%s\n", S_GET_NAME(ptr)); printf("%s\n", S_GET_NAME(ptr));
on_page++; on_page++;
listing_page(0); listing_page(0);
}
} }
} }
} }
void
DEFUN(print_source,(current_file, list, buffer, width),
file_info_type *current_file AND
list_info_type *list AND
char *buffer AND
unsigned int width)
{
if (current_file->file) {
while (current_file->linenum < list->hll_line)
{
char* p = buffer_line(current_file, buffer, width);
printf("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p);
on_page++;
listing_page(list);
}
}
}
void void
DEFUN(listing_listing,(name), DEFUN(listing_listing,(name),
char *name) char *name)
{ {
list_info_type *list = head; list_info_type *list = head;
file_info_type *current_hll_file = (file_info_type *)NULL;
unsigned int page= 1; unsigned int page= 1;
unsigned int prev = 0; unsigned int prev = 0;
char *message; char *message;
@ -599,7 +647,8 @@ DEFUN(listing_listing,(name),
unsigned int addr = 0; unsigned int addr = 0;
int on_page = 0; int on_page = 0;
int show_listing = 1; int show_listing = 1;
unsigned int width;
buffer = malloc(LISTING_RHS_WIDTH); buffer = malloc(LISTING_RHS_WIDTH);
eject = 1; eject = 1;
list = head; list = head;
@ -617,29 +666,29 @@ DEFUN(listing_listing,(name),
while ( list) while ( list)
{ {
p = buffer_line(list, buffer, LISTING_RHS_WIDTH > paper_width ? width = LISTING_RHS_WIDTH > paper_width ? paper_width :
paper_width : LISTING_RHS_WIDTH); LISTING_RHS_WIDTH;
switch (list->edict) { switch (list->edict) {
case EDICT_LIST: case EDICT_LIST:
show_listing++; show_listing++;
break; break;
case EDICT_NOLIST: case EDICT_NOLIST:
show_listing--; show_listing--;
break; break;
case EDICT_EJECT: case EDICT_EJECT:
break; break;
case EDICT_NONE: case EDICT_NONE:
break; break;
case EDICT_TITLE: case EDICT_TITLE:
title = list->edict_arg; title = list->edict_arg;
break; break;
case EDICT_SBTTL: case EDICT_SBTTL:
subtitle = list->edict_arg; subtitle = list->edict_arg;
break; break;
default: default:
abort(); abort();
} }
if (show_listing > 0) if (show_listing > 0)
{ {
@ -647,6 +696,17 @@ DEFUN(listing_listing,(name),
with this line (or lines) */ with this line (or lines) */
message = 0; message = 0;
if (list->hll_file)
{
current_hll_file = list->hll_file;
}
if (current_hll_file && list->hll_line && listing & LISTING_HLL)
{
print_source(current_hll_file, list, buffer, width);
}
p = buffer_line(list->file, buffer, width);
print_lines(list, p, calc_hex(list)); print_lines(list, p, calc_hex(list));
@ -655,6 +715,12 @@ DEFUN(listing_listing,(name),
eject = 1; eject = 1;
} }
} }
else
{
p = buffer_line(list->file, buffer, width);
}
list = list->next; list = list->next;
} }
free(buffer); free(buffer);
@ -774,6 +840,26 @@ DEFUN(listing_title,(depth),
} }
void
DEFUN(listing_source_line,(line),
unsigned int line)
{
new_frag();
listing_tail->hll_line = line;
new_frag();
}
void
DEFUN(listing_source_file,(file),
char *file)
{
listing_tail->hll_file = file_info(file);
}
#else #else
@ -817,5 +903,18 @@ char *name)
} }
void DEFUN(listing_source_line,(n),
unsigned int n)
{
}
void DEFUN(listing_source_file, (n),
char *n)
{
}
#endif #endif