Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
85a8e8a7
Commit
85a8e8a7
authored
Sep 04, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Thread fatal errors: add function name, and some Win32 support
parent
629c2b38
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
27 deletions
+37
-27
include/vlc_threads.h
include/vlc_threads.h
+2
-2
src/libvlccore.sym
src/libvlccore.sym
+1
-1
src/misc/threads.c
src/misc/threads.c
+34
-24
No files found.
include/vlc_threads.h
View file @
85a8e8a7
...
@@ -201,12 +201,12 @@ enum {
...
@@ -201,12 +201,12 @@ enum {
#define vlc_mutex_lock( P_MUTEX ) \
#define vlc_mutex_lock( P_MUTEX ) \
__vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
__vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
VLC_EXPORT
(
void
,
vlc_
pthread_fatal
,
(
const
char
*
action
,
int
error
,
const
char
*
file
,
unsigned
line
));
VLC_EXPORT
(
void
,
vlc_
thread_fatal
,
(
const
char
*
action
,
int
error
,
const
char
*
function
,
const
char
*
file
,
unsigned
line
));
#if defined(LIBVLC_USE_PTHREAD)
#if defined(LIBVLC_USE_PTHREAD)
# define VLC_THREAD_ASSERT( action ) \
# define VLC_THREAD_ASSERT( action ) \
if (val) \
if (val) \
vlc_
pthread_fatal (action, val
, psz_file, i_line)
vlc_
thread_fatal (action, val, __func__
, psz_file, i_line)
#else
#else
# define VLC_THREAD_ASSERT ((void)(val))
# define VLC_THREAD_ASSERT ((void)(val))
#endif
#endif
...
...
src/libvlccore.sym
View file @
85a8e8a7
...
@@ -482,7 +482,6 @@ __vlc_object_wait
...
@@ -482,7 +482,6 @@ __vlc_object_wait
__vlc_object_waitpipe
__vlc_object_waitpipe
__vlc_object_yield
__vlc_object_yield
vlc_poll
vlc_poll
vlc_pthread_fatal
vlc_rand_bytes
vlc_rand_bytes
vlc_recvmsg
vlc_recvmsg
vlc_sdp_Start
vlc_sdp_Start
...
@@ -492,6 +491,7 @@ vlc_strlcpy
...
@@ -492,6 +491,7 @@ vlc_strlcpy
vlc_strtoll
vlc_strtoll
vlc_submodule_create
vlc_submodule_create
__vlc_thread_create
__vlc_thread_create
vlc_thread_fatal
__vlc_thread_join
__vlc_thread_join
__vlc_thread_set_priority
__vlc_thread_set_priority
vlc_threadvar_create
vlc_threadvar_create
...
...
src/misc/threads.c
View file @
85a8e8a7
...
@@ -66,28 +66,54 @@ libvlc_global_data_t *vlc_global( void )
...
@@ -66,28 +66,54 @@ libvlc_global_data_t *vlc_global( void )
return
p_root
;
return
p_root
;
}
}
#if defined(LIBVLC_USE_PTHREAD)
#ifdef HAVE_EXECINFO_H
# include <execinfo.h>
#endif
/**
* Print a backtrace to the standard error for debugging purpose.
*/
void
vlc_trace
(
const
char
*
fn
,
const
char
*
file
,
unsigned
line
)
{
fprintf
(
stderr
,
"at %s:%u in %s
\n
"
,
file
,
line
,
fn
);
fflush
(
stderr
);
/* needed before switch to low-level I/O */
#ifdef HAVE_BACKTRACE
void
*
stack
[
20
];
int
len
=
backtrace
(
stack
,
sizeof
(
stack
)
/
sizeof
(
stack
[
0
]));
backtrace_symbols_fd
(
stack
,
len
,
2
);
#endif
#ifndef WIN32
fsync
(
2
);
#endif
}
static
inline
unsigned
long
vlc_threadid
(
void
)
static
inline
unsigned
long
vlc_threadid
(
void
)
{
{
#if defined(LIBVLC_USE_PTHREAD)
union
{
pthread_t
th
;
unsigned
long
int
i
;
}
v
=
{
};
union
{
pthread_t
th
;
unsigned
long
int
i
;
}
v
=
{
};
v
.
th
=
pthread_self
();
v
.
th
=
pthread_self
();
return
v
.
i
;
return
v
.
i
;
}
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
#elif defined (WIN32)
# include <execinfo.h>
return
GetCurrentThread
();
#else
return
0
;
#endif
#endif
}
/*****************************************************************************
/*****************************************************************************
* vlc_thread_fatal: Report an error from the threading layer
* vlc_thread_fatal: Report an error from the threading layer
*****************************************************************************
*****************************************************************************
* This is mostly meant for debugging.
* This is mostly meant for debugging.
*****************************************************************************/
*****************************************************************************/
void
vlc_
pthread_fatal
(
const
char
*
action
,
int
error
,
void
vlc_
thread_fatal
(
const
char
*
action
,
int
error
,
const
char
*
function
,
const
char
*
file
,
unsigned
line
)
const
char
*
file
,
unsigned
line
)
{
{
fprintf
(
stderr
,
"LibVLC fatal error %s in thread %lu at %s:%u: %d
\n
"
,
fprintf
(
stderr
,
"LibVLC fatal error %s (%d) in thread %lu "
,
action
,
vlc_threadid
(),
file
,
line
,
error
);
action
,
error
,
vlc_threadid
());
vlc_trace
(
function
,
file
,
line
);
/* Sometimes strerror_r() crashes too, so make sure we print an error
/* Sometimes strerror_r() crashes too, so make sure we print an error
* message before we invoke it */
* message before we invoke it */
...
@@ -115,24 +141,8 @@ void vlc_pthread_fatal (const char *action, int error,
...
@@ -115,24 +141,8 @@ void vlc_pthread_fatal (const char *action, int error,
#endif
#endif
fflush
(
stderr
);
fflush
(
stderr
);
#ifdef HAVE_BACKTRACE
void
*
stack
[
20
];
int
len
=
backtrace
(
stack
,
sizeof
(
stack
)
/
sizeof
(
stack
[
0
]));
backtrace_symbols_fd
(
stack
,
len
,
2
);
#endif
abort
();
abort
();
}
}
#else
void
vlc_pthread_fatal
(
const
char
*
action
,
int
error
,
const
char
*
file
,
unsigned
line
)
{
(
void
)
action
;
(
void
)
error
;
(
void
)
file
;
(
void
)
line
;
abort
();
}
static
vlc_threadvar_t
cancel_key
;
#endif
/**
/**
* Per-thread cancellation data
* Per-thread cancellation data
...
@@ -604,7 +614,7 @@ void vlc_join (vlc_thread_t handle, void **result)
...
@@ -604,7 +614,7 @@ void vlc_join (vlc_thread_t handle, void **result)
#if defined( LIBVLC_USE_PTHREAD )
#if defined( LIBVLC_USE_PTHREAD )
int
val
=
pthread_join
(
handle
,
result
);
int
val
=
pthread_join
(
handle
,
result
);
if
(
val
)
if
(
val
)
vlc_
pthread_fatal
(
"joining thread"
,
val
,
__FILE__
,
__LINE__
);
vlc_
thread_fatal
(
"joining thread"
,
val
,
__func__
,
__FILE__
,
__LINE__
);
#elif defined( UNDER_CE ) || defined( WIN32 )
#elif defined( UNDER_CE ) || defined( WIN32 )
do
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment