Skip to content

Commit d428bf2

Browse files
committed
improve debugability in TS debug builds
gdb seems to be not always able to fetch the correct context for thread locals. Thus, the "if (TSRMLS_CACHE)" clause causes gdb to show crashes which aren't recognized neither with helgrind nor in release builds. This is reproducable by setting breakpoints on the exact line where PHP has a tsrm_get_ls_cache() call.
1 parent 31287f0 commit d428bf2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

TSRM/TSRM.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ TSRM_API void *tsrm_get_ls_cache(void);
170170
#define TSRMG_STATIC(id, type, element) (((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element)
171171
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE
172172
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL
173+
#if ZEND_DEBUG
174+
#define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
175+
#else
173176
#define TSRMLS_CACHE_UPDATE() if (!TSRMLS_CACHE) TSRMLS_CACHE = tsrm_get_ls_cache()
177+
#endif
174178
#define TSRMLS_CACHE _tsrm_ls_cache
175179

176180
/* BC only */

0 commit comments

Comments
 (0)