Beispiel #1
0
static void
gum_allocator_probe_dispose (GObject * object)
{
  GumAllocatorProbe * self = GUM_ALLOCATOR_PROBE (object);
  GumAllocatorProbePrivate * priv = self->priv;

  if (!priv->disposed)
  {
    priv->disposed = TRUE;

    gum_allocator_probe_detach (self);

    if (priv->allocation_tracker != NULL)
    {
      g_object_unref (priv->allocation_tracker);
      priv->allocation_tracker = NULL;
    }

    if (priv->interceptor != NULL)
    {
      g_object_unref (priv->interceptor);
      priv->interceptor = NULL;
    }
  }

  G_OBJECT_CLASS (gum_allocator_probe_parent_class)->dispose (object);
}
gboolean
gum_sanity_checker_end (GumSanityChecker * self)
{
  GumSanityCheckerPrivate * priv = self->priv;
  gboolean all_checks_passed = TRUE;

  if (priv->bounds_checker != NULL)
  {
    gum_bounds_checker_detach (priv->bounds_checker);

    g_object_unref (priv->bounds_checker);
    priv->bounds_checker = NULL;
  }

  if (priv->instance_tracker != NULL)
  {
    GumList * stale_instances;

    gum_instance_tracker_end (priv->instance_tracker);

    stale_instances =
        gum_instance_tracker_peek_instances (priv->instance_tracker);

    if (stale_instances != NULL)
    {
      all_checks_passed = FALSE;

      gum_sanity_checker_printf (self, "Instance leaks detected:\n\n");
      gum_sanity_checker_print_instance_leaks_summary (self, stale_instances);
      gum_sanity_checker_print (self, "\n");
      gum_sanity_checker_print_instance_leaks_details (self, stale_instances);

      gum_list_free (stale_instances);
    }

    g_object_unref (priv->instance_tracker);
    priv->instance_tracker = NULL;
  }

  if (priv->alloc_probe != NULL)
  {
    GumList * stale_blocks;

    gum_allocator_probe_detach (priv->alloc_probe);

    stale_blocks =
        gum_allocation_tracker_peek_block_list (priv->alloc_tracker);

    if (stale_blocks != NULL)
    {
      if (all_checks_passed)
      {
        GumList * block_groups;

        block_groups =
            gum_allocation_tracker_peek_block_groups (priv->alloc_tracker);

        gum_sanity_checker_printf (self, "Block leaks detected:\n\n");
        gum_sanity_checker_print_block_leaks_summary (self, block_groups);
        gum_sanity_checker_print (self, "\n");
        gum_sanity_checker_print_block_leaks_details (self, stale_blocks);

        gum_allocation_group_list_free (block_groups);
      }

      all_checks_passed = FALSE;

      gum_allocation_block_list_free (stale_blocks);
    }

    g_object_unref (priv->alloc_probe);
    priv->alloc_probe = NULL;

    g_object_unref (priv->alloc_tracker);
    priv->alloc_tracker = NULL;
  }

  return all_checks_passed;
}