Пример #1
0
static void *
dbgmalloc_realloc_hook(void *ptr, size_t size, const void *caller)
{
  void *r;
  install_old_hook();
  r = realloc(ptr, size);
  open_logfile();
  if (ptr) fprintf(logfile, "F %p 0 : ", ptr);
  show_stack_trace();
  if (r) fprintf(logfile, "M %p %zu : ", r, size);
  show_stack_trace();
  install_our_hook();
  return r;
}
Пример #2
0
/* We need the heap_size argument because the heap size is not up to date when
 * we call this function from constrained_sbrk() or constrained_mmap().
 */
static void show_mem_info(int heap_size)
{
	if ( g_show_mem_info == 0 )
		return;

	if ( g_show_mem_info == -1)
	{
		g_show_mem_info = getenv("OPERA_SHOW_MEM_INFO") ? 1 : 0;
		if ( g_show_mem_info == 0 )
			return;
	}

	mstate av = get_malloc_state();
	if ( heap_size == 0 )
	{
		heap_size = av->mmapped_mem + av->sbrked_mem;
	}

	fprintf(stderr, "Heap size is %d\n",  heap_size);
	fprintf(stderr, "Opera allocated memory is %d\n", g_constrain_allocated_mem);

#ifdef STACK_TRACE_SUPPORT

	if ( g_show_mem_info_stack == 0 )
		return;

	if (g_show_mem_info_stack == -1)
	{
		g_show_mem_info_stack = getenv("OPERA_SHOW_MEM_INFO_STACK") ? 1 : 0;
		if ( g_show_mem_info_stack == 0 )
			return;
	}

	if ( heap_size > get_heap_limit() )
	{
		fprintf(stderr,"Exceeded heap limit at:\n");
		show_stack_trace(15,0);
	}
	if ( heap_size == 0 && g_constrain_allocated_mem > get_alloc_limit() )
	{
		fprintf(stderr,"Exceeded alloc limit at:\n");
		show_stack_trace(15,0);
	}
#endif
}
Пример #3
0
static void
dbgmalloc_free_hook(void *ptr, const void *caller)
{
  install_old_hook();
  free(ptr);
  open_logfile();
  if (ptr) fprintf(logfile, "F %p 0 : ", ptr);
  show_stack_trace();
  install_our_hook();
}
Пример #4
0
static void *
dbgmalloc_memalign_hook(size_t size, size_t algn, const void *caller)
{
  void *r;
  install_old_hook();
  r = memalign(size, algn);
  open_logfile();
  if (r) fprintf(logfile, "M %p %zu : ", r, size);
  show_stack_trace();
  install_our_hook();
  return r;
}
Пример #5
0
static void log_alloc(void* addr)
{
	if ( addr == NULL )
	{
#ifdef STACK_TRACE_SUPPORT
		if ( g_log_oom == 0 )
			return;

		if (g_log_oom == -1)
		{
			g_log_oom = getenv("OPERA_LOG_OOM") ? 1 : 0;
			if ( g_log_oom == 0 )
				return;
		}

		fprintf(stderr,"OOM at:\n");
		show_stack_trace(15,0);
#endif // STACK_TRACE_SUPPORT
		g_log_alloc_counter++; /* A place to put a breakpoint. Do something so the code isn't optimized away. */

	}
}
Пример #6
0
        static void graphite_signal_handler(int sig) {
	    Logger::err("SignalHandler") << "Caught " << sig << std::endl ;
	    show_stack_trace() ;
	    abort() ;
	}