[Vm-dev] [commit][2739] Cog VM source as per VMMaker.oscog-eem.298.
commits at squeakvm.org
commits at squeakvm.org
Tue Jun 11 01:16:03 UTC 2013
Revision: 2739
Author: eliot
Date: 2013-06-10 18:16:01 -0700 (Mon, 10 Jun 2013)
Log Message:
-----------
Cog VM source as per VMMaker.oscog-eem.298.
Change the VMProfileLinuxSupportPlugin to follow symlinks,
answering pairs of module name, dereferenced symlink or nil.
Modified Paths:
--------------
branches/Cog/src/plugins/VMProfileLinuxSupportPlugin/VMProfileLinuxSupportPlugin.c
Property Changed:
----------------
branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
- Mon Jun 10 13:58:47 PDT 2013
+ Mon Jun 10 18:15:11 PDT 2013
Modified: branches/Cog/src/plugins/VMProfileLinuxSupportPlugin/VMProfileLinuxSupportPlugin.c
===================================================================
--- branches/Cog/src/plugins/VMProfileLinuxSupportPlugin/VMProfileLinuxSupportPlugin.c 2013-06-10 20:59:49 UTC (rev 2738)
+++ branches/Cog/src/plugins/VMProfileLinuxSupportPlugin/VMProfileLinuxSupportPlugin.c 2013-06-11 01:16:01 UTC (rev 2739)
@@ -1,9 +1,9 @@
/* Automatically generated by
- VMPluginCodeGenerator VMMaker.oscog-eem.297 uuid: cb5c5783-9e64-4e06-ac22-1303b40171e9
+ VMPluginCodeGenerator VMMaker.oscog-eem.298 uuid: da5c90a8-14fa-4f7a-a58f-40f16337392c
from
- VMProfileLinuxSupportPlugin VMMaker.oscog-eem.297 uuid: cb5c5783-9e64-4e06-ac22-1303b40171e9
+ VMProfileLinuxSupportPlugin VMMaker.oscog-eem.298 uuid: da5c90a8-14fa-4f7a-a58f-40f16337392c
*/
-static char __buildInfo[] = "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.297 uuid: cb5c5783-9e64-4e06-ac22-1303b40171e9 " __DATE__ ;
+static char __buildInfo[] = "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.298 uuid: da5c90a8-14fa-4f7a-a58f-40f16337392c " __DATE__ ;
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <limits.h>
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
@@ -58,6 +59,7 @@
EXPORT(sqInt) primitiveExecutableModules(void);
EXPORT(sqInt) primitiveInterpretAddress(void);
static sqInt reapmodulenames(struct dl_phdr_info *info, size_t size, void *ignored);
+static sqInt reapmodulesymlinks(struct dl_phdr_info *info, size_t size, void *ignored);
EXPORT(sqInt) setInterpreter(struct VirtualMachine*anInterpreter);
@@ -72,6 +74,7 @@
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)(sqInt integerValue);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
@@ -88,6 +91,7 @@
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(sqInt integerValue);
extern sqInt primitiveFailFor(sqInt reasonCode);
@@ -101,9 +105,9 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.297 (i)"
+ "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.298 (i)"
#else
- "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.297 (e)"
+ "VMProfileLinuxSupportPlugin VMMaker.oscog-eem.298 (e)"
#endif
;
static sqInt numModules;
@@ -203,9 +207,11 @@
}
-/* Answer an Array of strings for executable modules (the VM executable and
- loaded libraries).
- */
+/* Answer an Array of pairs of strings for executable modules (the VM
+ executable and loaded libraries).
+ The first element in each pair is the filename of the module. The second
+ element is either nil or
+ the symlink's target, if the filename is a symlink. */
EXPORT(sqInt)
primitiveExecutableModules(void)
@@ -217,13 +223,13 @@
/* skip the fake linux-gate.so.1 */
- resultObj = instantiateClassindexableSize(classArray(), numModules - 1);
+ resultObj = instantiateClassindexableSize(classArray(), (numModules - 1) * 2);
if (resultObj == 0) {
return primitiveFailFor(PrimErrNoMemory);
}
pushRemappableOop(resultObj);
primErr = (numModules = 0);
- dl_iterate_phdr(reapmodulenames,0);
+ dl_iterate_phdr(reapmodulesymlinks,0);
resultObj = popRemappableOop();
if (primErr != 0) {
return primitiveFailFor(primErr);
@@ -269,6 +275,48 @@
}
+/* like reap:module:names:, but follows symlinks */
+
+static sqInt
+reapmodulesymlinks(struct dl_phdr_info *info, size_t size, void *ignored)
+{
+ const char *elfModuleName;
+ extern char *GetAttributeString(sqInt);
+ sqInt len;
+ sqInt moduleNameObj;
+ char symLinkBuf[PATH_MAX];
+
+ ;
+ elfModuleName = numModules ? info->dlpi_name : GetAttributeString(0);
+ if ((elfModuleName == null)
+ || (((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. */
EXPORT(sqInt)
@@ -290,6 +338,7 @@
instantiateClassindexableSize = interpreterProxy->instantiateClassindexableSize;
isBytes = interpreterProxy->isBytes;
methodReturnValue = interpreterProxy->methodReturnValue;
+ nilObject = interpreterProxy->nilObject;
popRemappableOop = interpreterProxy->popRemappableOop;
positive32BitIntegerFor = interpreterProxy->positive32BitIntegerFor;
primitiveFailFor = interpreterProxy->primitiveFailFor;
More information about the Vm-dev
mailing list