xref: /aoo4110/main/canvas/inc/canvas/debug.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_CANVAS_DEBUG_HXX
25 #define INCLUDED_CANVAS_DEBUG_HXX
26 
27 // shared_ptr debugging
28 // --------------------
29 
30 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
31 
32 # include <sal/config.h>
33 # include <boost/shared_ptr.hpp>
34 
35 ::std::size_t find_unreachable_objects( bool );
36 
37 # ifdef VERBOSE
38 #  include <osl/diagnose.h>
39 #  define SHARED_PTR_LEFTOVERS(a) OSL_TRACE("%s\n%s: Unreachable objects still use %d bytes\n", \
40                                             BOOST_CURRENT_FUNCTION, a, \
41                                             find_unreachable_objects(true) )
42 # else
43 /** This macro shows how much memory is still used by shared_ptrs
44 
45 	Use this macro at places in the code where normally all shared_ptr
46     objects should have been deleted. You'll get the number of bytes
47     still contained in those objects, which quite possibly are prevented
48     from deletion by circular references.
49  */
50 #  define SHARED_PTR_LEFTOVERS(a) OSL_TRACE("%s\n%s: Unreachable objects still use %d bytes\n", \
51                                             BOOST_CURRENT_FUNCTION, a, \
52                                             find_unreachable_objects(false) )
53 # endif
54 
55 #else
56 
57 # define SHARED_PTR_LEFTOVERS(a) ((void)0)
58 
59 #endif
60 
61 #endif // ! defined(INCLUDED_CANVAS_DEBUG_HXX)
62