Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
filter.h File Reference

Go to the source code of this file.

Functions

int insertAddress (unsigned long address)
 
void outputAddresses (char *cmd)
 
void generategdbscripts ()
 

Function Documentation

void generategdbscripts ( )

Definition at line 97 of file filter.cc.

References AddressTable::addresses, AddressTable::counter, and Detected.

Referenced by openFilter().

98 {
99  int i;
100 
101  pid_t myselfpid = getpid();
102  char gdbcommands[1024];
103  gdbcommands[0] = 0;
104  sprintf(gdbcommands, "./gdbcommands.%d", myselfpid);
105 
106  FILE *fp = fopen(gdbcommands, "w+");
107  for (i = 0 ; i < Detected.counter ; i++)
108  {
109  fprintf(fp, "break *0x%lx\n", Detected.addresses[i]);
110  fprintf(fp, "commands\n");
111  fprintf(fp, "bt 10\n");
112  fprintf(fp, "cont\n");
113  fprintf(fp, "end\n");
114  }
115  fprintf(fp, "cont\n");
116  fclose(fp);
117 }
struct AddressTable Detected
int counter
Definition: filter.cc:13
unsigned long * addresses
Definition: filter.cc:15
int insertAddress ( unsigned long  address)

Definition at line 44 of file filter.cc.

References AddressTable::addresses, assert, AddressTable::counter, Detected, findAddress(), malloc(), position, realloc(), and AddressTable::space.

Referenced by openFilter().

45 {
46  if (position == -1)
47  {
48  Detected.space = 4096;
49  assert(0 != (Detected.addresses = (unsigned long *) malloc(sizeof(unsigned long) * Detected.space)));
50  Detected.counter = 1;
51  position = 0;
52  #ifdef ADDRESSTABLEDEBUG
53  printf("Inserted position: %d, address: 0x%lx.\n", position, address);
54  #endif
55  Detected.addresses[position] = address;
56  return 0;
57  }
58  else
59  {
60  if (-1 == findAddress(address))
61  {
62  #ifdef ADDRESSTABLEDEBUG
63  printf("Inserted position: %d, address: 0x%lx.\n", position, address);
64  #endif
65  Detected.counter++;
67  {
68  Detected.space = Detected.space + 4096;
69 
70  assert(0 != (Detected.addresses = (unsigned long *) realloc((char *)Detected.addresses, sizeof(unsigned long) * Detected.space)));
71  }
72  int i;
73  for (i = Detected.counter - 1; i > position ; i--)
75  Detected.addresses[i] = address;
76 
77  return 0;
78  }
79  else
80  return -1;
81  }
82 }
struct AddressTable Detected
#define assert(x)
Definition: mymalloc.cc:1309
int space
Definition: filter.cc:14
int counter
Definition: filter.cc:13
int position
Definition: filter.cc:7
int findAddress(unsigned long address)
Definition: filter.cc:38
void * realloc(void *__ptr, size_t __size)
Definition: hjmalloc.cc:103
unsigned long * addresses
Definition: filter.cc:15
void * malloc(size_t __size)
Definition: hjmalloc.cc:30
void outputAddresses ( char *  cmd)

Definition at line 84 of file filter.cc.

References AddressTable::addresses, AddressTable::counter, and Detected.

Referenced by openFilter().

85 {
86  int i;
87  char convertcmd[1024];
88  printf("Lines that produce segmentation faults:\n");
89  for (i = 0 ; i < Detected.counter ; i++)
90  {
91  sprintf(convertcmd, "addr2line -e %s 0x%lx", cmd, Detected.addresses[i]);
92  system(convertcmd);
93  printf("%s address[%d]= 0x%lx\n", cmd, i, Detected.addresses[i]);
94  }
95 }
struct AddressTable Detected
char cmd[1024]
Definition: tracer.cxx:25
int counter
Definition: filter.cc:13
unsigned long * addresses
Definition: filter.cc:15