Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_devices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_devices
Commits
128dc3d3
Commit
128dc3d3
authored
8 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Adding print stacktrace function
parent
a0b02db5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Memleak_check.hpp
+8
-8
8 additions, 8 deletions
src/Memleak_check.hpp
src/memory/HeapMemory.cpp
+1
-1
1 addition, 1 deletion
src/memory/HeapMemory.cpp
src/memory/PtrMemory.cpp
+3
-1
3 additions, 1 deletion
src/memory/PtrMemory.cpp
src/util/se_util.hpp
+5
-3
5 additions, 3 deletions
src/util/se_util.hpp
with
17 additions
and
13 deletions
src/Memleak_check.hpp
+
8
−
8
View file @
128dc3d3
...
...
@@ -30,7 +30,7 @@ typedef unsigned char * byte_ptr;
#include
"ptr_info.hpp"
#include
<string>
#define MEM_ERROR
1300lu
#define MEM_ERROR
_OBJECT std::runtime_error("Runtime memory error")
extern
long
int
msg_on_alloc
;
extern
long
int
msg_on_dealloc
;
...
...
@@ -62,7 +62,7 @@ static bool remove_ptr(const void * ptr)
if
(
it
==
active_ptr
.
end
()
)
{
std
::
cout
<<
"Error "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" pointer not found "
<<
ptr
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
);
ACTION_ON_ERROR
(
MEM_ERROR
_OBJECT
);
return
false
;
}
...
...
@@ -286,7 +286,7 @@ inline static bool check_new(const void * data, size_t sz, size_t struct_id, siz
std
::
cout
<<
"Detected allocation: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" id="
<<
msg_on_alloc
<<
"
\n
"
;
if
(
thr_on_alloc
==
new_data
)
throw
MEM_ERROR
;
throw
MEM_ERROR
_OBJECT
;
return
true
;
}
...
...
@@ -333,7 +333,7 @@ inline static bool check_valid(const void * ptr, size_t size_access)
if
(
active_ptr
.
size
()
==
0
)
{
std
::
cerr
<<
"Error invalid pointer: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" "
<<
ptr
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
);
ACTION_ON_ERROR
(
MEM_ERROR
_OBJECT
);
return
false
;
}
...
...
@@ -347,7 +347,7 @@ inline static bool check_valid(const void * ptr, size_t size_access)
if
(
process_to_print
<
0
||
process_to_print
==
process_v_cl
)
{
std
::
cerr
<<
"Error invalid pointer: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" "
<<
ptr
<<
" base allocation id="
<<
l_b
->
second
.
id
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
);
ACTION_ON_ERROR
(
MEM_ERROR
_OBJECT
);
}
return
false
;
}
...
...
@@ -361,7 +361,7 @@ inline static bool check_valid(const void * ptr, size_t size_access)
if
(
process_to_print
<
0
||
process_to_print
==
process_v_cl
)
{
std
::
cerr
<<
"Error invalid pointer: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" "
<<
ptr
<<
" base allocation id="
<<
l_b
->
second
.
id
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
);
ACTION_ON_ERROR
(
MEM_ERROR
_OBJECT
);
}
return
false
;
}
...
...
@@ -390,8 +390,8 @@ inline static bool check_valid(const void * ptr, size_t size_access)
{
if
(
process_to_print
<
0
||
process_to_print
==
process_v_cl
)
{
std
::
cerr
<<
"Error invalid pointer: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" "
<<
ptr
<<
"base allocation id="
<<
l_b
->
second
.
id
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
);
std
::
cerr
<<
"Error invalid pointer: "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" "
<<
ptr
<<
"
base allocation id="
<<
l_b
->
second
.
id
<<
"
\n
"
;
ACTION_ON_ERROR
(
MEM_ERROR
_OBJECT
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/memory/HeapMemory.cpp
+
1
−
1
View file @
128dc3d3
...
...
@@ -95,7 +95,7 @@ bool HeapMemory::copyFromPointer(const void * ptr,size_t sz)
*
* copy a piece of memory from device to device
*
* \param
CudaMemory
from where to copy
* \param
m
from where to copy
*
*/
bool
HeapMemory
::
copyDeviceToDevice
(
const
HeapMemory
&
m
)
...
...
This diff is collapsed.
Click to expand it.
src/memory/PtrMemory.cpp
+
3
−
1
View file @
128dc3d3
...
...
@@ -59,7 +59,9 @@ bool PtrMemory::copyFromPointer(const void * ptr,size_t sz)
*
* copy a piece of memory from device to device
*
* \param PtrMemory from where to copy
* \param m PtrMemory from where to copy
*
* \return true if the memory is successful copy
*
*/
bool
PtrMemory
::
copyDeviceToDevice
(
const
PtrMemory
&
m
)
...
...
This diff is collapsed.
Click to expand it.
src/util/se_util.hpp
+
5
−
3
View file @
128dc3d3
...
...
@@ -8,15 +8,17 @@
#ifndef OPENFPM_DATA_SRC_UTIL_SE_UTIL_HPP_
#define OPENFPM_DATA_SRC_UTIL_SE_UTIL_HPP_
#include
"print_stack.hpp"
// Macro that decide what to do in case of error
#ifdef STOP_ON_ERROR
#define ACTION_ON_ERROR(error) exit(1);
#define ACTION_ON_ERROR(error)
print_stack();
exit(1);
#define THROW noexcept(true)
#elif defined(THROW_ON_ERROR)
#define ACTION_ON_ERROR(error) if (!std::uncaught_exception()) throw error;
#define ACTION_ON_ERROR(error) if (!std::uncaught_exception())
{print_stack();
throw error;
}
#define THROW noexcept(false)
#else
#define ACTION_ON_ERROR(error)
#define ACTION_ON_ERROR(error)
print_stack();
#define THROW noexcept(true)
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment