1 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
2 | * Version: CDDL 1.0/LGPL 2.1
|
---|
3 | *
|
---|
4 | * The contents of this file are subject to the COMMON DEVELOPMENT AND
|
---|
5 | * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
|
---|
6 | * this file except in compliance with the License. You may obtain a copy of
|
---|
7 | * the License at http://www.sun.com/cddl/
|
---|
8 | *
|
---|
9 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
11 | * for the specific language governing rights and limitations under the
|
---|
12 | * License.
|
---|
13 | *
|
---|
14 | * The Original Code is "NOM" Netlabs Object Model
|
---|
15 | *
|
---|
16 | * The Initial Developer of the Original Code is
|
---|
17 | * netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
|
---|
18 | * Portions created by the Initial Developer are Copyright (C) 2005-2006
|
---|
19 | * the Initial Developer. All Rights Reserved.
|
---|
20 | *
|
---|
21 | * Contributor(s):
|
---|
22 | *
|
---|
23 | * Alternatively, the contents of this file may be used under the terms of
|
---|
24 | * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
|
---|
25 | * case the provisions of the LGPL are applicable instead of those above. If
|
---|
26 | * you wish to allow use of your version of this file only under the terms of
|
---|
27 | * the LGPL, and not to allow others to use your version of this file under
|
---|
28 | * the terms of the CDDL, indicate your decision by deleting the provisions
|
---|
29 | * above and replace them with the notice and other provisions required by the
|
---|
30 | * LGPL. If you do not delete the provisions above, a recipient may use your
|
---|
31 | * version of this file under the terms of any one of the CDDL or the LGPL.
|
---|
32 | *
|
---|
33 | * ***** END LICENSE BLOCK ***** */
|
---|
34 |
|
---|
35 | #define INCL_DOS
|
---|
36 | #define INCL_DOSFILEMGR
|
---|
37 | #define INCL_DOSERRORS
|
---|
38 | #define INCL_WIN
|
---|
39 | #define INCL_WINWORKPLACE
|
---|
40 | #define INCL_OS2MM
|
---|
41 | #define INCL_MMIOOS2
|
---|
42 | #define INCL_MCIOS2
|
---|
43 | #define INCL_GPI
|
---|
44 | #define INCL_PM
|
---|
45 |
|
---|
46 | #include <os2.h>
|
---|
47 | #include <stdarg.h>
|
---|
48 | #include <stdio.h>
|
---|
49 |
|
---|
50 | #include "nom.h"
|
---|
51 | #include "nomtk.h"
|
---|
52 | #include "nomobj.h"
|
---|
53 | #include "nomclassmanager.h"
|
---|
54 |
|
---|
55 | //#include "cwsomcls.h"
|
---|
56 | extern NOMClassMgr* NOMClassMgrObject;
|
---|
57 |
|
---|
58 | static void dumpClassFunc(GQuark gquark, gpointer data, gpointer user_data)
|
---|
59 | {
|
---|
60 | nomMethodTab* mtab;
|
---|
61 | NOMClassPriv* priv;
|
---|
62 |
|
---|
63 | mtab=(nomMethodTab*)data;
|
---|
64 | priv=(NOMClassPriv*)mtab->nomClsInfo;
|
---|
65 |
|
---|
66 | if(!priv)
|
---|
67 | nomPrintf("%s: gquark: %ld, %lx-> %s mtab: %lx, nomClsInfo->mtab: %lx\n",
|
---|
68 | __FUNCTION__, gquark, data, mtab->nomClassName, mtab, priv/*->mtab*/);
|
---|
69 | else
|
---|
70 | nomPrintf("%s: gquark: %ld, %lx-> %s mtab: %lx, nomClsInfo->mtab: %lx\n",
|
---|
71 | __FUNCTION__, gquark, data, mtab->nomClassName, mtab, priv->mtab);
|
---|
72 |
|
---|
73 | }
|
---|
74 |
|
---|
75 | NOMEXTERN void NOMLINK dumpClasses(void)
|
---|
76 | {
|
---|
77 | GData *pgdata;
|
---|
78 |
|
---|
79 | nomPrintf("----- %s ----- NOMClassMgrObject: %lx\n", __FUNCTION__, NOMClassMgrObject);
|
---|
80 |
|
---|
81 | pgdata=_nomGetClassList(NOMClassMgrObject, NULLHANDLE);
|
---|
82 | if(pgdata){
|
---|
83 | nomPrintf("%s: classlist: %lx\n", __FUNCTION__, pgdata);
|
---|
84 | g_datalist_foreach(&pgdata, dumpClassFunc, pgdata);
|
---|
85 | }
|
---|
86 | nomPrintf("----- End of %s -----\n", __FUNCTION__);
|
---|
87 | }
|
---|
88 |
|
---|
89 | void _dumpSci(nomStaticClassInfo* sci)
|
---|
90 | {
|
---|
91 | nomPrintf("%d: --- sci dump ---:\n", __LINE__);
|
---|
92 | nomPrintf("&sci: 0x%x\n", sci);
|
---|
93 | nomPrintf("Num static methods: %d\n", sci->ulNumStaticMethods);
|
---|
94 | nomPrintf("Num static overrides: %d\n", sci->ulNumStaticOverrides);
|
---|
95 | nomPrintf("Major: %d, minor %d\n", sci->ulMajorVersion, sci->ulMinorVersion);
|
---|
96 | nomPrintf("Instance data size: %d\n", sci->ulInstanceDataSize);
|
---|
97 | //somPrintf("Max methods: %d\n", sci->maxMethods);
|
---|
98 | nomPrintf("numParents: %d\n", sci->ulNumParents);
|
---|
99 | nomPrintf("classId: %s\n", *sci->nomClassId);
|
---|
100 | if(sci->nomExplicitMetaId)
|
---|
101 | nomPrintf("explicitMetaId (meta class): %s\n", *sci->nomExplicitMetaId);
|
---|
102 | else
|
---|
103 | nomPrintf("explicitMetaId (meta class): NULLHANDLE\n");
|
---|
104 | // somPrintf("*parents: 0x%x\n", sci->parents);
|
---|
105 | nomPrintf("somClassDataStructure cds: 0x%x\n",sci->nomCds);
|
---|
106 | if(sci->nomCds)
|
---|
107 | nomPrintf("classObject: 0x%x\n", sci->nomCds->nomClassObject);
|
---|
108 | //somPrintf("somCClassDataStructure ccds: 0x%x\n", sci->ccds);
|
---|
109 | nomPrintf("Static method table (nomStaticMethodDesc): 0x%x\n", sci->nomSMethods);
|
---|
110 | //somPrintf("Override method table (somOverrideMethod_t): 0x%x\n", sci->omt);
|
---|
111 |
|
---|
112 | nomPrintf("------------------\n");
|
---|
113 |
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | void _dumpClassDataStruct(nomClassDataStructure* cds, ULONG ulNumMethods)
|
---|
118 | {
|
---|
119 | int a;
|
---|
120 |
|
---|
121 | nomPrintf("%d: --- classdataStruct dump num methods: %d ---:\n", __LINE__, ulNumMethods);
|
---|
122 | nomPrintf("classObject: %x\n", cds->nomClassObject);
|
---|
123 | for(a=0;a<ulNumMethods; a++)
|
---|
124 | nomPrintf("%d: %x at address %x\n", a+1, cds->nomTokens[a], &cds->nomTokens[a]);
|
---|
125 |
|
---|
126 | nomPrintf("-----------------------------\n");
|
---|
127 | }
|
---|
128 |
|
---|
129 | void _dumpMtab(nomMethodTab* mtab)
|
---|
130 | {
|
---|
131 | int a;
|
---|
132 | nomMethodProc* entries;
|
---|
133 |
|
---|
134 | nomPrintf("\n--- mtab dump for %x, %s (%s) ---\n", mtab, mtab->nomClassName, __FUNCTION__);
|
---|
135 | nomPrintf(" mtab: 0x%x\n", mtab);
|
---|
136 | nomPrintf(" classObject: 0x%x\n", mtab->nomClassObject);
|
---|
137 | nomPrintf(" classInfo: 0x%x\n", mtab->nomClsInfo);
|
---|
138 | // somPrintf("*classInfo: 0x%x\n", *sObj->mtab->classInfo);
|
---|
139 | nomPrintf(" className: %s\n", mtab->nomClassName);
|
---|
140 | nomPrintf(" instanceSize (this and all parents): %d 0x%x\n", mtab->ulInstanceSize, mtab->ulInstanceSize);
|
---|
141 | nomPrintf(" mtabSize: %d 0x%x\n", mtab->mtabSize, mtab->mtabSize);
|
---|
142 | nomPrintf(" somMethodProcs: (%ld)\n", (mtab->mtabSize-(LONG)sizeof(nomMethodTab))/4);
|
---|
143 | // entries=sObj->mtab->entries[0];
|
---|
144 | for(a=0; a<=(mtab->mtabSize-sizeof(nomMethodTab))/4; a++)
|
---|
145 | nomPrintf(" %d: somMethodProc: 0x%x at 0x%x\n", a, mtab->entries[a], &mtab->entries[a]);
|
---|
146 | nomPrintf("--- end of mtab dump ---\n");
|
---|
147 | }
|
---|
148 |
|
---|
149 |
|
---|
150 | void _dumpObjShort(NOMObject* sObj)
|
---|
151 | {
|
---|
152 |
|
---|
153 | nomPrintf("--- Object dump (mtab) for %s ---\n", sObj->mtab->nomClassName);
|
---|
154 | nomPrintf("Obj: 0x%x\n", sObj);
|
---|
155 | nomPrintf("SOM_Any->mtab: 0x%x\n", sObj->mtab);
|
---|
156 | nomPrintf("classObject: 0x%x\n", sObj->mtab->nomClassObject);
|
---|
157 | nomPrintf("classInfo: 0x%x\n", sObj->mtab->nomClsInfo);
|
---|
158 | #if 0
|
---|
159 | nomPrintf("*classInfo: 0x%x\n", *sObj->mtab->nomClsInfo);
|
---|
160 |
|
---|
161 | so=(ULONG*)sObj->mtab->classInfo;
|
---|
162 | #endif
|
---|
163 | nomPrintf("className: %s\n", sObj->mtab->nomClassName);
|
---|
164 | nomPrintf("instanceSize (this and all parents): %d 0x%x\n", sObj->mtab->ulInstanceSize, sObj->mtab->ulInstanceSize);
|
---|
165 | nomPrintf("mtabSize: %d 0x%x\n", sObj->mtab->mtabSize, sObj->mtab->mtabSize);
|
---|
166 | nomPrintf("nomMethodProcs: (%d)\n", (sObj->mtab->mtabSize-sizeof(nomMethodTab))/4);
|
---|
167 | nomPrintf("classObject in entries[]: 0x%x\n", sObj->mtab->entries[0]);
|
---|
168 | // entries=sObj->mtab->entries[0];
|
---|
169 | // for(a=0; a<=(sObj->mtab->mtabSize-sizeof(somMethodTab))/4; a++)
|
---|
170 | // somPrintf("%d: somMethodProc: 0x%x\n", a, sObj->mtab->entries[a]);
|
---|
171 | nomPrintf("---------\n");
|
---|
172 | }
|
---|
173 |
|
---|
174 |
|
---|
175 | #if 0
|
---|
176 | void _dumpStaticMTab(somStaticMethod_t* smt, ULONG ulMethod)
|
---|
177 | {
|
---|
178 | somStaticMethod_t* tmpSmt=&smt[ulMethod];
|
---|
179 |
|
---|
180 | somPrintf("--- static method dump for 0x%x, method index: %d ---:\n", smt, ulMethod);
|
---|
181 | somPrintf("classData: %x\n", tmpSmt->classData);
|
---|
182 | somPrintf("methodId: %s\n", **tmpSmt->methodId);
|
---|
183 | somPrintf("methodDescriptor: %s\n", **tmpSmt->methodDescriptor);
|
---|
184 | somPrintf("method: 0x%x\n", tmpSmt->method);
|
---|
185 |
|
---|
186 | somPrintf("-----------------------------\n");
|
---|
187 | }
|
---|
188 |
|
---|
189 | void _dumpOverrideMTab(somOverrideMethod_t* omt, ULONG ulMethod)
|
---|
190 | {
|
---|
191 | somOverrideMethod_t* tmpOmt=&omt[ulMethod];
|
---|
192 |
|
---|
193 | somPrintf("--- override method dump for 0x%x, method index: %d ---:\n", omt, ulMethod);
|
---|
194 | somPrintf("classId: %s\n", **tmpOmt->methodId);
|
---|
195 | // somPrintf("methodDescriptor: %s\n", **tmpOmt->methodDescriptor);
|
---|
196 | somPrintf("method: 0x%x\n", tmpOmt->method);
|
---|
197 |
|
---|
198 | somPrintf("-----------------------------\n");
|
---|
199 | }
|
---|
200 |
|
---|
201 | void SOMLINK _dumpParentMTab(somParentMtabStructPtr pMtabPtr)
|
---|
202 | {
|
---|
203 |
|
---|
204 | somPrintf("--- ParentMtabStruct dump for 0x%x (%s) ---:\n", pMtabPtr, pMtabPtr->mtab->className);
|
---|
205 | somPrintf("this mtab:\t\t\t%x\n", pMtabPtr->mtab);
|
---|
206 | somPrintf("somMethodTabs next:\t\t%x\n", pMtabPtr->next);
|
---|
207 | if(pMtabPtr->next) {
|
---|
208 | somPrintf("parent mtab (next->mtab):\t%x\n", pMtabPtr->next->mtab);
|
---|
209 | somPrintf(" next->next:\t\t\t%x\n", pMtabPtr->next->next);
|
---|
210 | }
|
---|
211 | else
|
---|
212 | somPrintf(" NO parent mtab\n");
|
---|
213 | somPrintf("classObject:\t\t\t0x%x\n", pMtabPtr->classObject);
|
---|
214 | somPrintf("instanceSize:\t\t\t%d 0x%x\n", pMtabPtr->instanceSize, pMtabPtr->instanceSize);
|
---|
215 | somPrintf("-----------------------------\n");
|
---|
216 | }
|
---|
217 |
|
---|
218 | void _dumpParentMTabList(somParentMtabStructPtr pMtabPtr)
|
---|
219 | {
|
---|
220 | somParentMtabStructPtr tempPtr=pMtabPtr;
|
---|
221 |
|
---|
222 | while(tempPtr){
|
---|
223 | _dumpParentMTab(tempPtr);
|
---|
224 | if(tempPtr->next)
|
---|
225 | tempPtr=(void*)tempPtr->next->mtab;
|
---|
226 | else
|
---|
227 | tempPtr=NULLHANDLE;
|
---|
228 | }
|
---|
229 |
|
---|
230 | }
|
---|
231 |
|
---|
232 | void _dumpMethodTabList(somMethodTabList *mtabList)
|
---|
233 | {
|
---|
234 | somMethodTab *mtab;
|
---|
235 | int a=0;
|
---|
236 |
|
---|
237 | somPrintf("--- somMethodTabList dump for 0x%x ---:\n", mtabList);
|
---|
238 | while(mtabList && a<3)
|
---|
239 | {
|
---|
240 | mtab=mtabList->mtab;
|
---|
241 |
|
---|
242 | if(mtab)
|
---|
243 | somPrintf(" %d: mtab: %x , class: %s SOM class object: %x, priv object: %x, next: %x\n",
|
---|
244 | a, mtab, mtab->className, mtab->classObject, mtab->classInfo, mtabList->next);
|
---|
245 | else
|
---|
246 | somPrintf("mtab is 0!!\n");
|
---|
247 |
|
---|
248 | mtabList=mtabList->next;
|
---|
249 | a++;
|
---|
250 | }
|
---|
251 | somPrintf("-----------------------------\n");
|
---|
252 | }
|
---|
253 |
|
---|
254 | void SOMLINK _dumpMTabListPrivClass(SOMClassPriv *sClass)
|
---|
255 | {
|
---|
256 | somMethodTabList *mtabList;
|
---|
257 | somMethodTab *mtab;
|
---|
258 | int a=0;
|
---|
259 |
|
---|
260 | if(!sClass) {
|
---|
261 | somPrintf("--- somMethodTabList dump: no SOMClassPriv* ");
|
---|
262 | return;
|
---|
263 | }
|
---|
264 | mtabList=&sClass->mtabList;
|
---|
265 |
|
---|
266 | somPrintf("\n--- somMethodTabList dump for 0x%x %s (%s) ---:\n", sClass, sClass->mtab->className, __FUNCTION__);
|
---|
267 | while(mtabList)
|
---|
268 | {
|
---|
269 | mtab=mtabList->mtab;
|
---|
270 | somPrintf(" %d: mtab: %x , class: %s SOM class object: %x, priv object: %x, next %x\n",
|
---|
271 | a, mtab, mtab->className, mtab->classObject, mtab->classInfo, mtabList->next);
|
---|
272 | mtabList=mtabList->next;
|
---|
273 | a++;
|
---|
274 | }
|
---|
275 | somPrintf("--- somMethodTabList end ---\n");
|
---|
276 | }
|
---|
277 |
|
---|
278 | /* Dump object data. This means more or less dumping of the methodTabStruct of this
|
---|
279 | object. A pointer to this struct is the first word of any object (SOMAny.mtab).
|
---|
280 |
|
---|
281 | -- Object Instance Structure:
|
---|
282 |
|
---|
283 | struct somMethodTabStruct;
|
---|
284 | typedef struct SOMAny_struct {
|
---|
285 | struct somMethodTabStruct *mtab;
|
---|
286 | integer4 body[1];
|
---|
287 | } SOMAny;
|
---|
288 |
|
---|
289 | typedef struct somMethodTabStruct {
|
---|
290 | SOMClass *classObject;
|
---|
291 | somClassInfo *classInfo;
|
---|
292 | char *className;
|
---|
293 | long instanceSize;
|
---|
294 | long dataAlignment;
|
---|
295 | long mtabSize;
|
---|
296 | long protectedDataOffset; // from class's introduced data
|
---|
297 | somDToken protectedDataToken;
|
---|
298 | somEmbeddedObjStruct *embeddedObjs;
|
---|
299 | // remaining structure is opaque
|
---|
300 | somMethodProc* entries[1]; <-- I found that this isn't correct (or I misseed something in the includes). When dumping a mtab
|
---|
301 | the following has this structure:
|
---|
302 |
|
---|
303 | SOMClass *classObject; //The first class object (SOMObject)
|
---|
304 | This is basically a copy -> somMethodProc* firstMethod_1;
|
---|
305 | of the ClassDataStruct somMethodProc* secondMEthod_1;
|
---|
306 | ...
|
---|
307 | SOMClass *classObject; //The second class object
|
---|
308 | ClassDataStruct of 2. -> somMethodProc* firstMethod_2;
|
---|
309 | class somMethodProc* secondMEthod_2;
|
---|
310 |
|
---|
311 | } somMethodTab, *somMethodTabPtr;
|
---|
312 | */
|
---|
313 | void SOMLINK _dumpObj(SOMObject* sObj)
|
---|
314 | {
|
---|
315 | int a;
|
---|
316 | somMethodProc* entries;
|
---|
317 |
|
---|
318 | somPrintf("\n--- Object dump (mtab) for %s (%s) ---\n", sObj->mtab->className, __FUNCTION__);
|
---|
319 | somPrintf(" Obj: 0x%x\n", sObj);
|
---|
320 | somPrintf(" SOM_Any->mtab: 0x%x\n", sObj->mtab);
|
---|
321 | somPrintf(" classObject: 0x%x\n", sObj->mtab->classObject);
|
---|
322 | somPrintf(" classInfo: 0x%x\n", sObj->mtab->classInfo);
|
---|
323 | // somPrintf("*classInfo: 0x%x\n", *sObj->mtab->classInfo);
|
---|
324 | somPrintf(" className: %s\n", sObj->mtab->className);
|
---|
325 | somPrintf(" instanceSize (this and all parents): %d 0x%x\n", sObj->mtab->instanceSize, sObj->mtab->instanceSize);
|
---|
326 | somPrintf(" mtabSize: %d 0x%x\n", sObj->mtab->mtabSize, sObj->mtab->mtabSize);
|
---|
327 | somPrintf(" somMethodProcs: (%ld)\n", (sObj->mtab->mtabSize-(LONG)sizeof(somMethodTab))/4);
|
---|
328 | // entries=sObj->mtab->entries[0];
|
---|
329 | for(a=0; a<=(sObj->mtab->mtabSize-sizeof(somMethodTab))/4; a++)
|
---|
330 | somPrintf(" %d: somMethodProc: 0x%x at 0x%x\n", a, sObj->mtab->entries[a], &sObj->mtab->entries[a]);
|
---|
331 | somPrintf("--- end of object dump ---\n");
|
---|
332 | }
|
---|
333 |
|
---|
334 |
|
---|
335 |
|
---|
336 | #endif
|
---|
337 |
|
---|
338 |
|
---|
339 |
|
---|
340 |
|
---|
341 |
|
---|
342 |
|
---|
343 |
|
---|
344 |
|
---|
345 |
|
---|
346 |
|
---|
347 |
|
---|
348 |
|
---|
349 |
|
---|
350 |
|
---|
351 |
|
---|
352 |
|
---|
353 |
|
---|
354 |
|
---|
355 |
|
---|
356 |
|
---|
357 |
|
---|
358 |
|
---|
359 |
|
---|
360 |
|
---|
361 |
|
---|
362 |
|
---|
363 |
|
---|
364 |
|
---|
365 |
|
---|
366 |
|
---|