Exemplo n.º 1
0
int main(void)
{
    std::cout << "leakfinder C++ thread example app" << std::endl;
    std::cout << "This application is expected to leak" << std::endl;
    my_class_b b;
    b.foobar();
    b.foo();

    c_function();

    std::cout << "leakfinder C++ thread example app all done" << std::endl;
    return 0;
}
Exemplo n.º 2
0
int main() {
  printf("Calling c_new_fred\n");
  Fred* fred = c_new_fred();
  printf("Calling c_function(fred)\n");
  c_function(fred);
}
Exemplo n.º 3
0
int
main (int argc, char **argv)
{
  void *obj;
  const char *loaded[] = { NULL, NULL, NULL};
  int errors = 0;
  void (*f) (void);
  const char *dir = dirname (argv [0]);
  char *oldfilename;
  char *newfilename;

  c_function ();

  printf ("\nThis is what is in memory now:\n");
  errors += check_loaded_objects (loaded);

  printf( "Loading shared object neededobj6.so\n");
  obj = dlopen( "neededobj6.so", RTLD_LAZY);
  if (obj == NULL)
    {
      printf ("%s\n", dlerror ());
      exit (1);
    }
  f = dlsym (obj, "a2_function");
  if (f == NULL)
    {
      printf ("%s\n", dlerror ());
      exit (1);
    }
  f ();
  loaded[0] = "neededobj5.so";
  loaded[1] = "neededobj6.so";
  errors += check_loaded_objects (loaded);

  printf ("Closing neededobj6.so\n");
  dlclose (obj);
  loaded[0] = NULL;
  errors += check_loaded_objects (loaded);

  printf ("Rename neededobj5.so\n");
  oldfilename = alloca (strlen (dir) + 1 + sizeof ("neededobj5.so"));
  strcpy (oldfilename, dir);
  strcat (oldfilename, "/");
  strcat (oldfilename, "neededobj5.so");
  newfilename = alloca (strlen (oldfilename) + sizeof (".renamed"));
  strcpy (newfilename, oldfilename);
  strcat (newfilename, ".renamed");
  if (rename (oldfilename, newfilename))
    {
      perror ("rename");
      exit (1);
    }

  printf( "Loading shared object neededobj6.so\n");
  obj = dlopen( "neededobj6.so", RTLD_LAZY);
  if (obj == NULL)
    printf ("%s\n", dlerror ());
  else
    {
      printf ("neededobj6.so should fail to load\n");
      exit (1);
    }

  printf( "Loading shared object neededobj1.so\n");
  obj = dlopen( "neededobj1.so", RTLD_LAZY);
  if (obj == NULL)
    {
      printf ("%s\n", dlerror ());
      exit (1);
    }
  errors += check_loaded_objects (loaded);
  f = dlsym (obj, "c_function");
  if (f == NULL)
    {
      printf ("%s\n", dlerror ());
      exit (1);
    }
  f ();

  printf ("Restore neededobj5.so\n");
  if (rename (newfilename, oldfilename))
    {
      perror ("rename");
      exit (1);
    }

  if (errors != 0)
    printf ("%d errors found\n", errors);
  return errors;
}
Exemplo n.º 4
0
void
a_function (void)
{
  b_function ();
  c_function ();
}