Changeset 1382:243a4a8fd8db
- Timestamp:
- 10/21/09 20:35:35 (2 years ago)
- Branch:
- default
- Parents:
- 1381:76d814e375c0 (diff), 1379:dd7a2489d931 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- trunk
- Files:
-
- 26 deleted
- 6 edited
-
include/libdodo/pcSyncDataCollection.h (deleted)
-
include/libdodo/pcSyncDataSingle.h (deleted)
-
include/libdodo/pcSyncProcessDataCollection.h (deleted)
-
include/libdodo/pcSyncProcessDataCollectionEx.h (deleted)
-
include/libdodo/pcSyncProcessDataSingle.h (deleted)
-
include/libdodo/pcSyncProcessDataSingleEx.h (deleted)
-
include/libdodo/pcSyncProcessSection.h (deleted)
-
include/libdodo/pcSyncProcessSectionEx.h (deleted)
-
include/libdodo/pcSyncSection.h (deleted)
-
include/libdodo/pcSyncThreadDataCollection.h (deleted)
-
include/libdodo/pcSyncThreadDataCollectionEx.h (deleted)
-
include/libdodo/pcSyncThreadDataSingle.h (deleted)
-
include/libdodo/pcSyncThreadDataSingleEx.h (deleted)
-
include/libdodo/pcSyncThreadSection.h (deleted)
-
include/libdodo/pcSyncThreadSectionEx.h (deleted)
-
include/libdodo/xexec.h (modified) (2 diffs)
-
include/libdodo/xexec.h (modified) (1 diff)
-
src/exceptionBasic.cc (modified) (1 diff)
-
src/exceptionBasic.cc (modified) (19 diffs)
-
src/pcSyncDataCollection.cc (deleted)
-
src/pcSyncDataSingle.cc (deleted)
-
src/pcSyncProcessDataCollection.cc (deleted)
-
src/pcSyncProcessDataSingle.cc (deleted)
-
src/pcSyncProcessLock.inline (deleted)
-
src/pcSyncProcessSection.cc (deleted)
-
src/pcSyncSection.cc (deleted)
-
src/pcSyncThreadDataCollection.cc (deleted)
-
src/pcSyncThreadDataSingle.cc (deleted)
-
src/pcSyncThreadLock.inline (deleted)
-
src/pcSyncThreadSection.cc (deleted)
-
src/xexec.cc (modified) (7 diffs)
-
src/xexec.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/libdodo/xexec.h
r1379 r1382 66 66 /** 67 67 * @struct __module__ 68 * @brief is returned from moduleInitin the library68 * @brief is returned from initModule in the library 69 69 */ 70 70 struct __module__ { … … 76 76 77 77 /** 78 * @typedef moduleInit78 * @typedef initModule 79 79 * @brief defines type of init function for library 80 80 * @param data defines user data 81 81 * @note name in the library must be initXexecModule 82 82 */ 83 typedef __module__ (* moduleInit)(void *data);84 85 /** 86 * @typedef moduleDeinit83 typedef __module__ (*initModule)(void *data); 84 85 /** 86 * @typedef deinitModule 87 87 * @brief defines type of deinit function for library 88 88 * @note name in the library must be deinitXexecModule 89 89 */ 90 typedef void (* moduleDeinit)();90 typedef void (*deinitModule)(); 91 91 #endif 92 92 -
trunk/include/libdodo/xexec.h
r1380 r1382 36 36 37 37 namespace dodo { 38 /**39 * example of exec function that performs xexec40 *41 * void42 * derivedClass::exec()43 * {44 * performXExec(preExec);45 * ///< execute routine46 * performXExec(postExec);47 * }48 */49 50 /**51 * @class xexec52 * @brief provides pre/post exec actions for defrived classes53 */54 class xexec {55 private:56 57 /*58 * copy constructor59 * @note to prevent copying60 */61 xexec(const xexec &);62 63 public:64 65 #ifdef DL_EXT 66 /**67 * @struct __module__68 * @brief is returned from initModule in the library69 */70 struct __module__ {71 char name[64]; ///< name of the library72 char discription[256]; ///< discription of the library73 char hook[64]; ///< name of function in the library that will be used as hook74 short type;///< type of hook, @see xexec::actionEnum, could me grouped with OR75 };76 77 /**78 * @typedef initModule79 * @brief defines type of init function for library80 * @param data defines user data81 * @note name in the library must be initXexecModule82 */83 typedef __module__ (*initModule)(void *data);84 85 /**86 * @typedef deinitModule87 * @brief defines type of deinit function for library88 * @note name in the library must be deinitXexecModule89 */90 typedef void (*deinitModule)();91 #endif 92 93 /**94 * @enum objectEnum defines objects that access xexec95 */96 enum objectEnum {97 OBJECT_XEXEC,98 OBJECT_DATABASEMYSQL,99 OBJECT_DATABASESQLITE,100 OBJECT_DATABASEPOSTGRESQL,101 OBJECT_IOSTDIO,102 OBJECT_IOFILEREGULAR,103 OBJECT_IOFILETEMP,104 OBJECT_IOFILEFIFO,105 OBJECT_IOPIPE,106 OBJECT_IOMEMORY,107 OBJECT_IONETWORKCLIENT,108 OBJECT_IONETWORKSERVER,109 OBJECT_IONETWORKEXCHANGE,110 OBJECT_IONETWORKSSLCLIENT,111 OBJECT_IONETWORKSSLSERVER,112 OBJECT_IONETWORKSSLEXCHANGE,113 OBJECT_CGIFASTEXCHANGE,114 OBJECT_CGIBASICEXCHANGE,115 OBJECT_GRAPHICSIMAGE,116 };117 118 /**119 * @enum actionEnum defines what type of exec[pre/post] will be used for module120 */121 enum actionEnum {122 ACTION_PREEXEC = 2,123 ACTION_POSTEXEC = 4,124 };125 126 /**127 * @class __collected_data__128 * @brief defines data that could be retrieved from the object where xexec action raised129 */130 class __collected_data__ {131 public:132 133 /**134 * constructor135 * @param executor defines class that executed hook136 * @param execObject defines type of object that executed a hook, @see xexec::objectEnum137 */138 __collected_data__(xexec *executor,139 short execObject);140 141 /**142 * @param execObject defines type of object that executed a hook, @see xexec::objectEnum143 */144 void setExecObject(short execObject);145 146 xexec *executor; ///< class that executed hook147 };148 149 /**150 * @typedef hook151 * @brief defines function that will be called as hook152 * @param operation defines what operation initiated the hook153 * @param odata defines object data154 * @param object defines type of object that called hook, @see xexec::objectEnum155 * @param udata defines user data156 */157 typedef void (*hook)(__collected_data__ *odata, short object, short operation, void *udata);158 159 /*160 * constructor161 */162 xexec();163 164 /**165 * destructor166 */167 virtual ~xexec();168 169 /**170 * set function that will be executed before/after the main action call171 * @return exec identificator172 * @param type defines type of hook, @see xexec::actionEnum173 * @param func defines function that will be called174 * @param data defines hook data175 */176 int addXExec(short type,177 hook func,178 void *data);179 180 #ifdef DL_EXT 181 /**182 * set function that will be executed before and/or after the main action call183 * @param path defines path to the library[if not in ldconfig db] or library name184 * @param data defines hook data185 * @param initData defines data that will be passed to the init function186 * @param preExecId defines pre-exec identificator if hook was set or -1187 * @param postExecId defines post-exec identificator if hook was set or -1188 * @note type of hook is defined in module189 */190 void addXExec(const dodoString &path,191 void *data,192 int&preExecId,193 int&postExecId,194 void *initData = NULL);195 #endif 196 197 /**198 * delete hook199 * @param id defines exec identificator200 */201 void removeXExec(int id);202 203 /**204 * enable/disable other hooks during hook execution205 * @note this prevents recursive hooks calls206 * true by default207 */208 bool safeXExecs;209 210 mutable bool disableXExecs;///< if true hooks are disabled211 212 #ifdef DL_EXT 213 /**214 * @return information about module215 * @param path defines path to the library[if not in ldconfig db] or library name216 * @param initData defines data that will be passed to the init function217 */218 static __module__ module(const dodoString &path,219 void *initData = NULL);220 #endif 221 222 protected:223 224 /**225 * perform preExec hooks226 * @param operation defines what operation initiated the hook227 */228 void performPreExec(short operation) const;229 230 /**231 * perform preExec hooks232 * @param operation defines what operation initiated the hook233 */234 void performPostExec(short operation) const;235 236 private:237 238 /**239 * @struct __item__240 * @brief defines xexec node241 */242 struct __item__ {243 hook func;///< function to execute244 void *data;///< user data245 int id;///< object identificator246 #ifdef DL_EXT 247 void *handle;///< handle to library248 #endif 249 };250 251 /**252 * @return true if found253 * @param list defines list of hooks254 * @param id defines XExec identificator255 */256 bool getXexec(dodoList<__item__> &list,257 intid);258 259 /**260 * set hook function261 * @return postExec identificator262 * @param list defines list of hooks263 * @param func defines function that will be called264 * @param data defines hook data265 */266 int addXExec(dodoList<__item__> &list,267 hookfunc,268 void*data);269 270 /**271 * perform enabled hooks272 * @param list defines list of hooks273 * @param operation defines what operation initiated the hook274 */275 void performXExec(dodoList<__item__> &list,276 shortoperation) const;277 278 mutable dodoList<__item__> preExec;///< preExec hooks279 mutable dodoList<__item__> postExec;///< postExec hooks280 281 int execs; ///< hook counter282 283 dodoList<__item__>::iterator current;///< iterator for list[for matched with getXexec method]284 285 short execObject; ///< type of object, @see xexec::objectEnum286 __collected_data__ *execObjectData;///< object data287 };38 /** 39 * example of exec function that performs xexec 40 * 41 * void 42 * derivedClass::exec() 43 * { 44 * performXExec(preExec); 45 * ///< execute routine 46 * performXExec(postExec); 47 * } 48 */ 49 50 /** 51 * @class xexec 52 * @brief provides pre/post exec actions for defrived classes 53 */ 54 class xexec { 55 private: 56 57 /* 58 * copy constructor 59 * @note to prevent copying 60 */ 61 xexec(const xexec &); 62 63 public: 64 65 #ifdef DL_EXT 66 /** 67 * @struct __module__ 68 * @brief is returned from initModule in the library 69 */ 70 struct __module__ { 71 char name[64]; ///< name of the library 72 char discription[256]; ///< discription of the library 73 char hook[64]; ///< name of function in the library that will be used as hook 74 short type; ///< type of hook, @see xexec::actionEnum, could me grouped with OR 75 }; 76 77 /** 78 * @typedef initModule 79 * @brief defines type of init function for library 80 * @param data defines user data 81 * @note name in the library must be initXexecModule 82 */ 83 typedef __module__ (*initModule)(void *data); 84 85 /** 86 * @typedef deinitModule 87 * @brief defines type of deinit function for library 88 * @note name in the library must be deinitXexecModule 89 */ 90 typedef void (*deinitModule)(); 91 #endif 92 93 /** 94 * @enum objectEnum defines objects that access xexec 95 */ 96 enum objectEnum { 97 OBJECT_XEXEC, 98 OBJECT_DATABASEMYSQL, 99 OBJECT_DATABASESQLITE, 100 OBJECT_DATABASEPOSTGRESQL, 101 OBJECT_IOSTDIO, 102 OBJECT_IOFILEREGULAR, 103 OBJECT_IOFILETEMP, 104 OBJECT_IOFILEFIFO, 105 OBJECT_IOPIPE, 106 OBJECT_IOMEMORY, 107 OBJECT_IONETWORKCLIENT, 108 OBJECT_IONETWORKSERVER, 109 OBJECT_IONETWORKEXCHANGE, 110 OBJECT_IONETWORKSSLCLIENT, 111 OBJECT_IONETWORKSSLSERVER, 112 OBJECT_IONETWORKSSLEXCHANGE, 113 OBJECT_CGIFASTEXCHANGE, 114 OBJECT_CGIBASICEXCHANGE, 115 OBJECT_GRAPHICSIMAGE, 116 }; 117 118 /** 119 * @enum actionEnum defines what type of exec[pre/post] will be used for module 120 */ 121 enum actionEnum { 122 ACTION_PREEXEC = 2, 123 ACTION_POSTEXEC = 4, 124 }; 125 126 /** 127 * @class __collected_data__ 128 * @brief defines data that could be retrieved from the object where xexec action raised 129 */ 130 class __collected_data__ { 131 public: 132 133 /** 134 * constructor 135 * @param executor defines class that executed hook 136 * @param execObject defines type of object that executed a hook, @see xexec::objectEnum 137 */ 138 __collected_data__(xexec *executor, 139 short execObject); 140 141 /** 142 * @param execObject defines type of object that executed a hook, @see xexec::objectEnum 143 */ 144 void setExecObject(short execObject); 145 146 xexec *executor; ///< class that executed hook 147 }; 148 149 /** 150 * @typedef hook 151 * @brief defines function that will be called as hook 152 * @param operation defines what operation initiated the hook 153 * @param odata defines object data 154 * @param object defines type of object that called hook, @see xexec::objectEnum 155 * @param udata defines user data 156 */ 157 typedef void (*hook)(__collected_data__ *odata, short object, short operation, void *udata); 158 159 /* 160 * constructor 161 */ 162 xexec(); 163 164 /** 165 * destructor 166 */ 167 virtual ~xexec(); 168 169 /** 170 * set function that will be executed before/after the main action call 171 * @return exec identificator 172 * @param type defines type of hook, @see xexec::actionEnum 173 * @param func defines function that will be called 174 * @param data defines hook data 175 */ 176 int addXExec(short type, 177 hook func, 178 void *data); 179 180 #ifdef DL_EXT 181 /** 182 * set function that will be executed before and/or after the main action call 183 * @param path defines path to the library[if not in ldconfig db] or library name 184 * @param data defines hook data 185 * @param initData defines data that will be passed to the init function 186 * @param preExecId defines pre-exec identificator if hook was set or -1 187 * @param postExecId defines post-exec identificator if hook was set or -1 188 * @note type of hook is defined in module 189 */ 190 void addXExec(const dodoString &path, 191 void *data, 192 int &preExecId, 193 int &postExecId, 194 void *initData = NULL); 195 #endif 196 197 /** 198 * delete hook 199 * @param id defines exec identificator 200 */ 201 void removeXExec(int id); 202 203 /** 204 * enable/disable other hooks during hook execution 205 * @note this prevents recursive hooks calls 206 * true by default 207 */ 208 bool safeXExecs; 209 210 mutable bool disableXExecs; ///< if true hooks are disabled 211 212 #ifdef DL_EXT 213 /** 214 * @return information about module 215 * @param path defines path to the library[if not in ldconfig db] or library name 216 * @param initData defines data that will be passed to the init function 217 */ 218 static __module__ module(const dodoString &path, 219 void *initData = NULL); 220 #endif 221 222 protected: 223 224 /** 225 * perform preExec hooks 226 * @param operation defines what operation initiated the hook 227 */ 228 void performPreExec(short operation) const; 229 230 /** 231 * perform preExec hooks 232 * @param operation defines what operation initiated the hook 233 */ 234 void performPostExec(short operation) const; 235 236 private: 237 238 /** 239 * @struct __item__ 240 * @brief defines xexec node 241 */ 242 struct __item__ { 243 hook func; ///< function to execute 244 void *data; ///< user data 245 int id; ///< object identificator 246 #ifdef DL_EXT 247 void *handle; ///< handle to library 248 #endif 249 }; 250 251 /** 252 * @return true if found 253 * @param list defines list of hooks 254 * @param id defines XExec identificator 255 */ 256 bool getXexec(dodoList<__item__> &list, 257 int id); 258 259 /** 260 * set hook function 261 * @return postExec identificator 262 * @param list defines list of hooks 263 * @param func defines function that will be called 264 * @param data defines hook data 265 */ 266 int addXExec(dodoList<__item__> &list, 267 hook func, 268 void *data); 269 270 /** 271 * perform enabled hooks 272 * @param list defines list of hooks 273 * @param operation defines what operation initiated the hook 274 */ 275 void performXExec(dodoList<__item__> &list, 276 short operation) const; 277 278 mutable dodoList<__item__> preExec; ///< preExec hooks 279 mutable dodoList<__item__> postExec; ///< postExec hooks 280 281 int execs; ///< hook counter 282 283 dodoList<__item__>::iterator current; ///< iterator for list[for matched with getXexec method] 284 285 short execObject; ///< type of object, @see xexec::objectEnum 286 __collected_data__ *execObjectData; ///< object data 287 }; 288 288 }; 289 289 #endif -
trunk/src/exceptionBasic.cc
r1379 r1382 1077 1077 __module__ mod = init(toInit); 1078 1078 1079 deinitModule deinit = (deinitModule)dlsym(handle, "deinitExceptionBasicModule"); 1080 if (deinit != NULL) 1081 deinit(); 1082 1079 1083 #ifndef DL_FAST 1080 1084 if (dlclose(handle) != 0) -
trunk/src/exceptionBasic.cc
r1380 r1382 53 53 54 54 bool basic::handlerMap[] = { 55 false, 56 false, 57 false, 58 false, 59 false, 60 false, 61 false, 62 false, 63 false, 64 false, 65 false, 66 false, 67 false, 68 false, 69 false, 70 false, 71 false, 72 false, 73 false, 74 false, 75 false, 76 false, 77 false, 78 false, 79 false, 80 false, 81 false, 82 false, 83 false, 84 false, 85 false, 86 false, 87 false, 88 false, 89 false, 90 false, 91 false, 92 false, 93 false, 94 false, 95 false, 96 false, 97 false, 98 false, 99 false, 100 false, 101 false, 102 false, 103 false, 104 false 55 false, 56 false, 57 false, 58 false, 59 false, 60 false, 61 false, 62 false, 63 false, 64 false, 65 false, 66 false, 67 false, 68 false, 69 false, 70 false, 71 false, 72 false, 73 false, 74 false, 75 false, 76 false, 77 false, 78 false, 79 false, 80 false, 81 false, 82 false, 83 false, 84 false, 85 false, 86 false, 87 false, 88 false, 89 false, 90 false, 91 false, 92 false, 93 false, 94 false, 95 false, 96 false, 97 false, 98 false, 99 false, 100 false 105 101 }; 106 102 … … 108 104 109 105 basic::handler basic::handlers[] = { 110 NULL, 111 NULL, 112 NULL, 113 NULL, 114 NULL, 115 NULL, 116 NULL, 117 NULL, 118 NULL, 119 NULL, 120 NULL, 121 NULL, 122 NULL, 123 NULL, 124 NULL, 125 NULL, 126 NULL, 127 NULL, 128 NULL, 129 NULL, 130 NULL, 131 NULL, 132 NULL, 133 NULL, 134 NULL, 135 NULL, 136 NULL, 137 NULL, 138 NULL, 139 NULL, 140 NULL, 141 NULL, 142 NULL, 143 NULL, 144 NULL, 145 NULL, 146 NULL, 147 NULL, 148 NULL, 149 NULL, 150 NULL, 151 NULL, 152 NULL, 153 NULL, 154 NULL, 155 NULL, 156 NULL, 157 NULL, 158 NULL, 159 NULL 106 NULL, 107 NULL, 108 NULL, 109 NULL, 110 NULL, 111 NULL, 112 NULL, 113 NULL, 114 NULL, 115 NULL, 116 NULL, 117 NULL, 118 NULL, 119 NULL, 120 NULL, 121 NULL, 122 NULL, 123 NULL, 124 NULL, 125 NULL, 126 NULL, 127 NULL, 128 NULL, 129 NULL, 130 NULL, 131 NULL, 132 NULL, 133 NULL, 134 NULL, 135 NULL, 136 NULL, 137 NULL, 138 NULL, 139 NULL, 140 NULL, 141 NULL, 142 NULL, 143 NULL, 144 NULL, 145 NULL, 146 NULL, 147 NULL, 148 NULL, 149 NULL, 150 NULL, 151 NULL 160 152 }; 161 153 … … 163 155 164 156 void *basic::handlerData[] = { 165 NULL, 166 NULL, 167 NULL, 168 NULL, 169 NULL, 170 NULL, 171 NULL, 172 NULL, 173 NULL, 174 NULL, 175 NULL, 176 NULL, 177 NULL, 178 NULL, 179 NULL, 180 NULL, 181 NULL, 182 NULL, 183 NULL, 184 NULL, 185 NULL, 186 NULL, 187 NULL, 188 NULL, 189 NULL, 190 NULL, 191 NULL, 192 NULL, 193 NULL, 194 NULL, 195 NULL, 196 NULL, 197 NULL, 198 NULL, 199 NULL, 200 NULL, 201 NULL, 202 NULL, 203 NULL, 204 NULL, 205 NULL, 206 NULL, 207 NULL, 208 NULL, 209 NULL, 210 NULL, 211 NULL, 212 NULL, 213 NULL, 214 NULL 157 NULL, 158 NULL, 159 NULL, 160 NULL, 161 NULL, 162 NULL, 163 NULL, 164 NULL, 165 NULL, 166 NULL, 167 NULL, 168 NULL, 169 NULL, 170 NULL, 171 NULL, 172 NULL, 173 NULL, 174 NULL, 175 NULL, 176 NULL, 177 NULL, 178 NULL, 179 NULL, 180 NULL, 181 NULL, 182 NULL, 183 NULL, 184 NULL, 185 NULL, 186 NULL, 187 NULL, 188 NULL, 189 NULL, 190 NULL, 191 NULL, 192 NULL, 193 NULL, 194 NULL, 195 NULL, 196 NULL, 197 NULL, 198 NULL, 199 NULL, 200 NULL, 201 NULL, 202 NULL 215 203 }; 216 204 … … 219 207 #ifdef DL_EXT 220 208 bool basic::handlesOpened[] = { 221 false, 222 false, 223 false, 224 false, 225 false, 226 false, 227 false, 228 false, 229 false, 230 false, 231 false, 232 false, 233 false, 234 false, 235 false, 236 false, 237 false, 238 false, 239 false, 240 false, 241 false, 242 false, 243 false, 244 false, 245 false, 246 false, 247 false, 248 false, 249 false, 250 false, 251 false, 252 false, 253 false, 254 false, 255 false, 256 false, 257 false, 258 false, 259 false, 260 false, 261 false, 262 false, 263 false, 264 false, 265 false, 266 false, 267 false, 268 false, 269 false 209 false, 210 false, 211 false, 212 false, 213 false, 214 false, 215 false, 216 false, 217 false, 218 false, 219 false, 220 false, 221 false, 222 false, 223 false, 224 false, 225 false, 226 false, 227 false, 228 false, 229 false, 230 false, 231 false, 232 false, 233 false, 234 false, 235 false, 236 false, 237 false, 238 false, 239 false, 240 false, 241 false, 242 false, 243 false, 244 false, 245 false, 246 false, 247 false, 248 false, 249 false, 250 false, 251 false, 252 false, 253 false 270 254 }; 271 255 … … 273 257 274 258 void *basic::handles[] = { 275 NULL, 276 NULL, 277 NULL, 278 NULL, 279 NULL, 280 NULL, 281 NULL, 282 NULL, 283 NULL, 284 NULL, 285 NULL, 286 NULL, 287 NULL, 288 NULL, 289 NULL, 290 NULL, 291 NULL, 292 NULL, 293 NULL, 294 NULL, 295 NULL, 296 NULL, 297 NULL, 298 NULL, 299 NULL, 300 NULL, 301 NULL, 302 NULL, 303 NULL, 304 NULL, 305 NULL, 306 NULL, 307 NULL, 308 NULL, 309 NULL, 310 NULL, 311 NULL, 312 NULL, 313 NULL, 314 NULL, 315 NULL, 316 NULL, 317 NULL, 318 NULL, 319 NULL, 320 NULL, 321 NULL, 322 NULL, 323 NULL, 324 NULL 259 NULL, 260 NULL, 261 NULL, 262 NULL, 263 NULL, 264 NULL, 265 NULL, 266 NULL, 267 NULL, 268 NULL, 269 NULL, 270 NULL, 271 NULL, 272 NULL, 273 NULL, 274 NULL, 275 NULL, 276 NULL, 277 NULL, 278 NULL, 279 NULL, 280 NULL, 281 NULL, 282 NULL, 283 NULL, 284 NULL, 285 NULL, 286 NULL, 287 NULL, 288 NULL, 289 NULL, 290 NULL, 291 NULL, 292 NULL, 293 NULL, 294 NULL, 295 NULL, 296 NULL, 297 NULL, 298 NULL, 299 NULL, 300 NULL, 301 NULL, 302 NULL, 303 NULL, 304 NULL 325 305 }; 326 306 #endif … … 328 308 //------------------------------------------------------------------- 329 309 310 basic::sync::stack::stack() 311 { 330 312 #ifdef PTHREAD_EXT 331 pthread_mutex_t basic::syncThreadSection::keeper; 332 #endif 333 334 //------------------------------------------------------------------- 335 336 basic::syncThreadSection basic::keeper; 337 338 //------------------------------------------------------------------- 339 340 basic::syncThreadSection::syncThreadSection() 313 static pthread_mutex_t mutex; 314 static unsigned char mutex_init = 0; 315 if (!mutex_init) { 316 pthread_mutexattr_t attr; 317 pthread_mutexattr_init(&attr); 318 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 319 320 pthread_mutex_init(&mutex, &attr); 321 322 pthread_mutexattr_destroy(&attr); 323 324 mutex_init = 1; 325 } 326 327 keeper = &mutex; 328 329 pthread_mutex_lock((pthread_mutex_t *)keeper); 330 #endif 331 } 332 333 //------------------------------------------------------------------- 334 335 basic::sync::stack::~stack() 341 336 { 342 337 #ifdef PTHREAD_EXT 343 pthread_mutexattr_t attr; 344 pthread_mutexattr_init(&attr); 345 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 346 347 pthread_mutex_init(&keeper, &attr); 348 349 pthread_mutexattr_destroy(&attr); 350 #endif 351 } 352 353 //------------------------------------------------------------------- 354 355 basic::syncThreadSection::~syncThreadSection() 356 { 357 #ifdef PTHREAD_EXT 358 pthread_mutex_destroy(&keeper); 359 #endif 360 } 361 362 //------------------------------------------------------------------- 363 364 void 365 basic::syncThreadSection::acquire() 366 { 367 #ifdef PTHREAD_EXT 368 pthread_mutex_lock(&keeper); 369 #endif 370 } 371 372 //------------------------------------------------------------------- 373 374 void 375 basic::syncThreadSection::release() 376 { 377 #ifdef PTHREAD_EXT 378 pthread_mutex_unlock(&keeper); 379 #endif 380 } 381 382 //------------------------------------------------------------------- 383 384 basic::syncThreadStack::syncThreadStack() 385 { 386 keeper.acquire(); 387 } 388 389 //------------------------------------------------------------------- 390 391 basic::syncThreadStack::~syncThreadStack() 392 { 393 keeper.release(); 338 pthread_mutex_unlock((pthread_mutex_t *)keeper); 339 #endif 394 340 } 395 341 … … 398 344 basic::basic() throw () 399 345 { 400 instances = 1;346 instances = 1; 401 347 } 402 348 … … 404 350 405 351 basic::basic(int a_module, 406 int functionID,407 int errnoSource,408 int a_errno,409 const dodoString &a_errstr,410 unsigned long a_line,411 const dodoString &a_file,412 const dodoString &a_message) throw () : source(a_module),413 function(functionID),414 errnoSource(errnoSource),415 errNo(a_errno),416 errStr(a_errstr),417 line(a_line),418 file(a_file),419 message(a_message)420 { 421 syncThreadStack tg;352 int functionID, 353 int errnoSource, 354 int a_errno, 355 const dodoString &a_errstr, 356 unsigned long a_line, 357 const dodoString &a_file, 358 const dodoString &a_message) throw () : source(a_module), 359 function(functionID), 360 errnoSource(errnoSource), 361 errNo(a_errno), 362 errStr(a_errstr), 363 line(a_line), 364 file(a_file), 365 message(a_message) 366 { 367 sync::stack tg; 422 368 423 369 #ifdef __GNUC__ 424 using namespace abi; 425 426 __call__ call; 427 428 #ifdef DL_EXT 429 Dl_info dlinfo; 430 const char *symname; 431 char *demangled; 432 int status; 433 #endif 434 435 for (int i=0;i<CALLSTACK_MAXLEN;++i) { 436 switch (i) { 437 case 0: 438 if(!__builtin_frame_address(0)) 439 goto handle; 440 call.address = __builtin_return_address(0); 441 break; 442 case 1: 443 if(!__builtin_frame_address(1)) 444 goto handle; 445 call.address = __builtin_return_address(1); 446 break; 447 case 2: 448 if(!__builtin_frame_address(2)) 449 goto handle; 450 call.address = __builtin_return_address(2); 451 break; 452 case 3: 453 if(!__builtin_frame_address(3)) 454 goto handle; 455 call.address = __builtin_return_address(3); 456 break; 457 case 4: 458 if(!__builtin_frame_address(4)) 459 goto handle; 460 call.address = __builtin_return_address(4); 461 break; 462 case 5: 463 if(!__builtin_frame_address(5)) 464 goto handle; 465 call.address = __builtin_return_address(5); 466 break; 467 case 6: 468 if(!__builtin_frame_address(6)) 469 goto handle; 470 call.address = __builtin_return_address(6); 471 break; 472 case 7: 473 if(!__builtin_frame_address(7)) 474 goto handle; 475 call.address = __builtin_return_address(7); 476 break; 477 case 8: 478 if(!__builtin_frame_address(8)) 479 goto handle; 480 call.address = __builtin_return_address(8); 481 break; 482 case 9: 483 if(!__builtin_frame_address(9)) 484 goto handle; 485 call.address = __builtin_return_address(9); 486 break; 487 case 10: 488 if(!__builtin_frame_address(10)) 489 goto handle; 490 call.address = __builtin_return_address(10); 491 break; 492 case 11: 493 if(!__builtin_frame_address(11)) 494 goto handle; 495 call.address = __builtin_return_address(11); 496 break; 497 case 12: 498 if(!__builtin_frame_address(12)) 499 goto handle; 500 call.address = __builtin_return_address(12); 501 break; 502 case 13: 503 if(!__builtin_frame_address(13)) 504 goto handle; 505 call.address = __builtin_return_address(13); 506 break; 507 case 14: 508 if(!__builtin_frame_address(14)) 509 goto handle; 510 call.address = __builtin_return_address(14); 511 break; 512 case 15: 513 if(!__builtin_frame_address(15)) 514 goto handle; 515 call.address = __builtin_return_address(15); 516 break; 517 case 16: 518 if(!__builtin_frame_address(16)) 519 goto handle; 520 call.address = __builtin_return_address(16); 521 break; 522 case 17: 523 if(!__builtin_frame_address(17)) 524 goto handle; 525 call.address = __builtin_return_address(17); 526 break; 527 case 18: 528 if(!__builtin_frame_address(18)) 529 goto handle; 530 call.address = __builtin_return_address(18); 531 break; 532 case 19: 533 if(!__builtin_frame_address(19)) 534 goto handle; 535 call.address = __builtin_return_address(19); 536 break; 537 case 20: 538 if(!__builtin_frame_address(20)) 539 goto handle; 540 call.address = __builtin_return_address(20); 541 break; 542 case 21: 543 if(!__builtin_frame_address(21)) 544 goto handle; 545 call.address = __builtin_return_address(21); 546 break; 547 case 22: 548 if(!__builtin_frame_address(22)) 549 goto handle; 550 call.address = __builtin_return_address(22); 551 break; 552 case 23: 553 if(!__builtin_frame_address(23)) 554 goto handle; 555 call.address = __builtin_return_address(23); 556 break; 557 case 24: 558 if(!__builtin_frame_address(24)) 559 goto handle; 560 call.address = __builtin_return_address(24); 561 break; 562 case 25: 563 if(!__builtin_frame_address(25)) 564 goto handle; 565 call.address = __builtin_return_address(25); 566 break; 567 case 26: 568 if(!__builtin_frame_address(26)) 569 goto handle; 570 call.address = __builtin_return_address(26); 571 break; 572 case 27: 573 if(!__builtin_frame_address(27)) 574 goto handle; 575 call.address = __builtin_return_address(27); 576 break; 577 case 28: 578 if(!__builtin_frame_address(28)) 579 goto handle; 580 call.address = __builtin_return_address(28); 581 break; 582 case 29: 583 if(!__builtin_frame_address(29)) 584 goto handle; 585 call.address = __builtin_return_address(29); 586 break; 587 case 30: 588 if(!__builtin_frame_address(30)) 589 goto handle; 590 call.address = __builtin_return_address(30); 591 break; 592 case 31: 593 if(!__builtin_frame_address(31)) 594 goto handle; 595 call.address = __builtin_return_address(31); 596 break; 597 case 32: 598 if(!__builtin_frame_address(32)) 599 goto handle; 600 call.address = __builtin_return_address(32); 601 break; 602 case 33: 603 if(!__builtin_frame_address(33)) 604 goto handle; 605 call.address = __builtin_return_address(33); 606 break; 607 case 34: 608 if(!__builtin_frame_address(34)) 609 goto handle; 610 call.address = __builtin_return_address(34); 611 break; 612 case 35: 613 if(!__builtin_frame_address(35)) 614 goto handle; 615 call.address = __builtin_return_address(35); 616 break; 617 case 36: 618 if(!__builtin_frame_address(36)) 619 goto handle; 620 call.address = __builtin_return_address(36); 621 break; 622 case 37: 623 if(!__builtin_frame_address(37)) 624 goto handle; 625 call.address = __builtin_return_address(37); 626 break; 627 case 38: 628 if(!__builtin_frame_address(38)) 629 goto handle; 630 call.address = __builtin_return_address(38); 631 break; 632 case 39: 633 if(!__builtin_frame_address(39)) 634 goto handle; 635 call.address = __builtin_return_address(39); 636 break; 637 case 40: 638 if(!__builtin_frame_address(40)) 639 goto handle; 640 call.address = __builtin_return_address(40); 641 break; 642 case 41: 643 if(!__builtin_frame_address(41)) 644 goto handle; 645 call.address = __builtin_return_address(41); 646 break; 647 case 42: 648 if(!__builtin_frame_address(42)) 649 goto handle; 650 call.address = __builtin_return_address(42); 651 break; 652 case 43: 653 if(!__builtin_frame_address(43)) 654 goto handle; 655 call.address = __builtin_return_address(43); 656 break; 657 case 44: 658 if(!__builtin_frame_address(44)) 659 goto handle; 660 call.address = __builtin_return_address(44); 661 break; 662 case 45: 663 if(!__builtin_frame_address(45)) 664 goto handle; 665 call.address = __builtin_return_address(45); 666 break; 667 case 46: 668 if(!__builtin_frame_address(46)) 669 goto handle; 670 call.address = __builtin_return_address(46); 671 break; 672 case 47: 673 if(!__builtin_frame_address(47)) 674 goto handle; 675 call.address = __builtin_return_address(47); 676 break; 677 case 48: 678 if(!__builtin_frame_address(48)) 679 goto handle; 680 call.address = __builtin_return_address(48); 681 break; 682 case 49: 683 if(!__builtin_frame_address(49)) 684 goto handle; 685 call.address = __builtin_return_address(49); 686 break; 687 case 50: 688 if(!__builtin_frame_address(50)) 689 goto handle; 690 call.address = __builtin_return_address(50); 691 break; 692 case 51: 693 if(!__builtin_frame_address(51)) 694 goto handle; 695 call.address = __builtin_return_address(51); 696 break; 697 case 52: 698 if(!__builtin_frame_address(52)) 699 goto handle; 700 call.address = __builtin_return_address(52); 701 break; 702 case 53: 703 if(!__builtin_frame_address(53)) 704 goto handle; 705 call.address = __builtin_return_address(53); 706 break; 707 case 54: 708 if(!__builtin_frame_address(54)) 709 goto handle; 710 call.address = __builtin_return_address(54); 711 break; 712 case 55: 713 if(!__builtin_frame_address(55)) 714 goto handle; 715 call.address = __builtin_return_address(55); 716 break; 717 case 56: 718 if(!__builtin_frame_address(56)) 719 goto handle; 720 call.address = __builtin_return_address(56); 721 break; 722 case 57: 723 if(!__builtin_frame_address(57)) 724 goto handle; 725 call.address = __builtin_return_address(57); 726 break; 727 case 58: 728 if(!__builtin_frame_address(58)) 729 goto handle; 730 call.address = __builtin_return_address(58); 731 break; 732 case 59: 733 if(!__builtin_frame_address(59)) 734 goto handle; 735 call.address = __builtin_return_address(59); 736 break; 737 case 60: 738 if(!__builtin_frame_address(60)) 739 goto handle; 740 call.address = __builtin_return_address(60); 741 break; 742 case 61: 743 if(!__builtin_frame_address(61)) 744 goto handle; 745 call.address = __builtin_return_address(61); 746 break; 747 case 62: 748 if(!__builtin_frame_address(62)) 749 goto handle; 750 call.address = __builtin_return_address(62); 751 break; 752 case 63: 753 if(!__builtin_frame_address(63)) 754 goto handle; 755 call.address = __builtin_return_address(63); 756 break; 757 } 758 759 #ifdef DL_EXT 760 if (dladdr(call.address, &dlinfo) != 0) { 761 symname = dlinfo.dli_sname; 762 763 demangled = __cxa_demangle(symname, NULL, 0, &status); 764 if (status == 0 && demangled != NULL) 765 symname = demangled; 766 767 call.symbol = (symname != NULL) ? symname : "undefined"; 768 call.object = (dlinfo.dli_fname != NULL) ? dlinfo.dli_fname : "undefined"; 769 770 771 if (demangled) 772 free(demangled); 773 } 774 #endif 775 776 callStack.push_back(call); 777 } 778 779 handle: 780 #endif 781 instance(); 782 783 ++instances; 784 785 if (handlerMap[source]) 786 handlers[source](source, this, handlerData[source]); 370 using namespace abi; 371 372 __call__ call; 373 374 #ifdef DL_EXT 375 Dl_info dlinfo; 376 const char *symname; 377 char *demangled; 378 int status; 379 #endif 380 381 for (int i = 0; i < CALLSTACK_MAXLEN; ++i) { 382 switch (i) { 383 case 0: 384 if (!__builtin_frame_address(0)) 385 goto handle; 386 call.address = __builtin_return_address(0); 387 break; 388 389 case 1: 390 if (!__builtin_frame_address(1)) 391 goto handle; 392 call.address = __builtin_return_address(1); 393 break; 394 395 case 2: 396 if (!__builtin_frame_address(2)) 397 goto handle; 398 call.address = __builtin_return_address(2); 399 break; 400 401 case 3: 402 if (!__builtin_frame_address(3)) 403 goto handle; 404 call.address = __builtin_return_address(3); 405 break; 406 407 case 4: 408 if (!__builtin_frame_address(4)) 409 goto handle; 410 call.address = __builtin_return_address(4); 411 break; 412 413 case 5: 414 if (!__builtin_frame_address(5)) 415 goto handle; 416 call.address = __builtin_return_address(5); 417 break; 418 419 case 6: 420 if (!__builtin_frame_address(6)) 421 goto handle; 422 call.address = __builtin_return_address(6); 423 break; 424 425 case 7: 426 if (!__builtin_frame_address(7)) 427 goto handle; 428 call.address = __builtin_return_address(7); 429 break; 430 431 case 8: 432 if (!__builtin_frame_address(8)) 433 goto handle; 434 call.address = __builtin_return_address(8); 435 break; 436 437 case 9: 438 if (!__builtin_frame_address(9)) 439 goto handle; 440 call.address = __builtin_return_address(9); 441 break; 442 443 case 10: 444 if (!__builtin_frame_address(10)) 445 goto handle; 446 call.address = __builtin_return_address(10); 447 break; 448 449 case 11: 450 if (!__builtin_frame_address(11)) 451 goto handle; 452 call.address = __builtin_return_address(11); 453 break; 454 455 case 12: 456 if (!__builtin_frame_address(12)) 457 goto handle; 458 call.address = __builtin_return_address(12); 459 break; 460 461 case 13: 462 if (!__builtin_frame_address(13)) 463 goto handle; 464 call.address = __builtin_return_address(13); 465 break; 466 467 case 14: 468 if (!__builtin_frame_address(14)) 469 goto handle; 470 call.address = __builtin_return_address(14); 471 break; 472 473 case 15: 474 if (!__builtin_frame_address(15)) 475 goto handle; 476 call.address = __builtin_return_address(15); 477 break; 478 479 case 16: 480 if (!__builtin_frame_address(16)) 481 goto handle; 482 call.address = __builtin_return_address(16); 483 break; 484 485 case 17: 486 if (!__builtin_frame_address(17)) 487 goto handle; 488 call.address = __builtin_return_address(17); 489 break; 490 491 case 18: 492 if (!__builtin_frame_address(18)) 493 goto handle; 494 call.address = __builtin_return_address(18); 495 break; 496 497 case 19: 498 if (!__builtin_frame_address(19)) 499 goto handle; 500 call.address = __builtin_return_address(19); 501 break; 502 503 case 20: 504 if (!__builtin_frame_address(20)) 505 goto handle; 506 call.address = __builtin_return_address(20); 507 break; 508 509 case 21: 510 if (!__builtin_frame_address(21)) 511 goto handle; 512 call.address = __builtin_return_address(21); 513 break; 514 515 case 22: 516 if (!__builtin_frame_address(22)) 517 goto handle; 518 call.address = __builtin_return_address(22); 519 break; 520 521 case 23: 522 if (!__builtin_frame_address(23)) 523 goto handle; 524 call.address = __builtin_return_address(23); 525 break; 526 527 case 24: 528 if (!__builtin_frame_address(24)) 529 goto handle; 530 call.address = __builtin_return_address(24); 531 break; 532 533 case 25: 534 if (!__builtin_frame_address(25)) 535 goto handle; 536 call.address = __builtin_return_address(25); 537 break; 538 539 case 26: 540 if (!__builtin_frame_address(26)) 541 goto handle; 542 call.address = __builtin_return_address(26); 543 break; 544 545 case 27: 546 if (!__builtin_frame_address(27)) 547 goto handle; 548 call.address = __builtin_return_address(27); 549 break; 550 551 case 28: 552 if (!__builtin_frame_address(28)) 553 goto handle; 554 call.address = __builtin_return_address(28); 555 break; 556 557 case 29: 558 if (!__builtin_frame_address(29)) 559 goto handle; 560 call.address = __builtin_return_address(29); 561 break; 562 563 case 30: 564 if (!__builtin_frame_address(30)) 565 goto handle; 566 call.address = __builtin_return_address(30); 567 break; 568 569 case 31: 570 if (!__builtin_frame_address(31)) 571 goto handle; 572 call.address = __builtin_return_address(31); 573 break; 574 575 case 32: 576 if (!__builtin_frame_address(32)) 577 goto handle; 578 call.address = __builtin_return_address(32); 579 break; 580 581 case 33: 582 if (!__builtin_frame_address(33)) 583 goto handle; 584 call.address = __builtin_return_address(33); 585 break; 586 587 case 34: 588 if (!__builtin_frame_address(34)) 589 goto handle; 590 call.address = __builtin_return_address(34); 591 break; 592 593 case 35: 594 if (!__builtin_frame_address(35)) 595 goto handle; 596 call.address = __builtin_return_address(35); 597 break; 598 599 case 36: 600 if (!__builtin_frame_address(36)) 601 goto handle; 602 call.address = __builtin_return_address(36); 603 break; 604 605 case 37: 606 if (!__builtin_frame_address(37)) 607 goto handle; 608 call.address = __builtin_return_address(37); 609 break; 610 611 case 38: 612 if (!__builtin_frame_address(38)) 613 goto handle; 614 call.address = __builtin_return_address(38); 615 break; 616 617 case 39: 618 if (!__builtin_frame_address(39)) 619 goto handle; 620 call.address = __builtin_return_address(39); 621 break; 622 623 case 40: 624 if (!__builtin_frame_address(40)) 625 goto handle; 626 call.address = __builtin_return_address(40); 627 break; 628 629 case 41: 630 if (!__builtin_frame_address(41)) 631 goto handle; 632 call.address = __builtin_return_address(41); 633 break; 634 635 case 42: 636 if (!__builtin_frame_address(42)) 637 goto handle; 638 call.address = __builtin_return_address(42); 639 break; 640 641 case 43: 642 if (!__builtin_frame_address(43)) 643 goto handle; 644 call.address = __builtin_return_address(43); 645 break; 646 647 case 44: 648 if (!__builtin_frame_address(44)) 649 goto handle; 650 call.address = __builtin_return_address(44); 651 break; 652 653 case 45: 654 if (!__builtin_frame_address(45)) 655 goto handle; 656 call.address = __builtin_return_address(45); 657 break; 658 659 case 46: 660 if (!__builtin_frame_address(46)) 661 goto handle; 662 call.address = __builtin_return_address(46); 663 break; 664 665 case 47: 666 if (!__builtin_frame_address(47)) 667 goto handle; 668 call.address = __builtin_return_address(47); 669 break; 670 671 case 48: 672 if (!__builtin_frame_address(48)) 673 goto handle; 674 call.address = __builtin_return_address(48); 675 break; 676 677 case 49: 678 if (!__builtin_frame_address(49)) 679 goto handle; 680 call.address = __builtin_return_address(49); 681 break; 682 683 case 50: 684 if (!__builtin_frame_address(50)) 685 goto handle; 686 call.address = __builtin_return_address(50); 687 break; 688 689 case 51: 690 if (!__builtin_frame_address(51)) 691 goto handle; 692 call.address = __builtin_return_address(51); 693 break; 694 695 case 52: 696 if (!__builtin_frame_address(52)) 697 goto handle; 698 call.address = __builtin_return_address(52); 699 break; 700 701 case 53: 702 if (!__builtin_frame_address(53)) 703 goto handle; 704 call.address = __builtin_return_address(53); 705 break; 706 707 case 54: 708 if (!__builtin_frame_address(54)) 709 goto handle; 710 call.address = __builtin_return_address(54); 711 break; 712 713 case 55: 714 if (!__builtin_frame_address(55)) 715 goto handle; 716 call.address = __builtin_return_address(55); 717 break; 718 719 case 56: 720 if (!__builtin_frame_address(56)) 721 goto handle; 722 call.address = __builtin_return_address(56); 723 break; 724 725 case 57: 726 if (!__builtin_frame_address(57)) 727 goto handle; 728 call.address = __builtin_return_address(57); 729 break; 730 731 case 58: 732 if (!__builtin_frame_address(58)) 733 goto handle; 734 call.address = __builtin_return_address(58); 735 break; 736 737 case 59: 738 if (!__builtin_frame_address(59)) 739 goto handle; 740 call.address = __builtin_return_address(59); 741 break; 742 743 case 60: 744 if (!__builtin_frame_address(60)) 745 goto handle; 746 call.address = __builtin_return_address(60); 747 break; 748 749 case 61: 750 if (!__builtin_frame_address(61)) 751 goto handle; 752 call.address = __builtin_return_address(61); 753 break; 754 755 case 62: 756 if (!__builtin_frame_address(62)) 757 goto handle; 758 call.address = __builtin_return_address(62); 759 break; 760 761 case 63: 762 if (!__builtin_frame_address(63)) 763 goto handle; 764 call.address = __builtin_return_address(63); 765 break; 766 } 767 768 #ifdef DL_EXT 769 if (dladdr(call.address, &dlinfo) != 0) { 770 symname = dlinfo.dli_sname; 771 772 demangled = __cxa_demangle(symname, NULL, 0, &status); 773 if (status == 0 && demangled != NULL) 774 symname = demangled; 775 776 call.symbol = (symname != NULL) ? symname : "undefined"; 777 call.object = (dlinfo.dli_fname != NULL) ? dlinfo.dli_fname : "undefined"; 778 779 780 if (demangled) 781 free(demangled); 782 } 783 #endif 784 785 callStack.push_back(call); 786 } 787 788 handle: 789 #endif 790 instance(); 791 792 ++instances; 793 794 if (handlerMap[source]) 795 handlers[source](source, this, handlerData[source]); 787 796 } 788 797 … … 791 800 basic::~basic() throw () 792 801 { 793 syncThreadStack tg;794 795 --instances;796 797 if (instances == 0) {798 #ifdef DL_EXT 799 deinitModule deinit;800 801 for (int i(0); i < MODULE_ENUMSIZE; ++i) {802 if (!handlesOpened[i])803 continue;804 805 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule");806 if (deinit != NULL)807 deinit();808 809 handlesOpened[i] = false;802 sync::stack tg; 803 804 --instances; 805 806 if (instances == 0) { 807 #ifdef DL_EXT 808 deinitModule deinit; 809 810 for (int i(0); i < MODULE_ENUMSIZE; ++i) { 811 if (!handlesOpened[i]) 812 continue; 813 814 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 815 if (deinit != NULL) 816 deinit(); 817 818 handlesOpened[i] = false; 810 819 811 820 #ifndef DL_FAST 812 dlclose(handles[i]);813 #endif 814 }815 #endif 816 }821 dlclose(handles[i]); 822 #endif 823 } 824 #endif 825 } 817 826 } 818 827 … … 822 831 basic::backtrace() 823 832 { 824 dodoString stack;825 826 char str[32];827 828 dodoArray<__call__>::iterator i = callStack.begin(), j = callStack.end();829 for (; i != j; ++i) {830 snprintf(str, 32, " [0x%lx]", (long)i->address);831 stack.append(i->object + ": " + i->symbol + dodoString(str) + "\n");832 }833 834 return stack;833 dodoString stack; 834 835 char str[32]; 836 837 dodoArray<__call__>::iterator i = callStack.begin(), j = callStack.end(); 838 for (; i != j; ++i) { 839 snprintf(str, 32, " [0x%lx]", (long)i->address); 840 stack.append(i->object + ": " + i->symbol + dodoString(str) + "\n"); 841 } 842 843 return stack; 835 844 } 836 845 … … 840 849 & () 841 850 { 842 syncThreadStack tg;843 844 return errStr;851 sync::stack tg; 852 853 return errStr; 845 854 } 846 855 … … 850 859 basic::what() const throw () 851 860 { 852 syncThreadStack tg;853 854 return errStr.data();861 sync::stack tg; 862 863 return errStr.data(); 855 864 } 856 865 … … 859 868 void 860 869 basic::setHandler(moduleEnum module, 861 handler handler,862 void*data)863 { 864 syncThreadStack tg;865 866 instance();867 868 #ifdef DL_EXT 869 if (handlesOpened[module]) {870 deinitModule deinit;871 872 deinit = (deinitModule)dlsym(handles[module], "deinitExceptionBasicModule");873 if (deinit != NULL)874 deinit();870 handler handler, 871 void *data) 872 { 873 sync::stack tg; 874 875 instance(); 876 877 #ifdef DL_EXT 878 if (handlesOpened[module]) { 879 deinitModule deinit; 880 881 deinit = (deinitModule)dlsym(handles[module], "deinitExceptionBasicModule"); 882 if (deinit != NULL) 883 deinit(); 875 884 876 885 #ifndef DL_FAST 877 dlclose(handles[module]);878 #endif 879 880 handlesOpened[module] = false;881 handles[module] = NULL;882 }883 #endif 884 885 handlers[module] = handler;886 handlerMap[module] = true;887 handlerData[module] = data;886 dlclose(handles[module]); 887 #endif 888 889 handlesOpened[module] = false; 890 handles[module] = NULL; 891 } 892 #endif 893 894 handlers[module] = handler; 895 handlerMap[module] = true; 896 handlerData[module] = data; 888 897 } 889 898 … … 892 901 void 893 902 basic::setHandler(handler handler, 894 void*data)895 { 896 syncThreadStack tg;897 898 instance();899 900 #ifdef DL_EXT 901 deinitModule deinit;902 #endif 903 904 for (int i(0); i < MODULE_ENUMSIZE; ++i) {905 #ifdef DL_EXT 906 if (handlesOpened[i]) {907 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule");908 if (deinit != NULL)909 deinit();903 void *data) 904 { 905 sync::stack tg; 906 907 instance(); 908 909 #ifdef DL_EXT 910 deinitModule deinit; 911 #endif 912 913 for (int i(0); i < MODULE_ENUMSIZE; ++i) { 914 #ifdef DL_EXT 915 if (handlesOpened[i]) { 916 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 917 if (deinit != NULL) 918 deinit(); 910 919 911 920 #ifndef DL_FAST 912 dlclose(handles[i]);913 #endif 914 915 handlesOpened[i] = false;916 handles[i] = NULL;917 }918 #endif 919 920 handlers[i] = handler;921 handlerMap[i] = true;922 handlerData[i] = data;923 }921 dlclose(handles[i]); 922 #endif 923 924 handlesOpened[i] = false; 925 handles[i] = NULL; 926 } 927 #endif 928 929 handlers[i] = handler; 930 handlerMap[i] = true; 931 handlerData[i] = data; 932 } 924 933 } 925 934 … … 929 938 basic::removeHandler(moduleEnum module) 930 939 { 931 syncThreadStack tg;932 933 #ifdef DL_EXT 934 if (handlesOpened[module]) {935 deinitModule deinit;936 937 deinit = (deinitModule)dlsym(handles[module], "deinitExceptionBasicModule");938 if (deinit != NULL)939 deinit();940 sync::stack tg; 941 942 #ifdef DL_EXT 943 if (handlesOpened[module]) { 944 deinitModule deinit; 945 946 deinit = (deinitModule)dlsym(handles[module], "deinitExceptionBasicModule"); 947 if (deinit != NULL) 948 deinit(); 940 949 941 950 #ifndef DL_FAST 942 dlclose(handles[module]);943 #endif 944 945 handlesOpened[module] = false;946 handles[module] = NULL;947 }948 #endif 949 950 handlers[module] = NULL;951 handlerMap[module] = false;952 handlerData[module] = NULL;951 dlclose(handles[module]); 952 #endif 953 954 handlesOpened[module] = false; 955 handles[module] = NULL; 956 } 957 #endif 958 959 handlers[module] = NULL; 960 handlerMap[module] = false; 961 handlerData[module] = NULL; 953 962 } 954 963 … … 958 967 basic::removeHandlers() 959 968 { 960 syncThreadStack tg;961 962 #ifdef DL_EXT 963 deinitModule deinit;964 #endif 965 966 for (int i(0); i < MODULE_ENUMSIZE; ++i) {967 #ifdef DL_EXT 968 if (handlesOpened[i]) {969 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule");970 if (deinit != NULL)971 deinit();969 sync::stack tg; 970 971 #ifdef DL_EXT 972 deinitModule deinit; 973 #endif 974 975 for (int i(0); i < MODULE_ENUMSIZE; ++i) { 976 #ifdef DL_EXT 977 if (handlesOpened[i]) { 978 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 979 if (deinit != NULL) 980 deinit(); 972 981 973 982 #ifndef DL_FAST 974 dlclose(handles[i]);975 #endif 976 977 handlesOpened[i] = false;978 handles[i] = NULL;979 }980 #endif 981 982 handlers[i] = NULL;983 handlerMap[i] = false;984 handlerData[i] = NULL;985 }983 dlclose(handles[i]); 984 #endif 985 986 handlesOpened[i] = false; 987 handles[i] = NULL; 988 } 989 #endif 990 991 handlers[i] = NULL; 992 handlerMap[i] = false; 993 handlerData[i] = NULL; 994 } 986 995 } 987 996 … … 991 1000 void 992 1001 basic::setHandler(const dodoString &path, 993 void *data,994 void *toInit)995 { 996 syncThreadStack tg;997 998 instance();1002 void *data, 1003 void *toInit) 1004 { 1005 sync::stack tg; 1006 1007 instance(); 999 1008 1000 1009 #ifdef DL_FAST 1001 void *h = dlopen(path.data(), RTLD_LAZY | RTLD_NODELETE);1010 void *h = dlopen(path.data(), RTLD_LAZY | RTLD_NODELETE); 1002 1011 #else 1003 void *h = dlopen(path.data(), RTLD_LAZY);1004 #endif 1005 if (h == NULL)1006 return;1007 1008 initModule init = (initModule)dlsym(h, "initExceptionBasicModule");1009 if (init == NULL)1010 return;1011 1012 __module__ mod = init(toInit);1013 1014 deinitModule deinit;1015 1016 for (int i=0;i<MODULE_ENUMSIZE;++i) {1017 if (!mod.modules[i])1018 continue;1019 1020 if (handlesOpened[i]) {1021 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule");1022 if (deinit != NULL)1023 deinit();1012 void *h = dlopen(path.data(), RTLD_LAZY); 1013 #endif 1014 if (h == NULL) 1015 return; 1016 1017 initModule init = (initModule)dlsym(h, "initExceptionBasicModule"); 1018 if (init == NULL) 1019 return; 1020 1021 __module__ mod = init(toInit); 1022 1023 deinitModule deinit; 1024 1025 for (int i = 0; i < MODULE_ENUMSIZE; ++i) { 1026 if (!mod.modules[i]) 1027 continue; 1028 1029 if (handlesOpened[i]) { 1030 deinit = (deinitModule)dlsym(handles[i], "deinitExceptionBasicModule"); 1031 if (deinit != NULL) 1032 deinit(); 1024 1033 1025 1034 #ifndef DL_FAST 1026 dlclose(handles[i]);1027 #endif 1028 1029 handlesOpened[i] = false;1030 handles[i] = NULL;1031 }1032 1033 1034 handles[i] = h;1035 1036 handler in = (handler)dlsym(handles[i], mod.hook);1037 if (in == NULL)1038 continue;1039 1040 handlesOpened[i] = true;1041 1042 handlers[i] = in;1043 handlerMap[i] = true;1044 handlerData[i] = data;1045 }1035 dlclose(handles[i]); 1036 #endif 1037 1038 handlesOpened[i] = false; 1039 handles[i] = NULL; 1040 } 1041 1042 1043 handles[i] = h; 1044 1045 handler in = (handler)dlsym(handles[i], mod.hook); 1046 if (in == NULL) 1047 continue; 1048 1049 handlesOpened[i] = true; 1050 1051 handlers[i] = in; 1052 handlerMap[i] = true; 1053 handlerData[i] = data; 1054 } 1046 1055 } 1047 1056 … … 1050 1059 basic::__module__ 1051 1060 basic::module(const dodoString &module, 1052 void *toInit)1053 { 1054 syncThreadStack tg;1061 void *toInit) 1062 { 1063 sync::stack tg; 1055 1064 1056 1065 #ifdef DL_FAST 1057 void *handle = dlopen(module.data(), RTLD_LAZY | RTLD_NODELETE);1066 void *handle = dlopen(module.data(), RTLD_LAZY | RTLD_NODELETE); 1058 1067 #else 1059 void *handle = dlopen(module.data(), RTLD_LAZY);1060 #endif 1061 if (handle == NULL)1062 return __module__();1063 1064 initModule init = (initModule)dlsym(handle, "initExceptionBasicModule");1065 if (init == NULL)1066 return __module__();1067 1068 __module__ mod = init(toInit);1068 void *handle = dlopen(module.data(), RTLD_LAZY); 1069 #endif 1070 if (handle == NULL) 1071 return __module__(); 1072 1073 initModule init = (initModule)dlsym(handle, "initExceptionBasicModule"); 1074 if (init == NULL) 1075 return __module__(); 1076 1077 __module__ mod = init(toInit); 1069 1078 1070 1079 deinitModule deinit = (deinitModule)dlsym(handle, "deinitExceptionBasicModule"); … … 1073 1082 1074 1083 #ifndef DL_FAST 1075 if (dlclose(handle) != 0)1076 return mod;1077 1078 #endif 1079 1080 return mod;1081 } 1082 #endif 1083 1084 //------------------------------------------------------------------- 1085 1084 if (dlclose(handle) != 0) 1085 return mod; 1086 1087 #endif 1088 1089 return mod; 1090 } 1091 #endif 1092 1093 //------------------------------------------------------------------- 1094 -
trunk/src/xexec.cc
r1379 r1382 74 74 { 75 75 #ifdef DL_EXT 76 moduleDeinitdeinit;76 deinitModule deinit; 77 77 78 78 dodoList<__item__>::iterator i(preExec.begin()), j(preExec.end()); … … 81 81 continue; 82 82 83 deinit = ( moduleDeinit)dlsym(i->handle, "deinitXexecModule");83 deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule"); 84 84 if (deinit != NULL) 85 85 deinit(); … … 96 96 continue; 97 97 98 deinit = ( moduleDeinit)dlsym(i->handle, "deinitXexecModule");98 deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule"); 99 99 if (deinit != NULL) 100 100 deinit(); … … 143 143 #ifdef DL_EXT 144 144 if (current->handle != NULL) { 145 moduleDeinitdeinit;146 147 deinit = ( moduleDeinit)dlsym(current->handle, "deinitXexecModule");145 deinitModule deinit; 146 147 deinit = (deinitModule)dlsym(current->handle, "deinitXexecModule"); 148 148 if (deinit != NULL) 149 149 deinit(); … … 225 225 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_MODULE, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 226 226 227 moduleInit init = (moduleInit)dlsym(handle, "initXexecModule");227 initModule init = (initModule)dlsym(handle, "initXexecModule"); 228 228 if (init == NULL) 229 229 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_MODULE, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); … … 261 261 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_ADDXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 262 262 263 moduleInit init = (moduleInit)dlsym(e.handle, "initXexecModule");263 initModule init = (initModule)dlsym(e.handle, "initXexecModule"); 264 264 if (init == NULL) 265 265 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_ADDXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); … … 284 284 postExecId = e.id; 285 285 } 286 287 deinitModule deinit = (deinitModule)dlsym(e.handle, "deinitXexecModule"); 288 if (deinit == NULL) 289 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_ADDXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 290 291 deinit(); 286 292 } 287 293 -
trunk/src/xexec.cc
r1380 r1382 41 41 42 42 xexec::__collected_data__::__collected_data__(xexec *executor, 43 short execObject) : executor(executor)44 { 45 executor->execObjectData = this;46 executor->execObject = execObject;43 short execObject) : executor(executor) 44 { 45 executor->execObjectData = this; 46 executor->execObject = execObject; 47 47 } 48 48 … … 50 50 xexec::__collected_data__::setExecObject(short execObject) 51 51 { 52 executor->execObject = execObject;52 executor->execObject = execObject; 53 53 } 54 54 … … 62 62 63 63 xexec::xexec() : safeXExecs(true), 64 disableXExecs(false),65 execs(0),66 execObject(xexec::OBJECT_XEXEC),67 execObjectData(NULL)64 disableXExecs(false), 65 execs(0), 66 execObject(xexec::OBJECT_XEXEC), 67 execObjectData(NULL) 68 68 { 69 69 } … … 74 74 { 75 75 #ifdef DL_EXT 76 deinitModule deinit;77 78 dodoList<__item__>::iterator i(preExec.begin()), j(preExec.end());79 for (; i != j; ++i) {80 if (i->handle == NULL)81 continue;82 83 deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule");84 if (deinit != NULL)85 deinit();76 deinitModule deinit; 77 78 dodoList<__item__>::iterator i(preExec.begin()), j(preExec.end()); 79 for (; i != j; ++i) { 80 if (i->handle == NULL) 81 continue; 82 83 deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule"); 84 if (deinit != NULL) 85 deinit(); 86 86 87 87 #ifndef DL_FAST 88 dlclose(i->handle);89 #endif 90 }91 92 i = postExec.begin();93 j = postExec.end();94 for (; i != j; ++i) {95 if (i->handle == NULL)96 continue;97 98 deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule");99 if (deinit != NULL)100 deinit();88 dlclose(i->handle); 89 #endif 90 } 91 92 i = postExec.begin(); 93 j = postExec.end(); 94 for (; i != j; ++i) { 95 if (i->handle == NULL) 96 continue; 97 98 deinit = (deinitModule)dlsym(i->handle, "deinitXexecModule"); 99 if (deinit != NULL) 100 deinit(); 101 101 102 102 #ifndef DL_FAST 103 dlclose(i->handle);104 #endif 105 }103 dlclose(i->handle); 104 #endif 105 } 106 106 #endif 107 107 } … … 111 111 int 112 112 xexec::addXExec(dodoList<__item__> &list, 113 hookfunc,114 void*data)115 { 116 __item__ e;117 118 e.data = data;119 e.func = func;120 e.id = ++execs;121 122 #ifdef DL_EXT 123 e.handle = NULL;124 #endif 125 126 list.push_back(e);127 128 return e.id;113 hook func, 114 void *data) 115 { 116 __item__ e; 117 118 e.data = data; 119 e.func = func; 120 e.id = ++execs; 121 122 #ifdef DL_EXT 123 e.handle = NULL; 124 #endif 125 126 list.push_back(e); 127 128 return e.id; 129 129 } 130 130 … … 134 134 xexec::removeXExec(int id) 135 135 { 136 if (getXexec(preExec, id))137 preExec.erase(current);138 else if (getXexec(postExec, id))139 postExec.erase(current);140 else141 return;142 143 #ifdef DL_EXT 144 if (current->handle != NULL) {145 deinitModule deinit;146 147 deinit = (deinitModule)dlsym(current->handle, "deinitXexecModule");148 if (deinit != NULL)149 deinit();136 if (getXexec(preExec, id)) 137 preExec.erase(current); 138 else if (getXexec(postExec, id)) 139 postExec.erase(current); 140 else 141 return; 142 143 #ifdef DL_EXT 144 if (current->handle != NULL) { 145 deinitModule deinit; 146 147 deinit = (deinitModule)dlsym(current->handle, "deinitXexecModule"); 148 if (deinit != NULL) 149 deinit(); 150 150 151 151 #ifndef DL_FAST 152 if (dlclose(current->handle) != 0)153 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_REMOVEXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__);154 #endif 155 }152 if (dlclose(current->handle) != 0) 153 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_REMOVEXEXEC, exception::ERRNO_DYNLOAD, 0, dlerror(), __LINE__, __FILE__); 154 #endif 155 } 156 156 #endif 157 157 } … … 161 161 int 162 162 xexec::addXExec(short type, 163 hookfunc,164 void*data)165 { 166 if (type == ACTION_PREEXEC)167 return addXExec(preExec, func, data);168 else if (type == ACTION_POSTEXEC)169 return addXExec(postExec, func, data);170 else171 throw exception::basic(exception::MODULE_XEXEC, XEXECEX_ADDXEXEC, exception::ERRNO_LIBDODO, XEXECEX_WRONGTYPE, XEXECEX_WRONGTYPE_STR, __LINE__, __FILE__);163 hook func, 164 void *data) 165 { 166 if (type == ACTION_PREEXEC) 167 return addXExec(preExec, func, data); 168 else if (type == ACTION_POSTEXEC)
