Skip to content

Commit e49e067

Browse files
committed
add debug-objc
update tsd_private to latest version bug: _objc_init is called before global c++ instance constructor calls
1 parent e9c2766 commit e49e067

File tree

5 files changed

+116
-89
lines changed

5 files changed

+116
-89
lines changed

debug-objc/main.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// main.m
3+
// debug-objc
4+
//
5+
// Created by closure on 2/24/16.
6+
//
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
int main(int argc, const char * argv[]) {
12+
@autoreleasepool {
13+
// insert code here...
14+
NSLog(@"Hello, World!");
15+
}
16+
return 0;
17+
}

include/pthread/tsd_private.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@
22
* Copyright (c) 2003-2013 Apple Inc. All rights reserved.
33
*
44
* @APPLE_LICENSE_HEADER_START@
5-
*
5+
*
66
* This file contains Original Code and/or Modifications of Original Code
77
* as defined in and that are subject to the Apple Public Source License
88
* Version 2.0 (the 'License'). You may not use this file except in
99
* compliance with the License. Please obtain a copy of the License at
1010
* http://www.opensource.apple.com/apsl/ and read it before using this
1111
* file.
12-
*
12+
*
1313
* The Original Code and all software distributed under the License are
1414
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1515
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
1616
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
1717
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
1818
* Please see the License for the specific language governing rights and
1919
* limitations under the License.
20-
*
20+
*
2121
* @APPLE_LICENSE_HEADER_END@
2222
*/
2323
/*
24-
* Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991
25-
* All Rights Reserved
26-
*
27-
* Permission to use, copy, modify, and distribute this software and
28-
* its documentation for any purpose and without fee is hereby granted,
29-
* provided that the above copyright notice appears in all copies and
30-
* that both the copyright notice and this permission notice appear in
31-
* supporting documentation.
32-
*
33-
* OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
34-
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
35-
* FOR A PARTICULAR PURPOSE.
36-
*
37-
* IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
38-
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
40-
* NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
41-
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24+
* Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991
25+
* All Rights Reserved
26+
*
27+
* Permission to use, copy, modify, and distribute this software and
28+
* its documentation for any purpose and without fee is hereby granted,
29+
* provided that the above copyright notice appears in all copies and
30+
* that both the copyright notice and this permission notice appear in
31+
* supporting documentation.
32+
*
33+
* OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
34+
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
35+
* FOR A PARTICULAR PURPOSE.
36+
*
37+
* IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
38+
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
40+
* NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
41+
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4242
*/
4343
/*
4444
* MkLinux
@@ -73,7 +73,7 @@
7373
#define _PTHREAD_TSD_SLOT_PTHREAD_QOS_CLASS __TSD_THREAD_QOS_CLASS
7474
//#define _PTHREAD_TSD_SLOT_SEMAPHORE_CACHE__TSD_SEMAPHORE_CACHE
7575

76-
#define _PTHREAD_TSD_RESERVED_SLOT_COUNT _PTHREAD_TSD_RESERVED_SLOT_COUNT
76+
//#define _PTHREAD_TSD_RESERVED_SLOT_COUNT _PTHREAD_TSD_RESERVED_SLOT_COUNT
7777

7878
/* Keys 10 - 29 are for Libc/Libsystem internal usage */
7979
/* used as __pthread_tsd_first + Num */
@@ -217,14 +217,14 @@ extern int pthread_key_init_np(int, void (*)(void *));
217217

218218
__OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0)
219219
extern const struct pthread_layout_offsets_s {
220-
// always add new fields at the end
221-
const uint16_t plo_version;
222-
// either of the next two fields may be 0; use whichever is set
223-
// bytes from pthread_t to base of tsd
224-
const uint16_t plo_pthread_tsd_base_offset;
225-
// bytes from pthread_t to a pointer to base of tsd
226-
const uint16_t plo_pthread_tsd_base_address_offset;
227-
const uint16_t plo_pthread_tsd_entry_size;
220+
// always add new fields at the end
221+
const uint16_t plo_version;
222+
// either of the next two fields may be 0; use whichever is set
223+
// bytes from pthread_t to base of tsd
224+
const uint16_t plo_pthread_tsd_base_offset;
225+
// bytes from pthread_t to a pointer to base of tsd
226+
const uint16_t plo_pthread_tsd_base_address_offset;
227+
const uint16_t plo_pthread_tsd_entry_size;
228228
} pthread_layout_offsets;
229229

230230
#endif // PTHREAD_LAYOUT_SPI
@@ -235,7 +235,7 @@ __END_DECLS
235235
__header_always_inline int
236236
_pthread_has_direct_tsd(void)
237237
{
238-
return 0;
238+
return 0;
239239
}
240240

241241
#define _pthread_getspecific_direct(key) pthread_getspecific((key))
@@ -246,21 +246,21 @@ _pthread_has_direct_tsd(void)
246246
__header_always_inline int
247247
_pthread_has_direct_tsd(void)
248248
{
249-
return 1;
249+
return 1;
250250
}
251251

252252
/* To be used with static constant keys only */
253253
__header_always_inline void *
254254
_pthread_getspecific_direct(unsigned long slot)
255255
{
256-
return _os_tsd_get_direct(slot);
256+
return _os_tsd_get_direct(slot);
257257
}
258258

259259
/* To be used with static constant keys only */
260260
__header_always_inline int
261261
_pthread_setspecific_direct(unsigned long slot, void * val)
262262
{
263-
return _os_tsd_set_direct(slot, val);
263+
return _os_tsd_set_direct(slot, val);
264264
}
265265

266266
#endif /* TARGET_IPHONE_SIMULATOR */

0 commit comments

Comments
 (0)