1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-03 06:29:36 +00:00

First version of a module that reads debug files generated by ld65.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4779 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2010-08-03 18:46:50 +00:00
parent e046ecbcf2
commit 54e22eb53c
4 changed files with 1735 additions and 0 deletions

1479
src/dbginfo/dbginfo.c Normal file

File diff suppressed because it is too large Load Diff

113
src/dbginfo/dbginfo.h Normal file
View File

@ -0,0 +1,113 @@
/*****************************************************************************/
/* */
/* dbginfo.h */
/* */
/* cc65 debug info handling */
/* */
/* */
/* */
/* (C) 2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#ifndef DBGINFO_H
#define DBGINFO_H
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Pointer to an opaque data structure containing information from the debug
* info file. Actually a handle to the data in the file.
*/
typedef void* cc65_dbginfo;
/* Warnings/errors in cc65_read_dbginfo are passed via this struct */
typedef struct cc65_parseerror cc65_parseerror;
struct cc65_parseerror {
unsigned type; /* 0 = warning, 1 = error */
const char* name; /* Name of input file */
unsigned long line; /* Error line */
unsigned column; /* Error column */
char errormsg[1]; /* Error message */
};
/* Function that is called in case of parse errors */
typedef void (*cc65_errorfunc) (const struct cc65_parseerror*);
/* File information */
typedef struct cc65_fileinfo cc65_fileinfo;
struct cc65_fileinfo {
char* name; /* Name of file with full path */
unsigned long size; /* Size of file */
unsigned long mtime; /* Modification time */
};
/* Line information */
typedef struct cc65_lineinfo cc65_lineinfo;
struct cc65_lineinfo {
unsigned count; /* Count of data sets that follow */
struct {
cc65_fileinfo* fileinfo; /* File information including name */
unsigned long line; /* Line number */
} data[1];
};
/*****************************************************************************/
/* Code */
/*****************************************************************************/
cc65_dbginfo cc65_read_dbginfo (const char* filename, cc65_errorfunc errorfunc);
/* Parse the debug info file with the given name. On success, the function
* will return a pointer to an opaque cc65_dbginfo structure, that must be
* passed to the other functions in this module to retrieve information.
* errorfunc is called in case of warnings and errors. If the file cannot be
* read successfully, NULL is returned.
*/
cc65_lineinfo* cc65_get_lineinfo (cc65_dbginfo handle, unsigned long addr);
/* Return line information for the given address */
void cc65_free_lineinfo (cc65_dbginfo handle, cc65_lineinfo* info);
/* Free line info returned by cc65_get_lineinfo() */
/* End of dbginfo.h */
#endif

85
src/dbginfo/dbgtest.c Normal file
View File

@ -0,0 +1,85 @@
/*****************************************************************************/
/* */
/* dbgtest.c */
/* */
/* Test file for the cc65 dbginfo module */
/* */
/* */
/* */
/* (C) 2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "dbginfo.h"
static void ErrorFunc (const struct cc65_parseerror* E)
/* Handle errors or warnings that occur while parsing a debug file */
{
fprintf (stderr,
"%s:%s(%lu): %s\n",
E->type? "Error" : "Warning",
E->name,
E->line,
E->errormsg);
}
static void Usage (void)
/* Print usage information and exit */
{
printf ("Usage: dbgtest debug-file\n");
exit (1);
}
int main (int argc, char** argv)
{
const char* Input;
cc65_dbginfo Handle;
/* Input file is argument */
if (argc != 2) {
Usage ();
}
Input = argv[1];
Handle = cc65_read_dbginfo (Input, ErrorFunc);
if (Handle == 0) {
fprintf (stderr, "No handle\n");
}
return 0;
}

58
src/dbginfo/make/gcc.mak Normal file
View File

@ -0,0 +1,58 @@
#
# Makefile for debug info test executable
#
# ------------------------------------------------------------------------------
# The executable to build
EXE = dbgtest
#
CC = gcc
CFLAGS = -O2 -g -Wall -W
EBIND = emxbind
LDFLAGS =
# ------------------------------------------------------------------------------
# Object files and libraries to link
OBJS = dbginfo.o \
dbgtest.o
# ------------------------------------------------------------------------------
# Makefile targets
# Main target - must be first
.PHONY: all
ifeq (.depend,$(wildcard .depend))
all: $(EXE)
include .depend
else
all: depend
@$(MAKE) -f make/gcc.mak all
endif
$(EXE): $(OBJS)
$(CC) $(OBJS) $(LDFLAGS) -o $@
@if [ $(OS2_SHELL) ] ; then $(EBIND) $(EXE) ; fi
clean:
$(RM) *~ core.* *.map
zap: clean
$(RM) $(OBJS) $(EXE) .depend
# ------------------------------------------------------------------------------
# Make the dependencies
.PHONY: depend dep
depend dep: $(OBJS:.o=.c)
@echo "Creating dependency information"
$(CC) -I$(COMMON) -MM $^ > .depend