version 1.15, 2010/05/05 21:20:37
|
version 1.16, 2010/05/13 19:09:18
|
Line 3535 copie_etat_processus(struct_processus *s
|
Line 3535 copie_etat_processus(struct_processus *s
|
|
|
#undef fprintf |
#undef fprintf |
|
|
|
#ifdef __BACKTRACE |
#define return(a) { if (a == NULL) \ |
#define return(a) { if (a == NULL) \ |
{ BACKTRACE(20); fprintf(stderr, ">>> MEDITATION %d\n", __LINE__); } \ |
{ BACKTRACE(20); fprintf(stderr, ">>> MEDITATION %d\n", __LINE__); } \ |
return(a); } while(0) |
return(a); } while(0) |
|
#define PROFONDEUR_PILE 64 |
|
#endif |
|
|
typedef struct memoire |
typedef struct memoire |
{ |
{ |
Line 3547 typedef struct memoire
|
Line 3550 typedef struct memoire
|
unsigned long ligne; |
unsigned long ligne; |
size_t taille; |
size_t taille; |
unsigned long long ordre; |
unsigned long long ordre; |
|
# ifdef __BACKTRACE |
|
void *pile[PROFONDEUR_PILE]; |
|
int profondeur; |
|
# endif |
struct memoire *suivant; |
struct memoire *suivant; |
|
pthread_t thread; |
|
pid_t pid; |
} struct_memoire; |
} struct_memoire; |
|
|
static struct_memoire *debug = NULL; |
static struct_memoire *debug = NULL; |
Line 3582 debug_memoire_ajout(size_t taille, const
|
Line 3591 debug_memoire_ajout(size_t taille, const
|
(*debug).ligne = ligne; |
(*debug).ligne = ligne; |
(*debug).taille = taille; |
(*debug).taille = taille; |
(*debug).ordre = ordre; |
(*debug).ordre = ordre; |
|
(*debug).thread = pthread_self(); |
|
(*debug).pid = getpid(); |
|
|
|
# ifdef __BACKTRACE |
|
(*debug).profondeur = backtrace((*debug).pile, PROFONDEUR_PILE); |
|
# endif |
|
|
pthread_mutex_unlock(&mutex_allocation); |
pthread_mutex_unlock(&mutex_allocation); |
|
|
Line 3728 debug_memoire_retrait(void *pointeur)
|
Line 3743 debug_memoire_retrait(void *pointeur)
|
void |
void |
debug_memoire_verification(struct_processus *s_etat_processus) |
debug_memoire_verification(struct_processus *s_etat_processus) |
{ |
{ |
|
# ifdef __BACKTRACE |
|
char **appels; |
|
# endif |
|
|
|
int j; |
|
|
integer8 i; |
integer8 i; |
|
|
struct_memoire *element_courant; |
struct_memoire *element_courant; |
Line 3743 debug_memoire_verification(struct_proces
|
Line 3764 debug_memoire_verification(struct_proces
|
|
|
while(element_courant != NULL) |
while(element_courant != NULL) |
{ |
{ |
fprintf(stderr, "[%d-%llu] MEDITATION %lld (%llu)\n", getpid(), |
if (((*element_courant).pid == getpid()) && |
(unsigned long long) pthread_self(), i, |
(pthread_equal((*element_courant).thread, pthread_self()) != 0)) |
(*element_courant).ordre); |
|
fprintf(stderr, "[%d-%llu] P: %p, F: %s(), L: %lu, S: %d\n", |
|
getpid(), (unsigned long long) pthread_self(), |
|
(*element_courant).pointeur, |
|
(*element_courant).fonction, (*element_courant).ligne, |
|
(int) (*element_courant).taille); |
|
fprintf(stderr, "[%d-%llu] A: %s\n", getpid(), |
|
(unsigned long long) pthread_self(), |
|
(*element_courant).argument); |
|
|
|
switch(i) |
|
{ |
{ |
// Affichage des méditations |
fprintf(stderr, "[%d-%llu] MEDITATION %lld (%llu)\n", getpid(), |
case 1: |
(unsigned long long) pthread_self(), i, |
|
(*element_courant).ordre); |
|
fprintf(stderr, "[%d-%llu] P: %p, F: %s(), L: %lu, S: %d\n", |
|
getpid(), (unsigned long long) pthread_self(), |
|
(*element_courant).pointeur, |
|
(*element_courant).fonction, (*element_courant).ligne, |
|
(int) (*element_courant).taille); |
|
fprintf(stderr, "[%d-%llu] A: %s\n", getpid(), |
|
(unsigned long long) pthread_self(), |
|
(*element_courant).argument); |
|
|
|
# ifdef __BACKTRACE |
|
appels = backtrace_symbols((*element_courant).pile, |
|
(*element_courant).profondeur); |
|
|
|
fprintf(stderr, "[%d-%llu] BACKTRACE\n", |
|
getpid(), (unsigned long long) pthread_self()); |
|
|
|
if (appels != NULL) |
{ |
{ |
break; |
for(j = 0; j < (*element_courant).profondeur; j++) |
|
{ |
|
fprintf(stderr, "[%d-%llu] %s\n", getpid(), |
|
(unsigned long long) pthread_self(), appels[j]); |
|
} |
|
|
|
free(appels); |
} |
} |
} |
# endif |
|
|
|
fprintf(stderr, "\n"); |
|
|
i++; |
i++; |
|
} |
|
|
element_suivant = (*element_courant).suivant; |
element_suivant = (*element_courant).suivant; |
free((*element_courant).fonction); |
free((*element_courant).fonction); |