[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/ildb ildb_context.c,1.6,1.7 ildb_context
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/ildb ildb_context.c,1.6,1.7 ildb_context.h,1.6,1.7 ildb_list.c,1.3,1.4 ildb_search.c,1.2,1.3 ildb_source.c,1.2,1.3 ildb_source.h,1.2,1.3 |
Date: |
Fri, 22 Nov 2002 01:12:51 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/ildb
In directory subversions:/tmp/cvs-serv24662/ildb
Modified Files:
ildb_context.c ildb_context.h ildb_list.c ildb_search.c
ildb_source.c ildb_source.h
Log Message:
Load source files correctly into the debugger; use EXINIT for
the tab stop specification in "list" commands.
Index: ildb_context.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildb/ildb_context.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** ildb_context.c 26 Jun 2002 03:10:46 -0000 1.6
--- ildb_context.c 22 Nov 2002 06:12:47 -0000 1.7
***************
*** 33,36 ****
--- 33,37 ----
{
ILDb *db;
+ char *env;
/* Initialize the runtime engine's global data */
***************
*** 58,61 ****
--- 59,63 ----
db->currFile = 0;
db->currLine = 1;
+ db->tabStops = 8;
/* Set the initial source directory search path */
***************
*** 72,75 ****
--- 74,89 ----
ILDbRegisterCommands(db, ILDbSetCommands, ILDbNumSetCommands);
ILDbRegisterCommands(db, ILDbHelpCommands, ILDbNumHelpCommands);
+
+ /* Change the tab stop setting if EXINIT has "ts=4" in it */
+ env = getenv("EXINIT");
+ while(env != 0 && *env != '\0')
+ {
+ if(!strncmp(env, "ts=4", 4) && (env[4] == '\0' || env[4] == '
'))
+ {
+ db->tabStops = 4;
+ break;
+ }
+ ++env;
+ }
/* Return the context to the caller */
Index: ildb_context.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildb/ildb_context.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** ildb_context.h 26 Jun 2002 03:10:46 -0000 1.6
--- ildb_context.h 22 Nov 2002 06:12:47 -0000 1.7
***************
*** 60,63 ****
--- 60,64 ----
struct _tagILDbSourceFile *currFile; /* Current source file */
long currLine; /* Current
source line */
+ int tabStops; /* Size
of tabs in file listings */
} ILDb;
Index: ildb_list.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildb/ildb_list.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** ildb_list.c 26 Jun 2002 03:10:46 -0000 1.3
--- ildb_list.c 22 Nov 2002 06:12:47 -0000 1.4
***************
*** 36,39 ****
--- 36,40 ----
char *line;
long len;
+ int posn;
while(first <= last)
{
***************
*** 44,48 ****
}
printf("%-7ld\t", first);
! fwrite(line, 1, len, stdout);
putc('\n', stdout);
++first;
--- 45,68 ----
}
printf("%-7ld\t", first);
! posn = 0;
! while(len > 0)
! {
! if(*line == '\t')
! {
! do
! {
! putc(' ', stdout);
! ++posn;
! }
! while((posn % db->tabStops) != 0);
! }
! else
! {
! putc(*line, stdout);
! ++posn;
! }
! ++line;
! --len;
! }
putc('\n', stdout);
++first;
***************
*** 57,60 ****
--- 77,82 ----
{
ILDbSourceFile *file;
+ long line, firstLine;
+
if(!strcmp(args, ",main"))
{
***************
*** 63,72 ****
{
file = ILDbSourceGet(db, (ILClass *)0,
! (ILMember
*)(db->entryPoint));
if(file)
{
! ShowLines(db, file, 1, file->numLines);
! db->currFile = file;
! db->currLine = file->numLines;
return;
}
--- 85,107 ----
{
file = ILDbSourceGet(db, (ILClass *)0,
! (ILMember
*)(db->entryPoint), &line);
if(file)
{
! if(line > 0)
! {
! firstLine = line - (long)(db->listSize)
+ 1;
! if(firstLine < 1)
! {
! firstLine = 1;
! }
! ShowLines(db, file, firstLine, line);
! db->currFile = file;
! db->currLine = line;
! }
! else
! {
! db->currFile = file;
! db->currLine = 1;
! }
return;
}
Index: ildb_search.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildb/ildb_search.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ildb_search.c 25 Jun 2002 11:51:12 -0000 1.2
--- ildb_search.c 22 Nov 2002 06:12:47 -0000 1.3
***************
*** 140,146 ****
}
char *ILDbSearchFind(ILDb *db, const char *filename)
{
! /* TODO */
return 0;
}
--- 140,282 ----
}
+ /*
+ * Find a relative file within a specific directory.
+ */
+ static char *FindInDirectory(ILDb *db, const char *dir, int dirlen,
+ const char *filename,
const char *basename)
+ {
+ char *path;
+ char *result;
+
+ /* Try the full relative filename */
+ path = (char *)ILMalloc(dirlen + strlen(filename) + 2);
+ if(!path)
+ {
+ ILDbOutOfMemory(db);
+ }
+ strncpy(path, dir, dirlen);
+ path[dirlen] = '/';
+ strcpy(path + dirlen + 1, filename);
+ if(ILFileExists(path, (char **)0))
+ {
+ result = ILExpandFilename(path, (char *)0);
+ if(!result)
+ {
+ ILDbOutOfMemory(db);
+ }
+ ILFree(path);
+ return result;
+ }
+ ILFree(path);
+
+ /* Try the base name also */
+ if(basename != filename)
+ {
+ path = (char *)ILMalloc(dirlen + strlen(basename) + 2);
+ if(!path)
+ {
+ ILDbOutOfMemory(db);
+ }
+ strncpy(path, dir, dirlen);
+ path[dirlen] = '/';
+ strcpy(path + dirlen + 1, basename);
+ if(ILFileExists(path, (char **)0))
+ {
+ result = ILExpandFilename(path, (char *)0);
+ if(!result)
+ {
+ ILDbOutOfMemory(db);
+ }
+ ILFree(path);
+ return result;
+ }
+ ILFree(path);
+ }
+
+ /* We were unable to locate the file */
+ return 0;
+ }
+
char *ILDbSearchFind(ILDb *db, const char *filename)
{
! int len, dir;
! const char *basename;
! char *result;
!
! /* Strip the filename down to its base name */
! len = strlen(filename);
! while(len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\')
! {
! --len;
! }
! basename = filename + len;
!
! /* If the filename is absolute, then try using it directly.
! Otherwise strip it down to its base name */
! if(filename[0] == '/')
! {
! if(ILFileExists(filename, (char **)0))
! {
! result = ILExpandFilename(filename, (char *)0);
! if(!result)
! {
! ILDbOutOfMemory(db);
! }
! return result;
! }
! filename = basename;
! }
!
! /* Search the specified path */
! for(dir = db->dirSearchNum - 1; dir >= 0; --dir)
! {
! if(!strcmp(db->dirSearch[dir], "$cdir") && db->debugProgram)
! {
! /* Search the directory containing the executable */
! len = strlen(db->debugProgram);
! while(len > 0 && db->debugProgram[len - 1] != '/' &&
! db->debugProgram[len - 1] != '\\')
! {
! --len;
! }
! if(len > 0)
! {
! result = FindInDirectory(db, db->debugProgram,
len - 1,
!
filename, basename);
! if(result)
! {
! return result;
! }
! }
! else
! {
! result = FindInDirectory(db, ".", 1, filename,
basename);
! if(result)
! {
! return result;
! }
! }
! }
! else if(!strcmp(db->dirSearch[dir], "$cwd"))
! {
! /* Search the current working directory */
! result = FindInDirectory(db, ".", 1, filename,
basename);
! if(result)
! {
! return result;
! }
! }
! else
! {
! /* Search some other directory */
! result = FindInDirectory(db, db->dirSearch[dir],
!
strlen(db->dirSearch[dir]),
!
filename, basename);
! if(result)
! {
! return result;
! }
! }
! }
return 0;
}
Index: ildb_source.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildb/ildb_source.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ildb_source.c 26 Jun 2002 03:10:46 -0000 1.2
--- ildb_source.c 22 Nov 2002 06:12:47 -0000 1.3
***************
*** 798,801 ****
--- 798,802 ----
offset += (unsigned long)(temp - buf);
len -= (unsigned long)(temp - buf);
+ buf += (unsigned long)(temp - buf);
file->prevIsEOL = 1;
}
***************
*** 809,816 ****
}
ILDbSourceFile *ILDbSourceCreate(ILDb *db, const char *filename)
{
! /* TODO */
! return 0;
}
--- 810,864 ----
}
+ /*
+ * Add a string buffer to a source file.
+ */
+ static void AddBuffer(ILDbSourceFile *file, const char *str, unsigned long
len)
+ {
+ /* Expand the text buffer and add the new string */
+ if((file->textLen + len) > file->textMax)
+ {
+ char *newText;
+ unsigned long newLen = file->textLen + len;
+ newLen = (newLen + 1023) & ~1023;
+ newText = (char *)ILRealloc(file->text, newLen);
+ if(!newText)
+ {
+ ILDbOutOfMemory(file->owner);
+ }
+ file->text = newText;
+ file->textMax = newLen;
+ }
+ ILMemCpy(file->text + file->textLen, str, len);
+ file->textLen += len;
+
+ /* Add the lines within the string to the lines array */
+ AddLines(file, str, len);
+ }
+
ILDbSourceFile *ILDbSourceCreate(ILDb *db, const char *filename)
{
! ILDbSourceFile *file;
! FILE *stream;
! char buffer[BUFSIZ];
! int size;
!
! /* Create the source file block */
! if(SourceCreate(db, filename, 0, &file))
! {
! return file;
! }
!
! /* Load the contents of the file into memory */
! if((stream = fopen(filename, "r")) == NULL)
! {
! perror(filename);
! return file;
! }
! while((size = (int)fread(buffer, 1, BUFSIZ, stream)) > 0)
! {
! AddBuffer(file, buffer, (unsigned long)size);
! }
! fclose(stream);
! return file;
}
***************
*** 887,910 ****
return;
}
!
! /* Expand the text buffer and add the new string */
! if((file->textLen + len) > file->textMax)
! {
! char *newText;
! unsigned long newLen = file->textLen + len;
! newLen = (newLen + 1023) & ~1023;
! newText = (char *)ILRealloc(file->text, newLen);
! if(!newText)
! {
! ILDbOutOfMemory(file->owner);
! }
! file->text = newText;
! file->textMax = newLen;
! }
! ILMemCpy(file->text + file->textLen, str, len);
! file->textLen += len;
!
! /* Add the lines within the string to the lines array */
! AddLines(file, str, len);
}
--- 935,939 ----
return;
}
! AddBuffer(file, str, len);
}
***************
*** 930,934 ****
*/
static ILDbSourceFile *GetSourceFromDebug(ILDb *db, ILDebugContext *dbg,
!
ILToken token, ILClass *classInfo)
{
const char *filename;
--- 959,964 ----
*/
static ILDbSourceFile *GetSourceFromDebug(ILDb *db, ILDebugContext *dbg,
!
ILToken token, ILClass *classInfo,
!
long *lineReturn)
{
const char *filename;
***************
*** 937,941 ****
ILDbSourceFile *file;
! filename = ILDebugGetLineInfo(dbg, token, IL_MAX_UINT32, &line,
&column);
if(filename)
{
--- 967,976 ----
ILDbSourceFile *file;
! filename = ILDebugGetLineInfo(dbg, token, 0, &line, &column);
! if(!filename)
! {
! filename = ILDebugGetLineInfo(dbg, token, IL_MAX_UINT32,
!
&line, &column);
! }
if(filename)
{
***************
*** 951,954 ****
--- 986,993 ----
file = ILDbSourceCreate(db, fullName);
ILFree(fullName);
+ if(lineReturn)
+ {
+ *lineReturn = (long)line;
+ }
return file;
}
***************
*** 959,963 ****
}
! ILDbSourceFile *ILDbSourceGet(ILDb *db, ILClass *classInfo, ILMember *member)
{
ILDebugContext *dbg;
--- 998,1003 ----
}
! ILDbSourceFile *ILDbSourceGet(ILDb *db, ILClass *classInfo,
! ILMember *member,
long *line)
{
ILDebugContext *dbg;
***************
*** 994,997 ****
--- 1034,1041 ----
/* Look for debug blocks on the member or class */
+ if(line)
+ {
+ *line = 0;
+ }
if(dbg)
{
***************
*** 1004,1008 ****
{
return GetSourceFromDebug
! (db, dbg, ILMember_Token(member),
classInfo);
}
}
--- 1048,1052 ----
{
return GetSourceFromDebug
! (db, dbg, ILMember_Token(member),
classInfo, line);
}
}
***************
*** 1015,1019 ****
{
return GetSourceFromDebug
! (db, dbg, ILClass_Token(classInfo),
classInfo);
}
}
--- 1059,1064 ----
{
return GetSourceFromDebug
! (db, dbg, ILClass_Token(classInfo),
classInfo,
! (member ? 0 : line));
}
}
Index: ildb_source.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildb/ildb_source.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ildb_source.h 26 Jun 2002 03:10:46 -0000 1.2
--- ildb_source.h 22 Nov 2002 06:12:47 -0000 1.3
***************
*** 88,92 ****
* Returns NULL if it was not possible to locate an approprate file.
*/
! ILDbSourceFile *ILDbSourceGet(ILDb *db, ILClass *classInfo, ILMember *member);
/*
--- 88,93 ----
* Returns NULL if it was not possible to locate an approprate file.
*/
! ILDbSourceFile *ILDbSourceGet(ILDb *db, ILClass *classInfo,
! ILMember *member,
long *line);
/*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/ildb ildb_context.c,1.6,1.7 ildb_context.h,1.6,1.7 ildb_list.c,1.3,1.4 ildb_search.c,1.2,1.3 ildb_source.c,1.2,1.3 ildb_source.h,1.2,1.3,
Rhys Weatherley <address@hidden> <=