Skip to content

Commit

Permalink
Temporary fix for regression in VMProfileLinuxSupportPlugin.c
Browse files Browse the repository at this point in the history
due to different pruning criteria for plugins.
  • Loading branch information
eliotmiranda committed Sep 10, 2024
1 parent 41fce66 commit d96fe53
Showing 1 changed file with 72 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3455 uuid: 3fb5350e-7e08-4a76-8b1b-7755e8e0811f
VMPluginCodeGenerator * VMMaker.oscog-eem.3455 uuid: 3fb5350e-7e08-4a76-8b1b-7755e8e0811f
from
VMProfileLinuxSupportPlugin VMMaker.oscog-eem.3455 uuid: 3fb5350e-7e08-4a76-8b1b-7755e8e0811f
VMProfileLinuxSupportPlugin * VMMaker.oscog-eem.3455 uuid: 3fb5350e-7e08-4a76-8b1b-7755e8e0811f
*/
static char __buildInfo[] = "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.3455 uuid: 3fb5350e-7e08-4a76-8b1b-7755e8e0811f " __DATE__ ;
static char __buildInfo[] = "VMProfileLinuxSupportPlugin * VMMaker.oscog-eem.3455 uuid: 3fb5350e-7e08-4a76-8b1b-7755e8e0811f " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -47,51 +47,71 @@ extern const char *getAttributeString(sqInt);


/*** Function Prototypes ***/
static int countnummodules(struct dl_phdr_info *info, size_t size, void *ignored);
EXPORT(const char*) getModuleName(void);
EXPORT(sqInt) primitiveDLSymInLibrary(void);
EXPORT(sqInt) primitiveExecutableModules(void);
EXPORT(sqInt) primitiveInterpretAddress(void);
static int reapmodulesymlinks(struct dl_phdr_info *info, size_t size, void *ignored);
EXPORT(sqInt) setInterpreter(struct VirtualMachine *anInterpreter);


/*** Variables ***/

#if !defined(SQUEAK_BUILTIN_PLUGIN)
static void * (*arrayValueOf)(sqInt oop);
static sqInt (*byteSizeOf)(sqInt oop);
static sqInt (*classArray)(void);
static sqInt (*classString)(void);
static void * (*firstIndexableField)(sqInt oop);
static sqInt (*instantiateClassindexableSize)(sqInt classPointer, sqInt size);
static sqInt (*isBytes)(sqInt oop);
static sqInt (*methodReturnValue)(sqInt oop);
static sqInt (*nilObject)(void);
static sqInt (*popRemappableOop)(void);
static sqInt (*positive32BitIntegerFor)(unsigned int integerValue);
static sqInt (*positive64BitIntegerFor)(usqLong integerValue);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*pushRemappableOop)(sqInt oop);
static sqInt (*stackValue)(sqInt offset);
static sqInt (*storePointerofObjectwithValue)(sqInt index, sqInt oop, sqInt valuePointer);
static sqInt (*topRemappableOop)(void);
#else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
extern void * arrayValueOf(sqInt oop);
extern sqInt byteSizeOf(sqInt oop);
extern sqInt classArray(void);
extern sqInt classString(void);
extern void * firstIndexableField(sqInt oop);
extern sqInt instantiateClassindexableSize(sqInt classPointer, sqInt size);
extern sqInt isBytes(sqInt oop);
extern sqInt methodReturnValue(sqInt oop);
extern sqInt nilObject(void);
extern sqInt popRemappableOop(void);
extern sqInt positive32BitIntegerFor(unsigned int integerValue);
extern sqInt positive64BitIntegerFor(usqLong integerValue);
extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt pushRemappableOop(sqInt oop);
extern sqInt stackValue(sqInt offset);
extern sqInt storePointerofObjectwithValue(sqInt index, sqInt oop, sqInt valuePointer);
extern sqInt topRemappableOop(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.3455 " INT_EXT;
static const char *moduleName = "VMProfileLinuxSupportPlugin * VMMaker.oscog-eem.3455 " INT_EXT;
static sqInt numModules;
static sqInt primErr;


/*** Methods ***/

/* VMProfileLinuxSupportPlugin>>#count:num:modules: */
static int
countnummodules(struct dl_phdr_info *info, size_t size, void *ignored)
{
numModules += 1;
return 0;
}


/* Note: This is hardcoded so it can be run from Squeak.
The module name is used for validating a module *after*
Expand Down Expand Up @@ -204,6 +224,49 @@ primitiveInterpretAddress(void)
}


/* like reap:module:names:, but follows symlinks */

/* VMProfileLinuxSupportPlugin>>#reap:module:symlinks: */
static int
reapmodulesymlinks(struct dl_phdr_info *info, size_t size, void *ignored)
{
const char *elfModuleName;
sqInt len;
sqInt moduleNameObj;
char symLinkBuf[PATH_MAX];

elfModuleName = (numModules > 0
? (info->dlpi_name)
: getAttributeString(0));
if ((!elfModuleName)
|| (((len = strlen(elfModuleName))) == 0)) {
return 0;
}
moduleNameObj = instantiateClassindexableSize(classString(), len);
if (moduleNameObj == 0) {
primErr = PrimErrNoMemory;
return 1;
}
strncpy(arrayValueOf(moduleNameObj), elfModuleName, len);
storePointerofObjectwithValue(numModules, topRemappableOop(), moduleNameObj);
strcpy(symLinkBuf, elfModuleName);
if (((len = readlink(elfModuleName, symLinkBuf, PATH_MAX))) > 0) {
moduleNameObj = instantiateClassindexableSize(classString(), len);
if (moduleNameObj == 0) {
primErr = PrimErrNoMemory;
return 1;
}
strncpy(arrayValueOf(moduleNameObj), symLinkBuf, len);
storePointerofObjectwithValue(numModules + 1, topRemappableOop(), moduleNameObj);
}
else {
storePointerofObjectwithValue(numModules + 1, topRemappableOop(), nilObject());
}
numModules += 2;
return 0;
}


/* Note: This is coded so that it can be run in Squeak. */

/* InterpreterPlugin>>#setInterpreter: */
Expand All @@ -212,7 +275,6 @@ setInterpreter(struct VirtualMachine *anInterpreter)
{
sqInt ok;


/* This may seem tautological, but in a real plugin it checks that the VM provides
the version the plugin was compiled against which is the version the plugin expects. */
interpreterProxy = anInterpreter;
Expand All @@ -221,18 +283,23 @@ setInterpreter(struct VirtualMachine *anInterpreter)
if (ok) {

#if !defined(SQUEAK_BUILTIN_PLUGIN)
arrayValueOf = interpreterProxy->arrayValueOf;
byteSizeOf = interpreterProxy->byteSizeOf;
classArray = interpreterProxy->classArray;
classString = interpreterProxy->classString;
firstIndexableField = interpreterProxy->firstIndexableField;
instantiateClassindexableSize = interpreterProxy->instantiateClassindexableSize;
isBytes = interpreterProxy->isBytes;
methodReturnValue = interpreterProxy->methodReturnValue;
nilObject = interpreterProxy->nilObject;
popRemappableOop = interpreterProxy->popRemappableOop;
positive32BitIntegerFor = interpreterProxy->positive32BitIntegerFor;
positive64BitIntegerFor = interpreterProxy->positive64BitIntegerFor;
primitiveFailFor = interpreterProxy->primitiveFailFor;
pushRemappableOop = interpreterProxy->pushRemappableOop;
stackValue = interpreterProxy->stackValue;
storePointerofObjectwithValue = interpreterProxy->storePointerofObjectwithValue;
topRemappableOop = interpreterProxy->topRemappableOop;
#endif /* !defined(SQUEAK_BUILTIN_PLUGIN) */
}
return ok;
Expand Down

0 comments on commit d96fe53

Please sign in to comment.