I am looking to create a list of memory locations from which this function was called. Is this code correct? How can this be improved? Suppose integers, long integers, and pointers are 4 bytes, and char is 1 byte. Suppose compiler optimizers are not executed. Suppose a function uses / sets its arguments, return value, and local variables.
void * CalledFromArray[ARRAY_SIZE]; int CallerRecorder(int i) { int LocalVar1; int LocalVar2; CalledFromArray[i]=(void *) *( (long int *)( (char *)&LocalVar2 + 36 ) ); return 0; }
, . , GCC. , , . , const char* const pFunction , , __FUNCTION__. dlsym .
const char* const pFunction
__FUNCTION__
dlsym
#define CallerRecorder(var) CallerRecorderNew((var), __FUNCTION__) int CallerRecorderNew(int i, const char* const pFunction) { // dlsym(..., pFunction) }
Source: https://habr.com/ru/post/1621318/More articles:iOS separate scrollView & collectionView delegates in separate files - ioshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1621314/css-background-size-cover-is-too-big&usg=ALkJrhgcBUmiqTLvPzZzc1SHaumUxt4gswPandas - remove duplicate rows except one with the highest value from another column - pythonConfusion over the syntax of the dimond operator in perl analysis and simple words - syntaxIs this a valid Singleton in C # 6 - c #comparing multilevel structured arrays - pythonPrinting Stack Frames - cJavascript onClick does not work when assigned inside array.map - javascriptHttp.post error: map is not a function in Angular 2 - angularHow to use source maps with gulp? - javascriptAll Articles