From c6dce7843cbdaea58520d52ed46db2d24848ba5c Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Tue, 16 Mar 2021 15:29:27 -0700 Subject: [PATCH 1/2] Display atom name in error message if get_package_atom() fails --- src/gcarray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gcarray.c b/src/gcarray.c index da57fe32..c443eebb 100644 --- a/src/gcarray.c +++ b/src/gcarray.c @@ -278,7 +278,7 @@ LispPTR get_package_atom(const char *char_base, DLword charlen, const char *pack packindex = find_package_from_name(packname, packlen); if (packindex < 0) { - printf("getting package index is failed \n"); + printf("getting package index failed %s:%s\n", packname, char_base); return (0xffffffff); } From b1a861203897e90d44890a244c16886d7bf99680 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Tue, 16 Mar 2021 15:30:12 -0700 Subject: [PATCH 2/2] Various fixes to package/atom handling in testtool.c Remove S_TOPVAL and S_MAKEATOM which only existed to deal with an old issue with dbx where you supposedly couldn't enter a string with "\" in it. Remove countchar(), which is functionally identical to strlen(), and adjust code that used it. Adjust return type of MAKEATOM() to be the LispPTR that it should be, instead of int. Limit find_package_from_name() to examining only the number of entries that are present in the *PACKAGE-FROM-INDEX* array, instead of walking off the end. MakeAtom68k() now drops into uraid() if asked to look up an atom that does not exist (Make... is a misnomer, it will never *make* the atom, only lookup an existing one) --- inc/testtooldefs.h | 5 +--- src/testtool.c | 73 +++++++++------------------------------------- 2 files changed, 15 insertions(+), 63 deletions(-) diff --git a/inc/testtooldefs.h b/inc/testtooldefs.h index 4757982d..1f84f1a9 100644 --- a/inc/testtooldefs.h +++ b/inc/testtooldefs.h @@ -21,7 +21,6 @@ void doko(void); void dumpl(LispPTR laddr); void dumps(LispPTR laddr); void printPC(void); -int countchar(char *string); void dump_bf(Bframe *bf); void dump_fx(struct frameex1 *fx_addr68k); void dump_stackframe(struct frameex1 *fx_addr68k); @@ -29,11 +28,9 @@ void dump_CSTK(int before); void btv(void); int get_framename(struct frameex1 *fx_addr68k); FX *get_nextFX(FX *fx); -int MAKEATOM(char *string); +LispPTR MAKEATOM(char *string); LispPTR *MakeAtom68k(char *string); void GETTOPVAL(char *string); -void S_TOPVAL(char *string); -int S_MAKEATOM(char *string); void all_stack_dump(DLword start, DLword end, DLword silent); void dtd_chain(DLword type); void Trace_FNCall(int numargs, int atomindex, int arg1, LispPTR *tos); diff --git a/src/testtool.c b/src/testtool.c index a1579aa9..60f25c6c 100644 --- a/src/testtool.c +++ b/src/testtool.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "lispemul.h" #include "lispmap.h" @@ -57,7 +58,9 @@ #include "debug.h" #include "dbprint.h" #include "tosfns.h" +#include "array.h" +#include "commondefs.h" #include "testtooldefs.h" #include "dbgtooldefs.h" #include "gcarraydefs.h" @@ -106,16 +109,17 @@ void print_atomname(LispPTR index) /* */ /************************************************************************/ -#define PACKAGES_LIMIT 255 -/** GET PACKAGE INDEX from PACKAGE FULL NAME */ int find_package_from_name(const char *packname, int len) { int index; PACKAGE *package; NEWSTRINGP *namestring; DLword len2; char *pname; + struct arrayheader *pi_array; - for (index = 1; index <= PACKAGES_LIMIT; index++) { + /* assumes the *PACKAGE-FROM-INDEX* array is simple with no offset */ + pi_array = (struct arrayheader *)Addr68k_from_LADDR(*Package_from_Index_word); + for (index = 1; index < pi_array->totalsize; index++) { package = (PACKAGE *)Addr68k_from_LADDR(aref1(*Package_from_Index_word, index)); namestring = (NEWSTRINGP *)Addr68k_from_LADDR(package->NAME); pname = (char *)Addr68k_from_LADDR(namestring->base); @@ -847,18 +851,6 @@ void printPC(void) { printf("PC: O%o ", pc); } -/***************************/ -int countchar(char *string) { - int cnt = 0; - - while (*string != '\0') { - string++; - cnt++; - } - - return (cnt); -} - void dump_bf(Bframe *bf) { DLword *ptr; printf("\n*** Basic Frame"); @@ -1024,10 +1016,8 @@ FX *get_nextFX(FX *fx) { } /* get_nextFX end */ -int MAKEATOM(char *string) { - int length; - length = countchar(string); - return (make_atom(string, 0, length, 0)); +LispPTR MAKEATOM(char *string) { + return (make_atom(string, 0, strlen(string), 0)); } /************************************************************************/ @@ -1040,8 +1030,11 @@ int MAKEATOM(char *string) { /************************************************************************/ LispPTR *MakeAtom68k(char *string) { - int index; - index = make_atom(string, 0, countchar(string), 0); + LispPTR index; + index = make_atom(string, 0, strlen(string), 0); + if (index == 0xffffffff) { + error("MakeAtom68k: no such atom found"); + } #ifdef BIGVM index = (ATOMS_HI << 16) + (index * 10) + NEWATOM_VALUE_OFFSET; #else @@ -1070,44 +1063,6 @@ void GETTOPVAL(char *string) { printf("'%s': no such symbol.\n", string); } -/************************************************************************/ -/* */ -/* S _ T O P V A L */ -/* */ -/* Given a string that's an atom name minus the initial \, */ -/* print the atom's top-level value. This is here because */ -/* DBX won't put \'s in strings you type. */ -/* */ -/************************************************************************/ - -void S_TOPVAL(char *string) { - int index; - LispPTR *cell68k; - int length; - char dummy[256]; - - dummy[0] = '\\'; - for (length = 1; *string != '\0'; length++, string++) { dummy[length] = *string; } - - index = make_atom(dummy, 0, length, 0); - cell68k = (LispPTR *)GetVALCELL68k(index); - print(*cell68k); -} - -/***************/ -int S_MAKEATOM(char *string) { - int index = 0; - int length; - char dummy[256]; - - dummy[0] = '\\'; - for (length = 1; *string != '\0'; length++, string++) { dummy[length] = *string; } - - index = make_atom(dummy, 0, length, 0); - printf("#Atomindex : %d\n", index); - return (index); -} - /****************************************************************************/ /* all_stack_dump(start,end) */