[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with gnustep on OpenBSD sparc64
From: |
Sebastian Reitenbach |
Subject: |
Re: problem with gnustep on OpenBSD sparc64 |
Date: |
Wed, 06 Jul 2011 19:38:58 +0200 |
User-agent: |
SOGoMail 1.3.7 |
On Wednesday, July 6, 2011 15:08 CEST, David Chisnall <theraven@sucs.org>
wrote:
> On 6 Jul 2011, at 13:44, Sebastian Reitenbach wrote:
>
> > running it in gdb, I see the following:
>
> It helps me if you can tidy up the gdb traces a bit before sending them.
> It's easy to miss important things in the middle of a load of list commands
> and frames in libc with no debugging info.
$ gdb ./a.out
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc64-unknown-openbsd4.9"...(no debugging symbols
found)
(gdb) break objc_sizeof_type
Breakpoint 1 at 0x400ea0
(gdb) r
Starting program: /home/sebastia/a.out
Breakpoint 1 at 0x20b8f6d1c: file encoding2.c, line 322.
Breakpoint 1, objc_sizeof_type (type=0x200c10 "[3[4i]]") at encoding2.c:322
warning: Source file is more recent than executable.
322 size_t size = 0;
(gdb) list
317 return NULL;
318 }
319
320 size_t objc_sizeof_type(const char *type)
321 {
322 size_t size = 0;
323 sizeof_type(type, &size);
324 return size / 8;
325 }
326
(gdb) n
323 sizeof_type(type, &size);
(gdb) s
sizeof_type (type=0x200c10 "[3[4i]]", size=0xfffffffffffc9028) at
encoding2.c:154
154 fprintf(stderr, "sizeof_type: type before objc_skip_type_qualifiers:
%s\n", type);
(gdb) n
sizeof_type: type before objc_skip_type_qualifiers: [3[4i]]
155 type = objc_skip_type_qualifiers(type);
(gdb) n
objc_skip_type_qualifiers returning type: [3[4i]]156 fprintf(stderr,
"sizeof_type: type after objc_skip_type_qualifiers: %s\n", type);
(gdb) n
sizeof_type: type after objc_skip_type_qualifiers: [3[4i]]
157 switch (*type)
(gdb)
197 const char *t = type;
(gdb) list
192 round_up(size, align * 8);
193 return t;
194 }
195 case '[':
196 {
197 const char *t = type;
198 int element_size = 0;
199 // FIXME: aligned size
200 int element_count = parse_array(&t,
(type_parser)sizeof_type, &element_size);
201 (*size) += element_size * element_count;
(gdb) n
198 int element_size = 0;
(gdb) n
200 int element_count = parse_array(&t,
(type_parser)sizeof_type, &element_size);
(gdb) s
parse_array (type=0xfffffffffffc8f48, callback=0x20b8f5908 <sizeof_type>,
context=0xfffffffffffc8f40) at encoding2.c:78
78 (*type)++;
(gdb) list
73 typedef const char *(*type_parser)(const char*, void*);
74
75 static int parse_array(const char **type, type_parser callback, void
*context)
76 {
77 // skip [
78 (*type)++;
79 int element_count = (int)strtol(*type, (char**)type, 10);
80 fprintf(stderr, "parse_array: element_count: %i, type: %s\n",
element_count, *type);
81 *type = callback(*type, context);
82 // skip ]
(gdb) n
79 int element_count = (int)strtol(*type, (char**)type, 10);
(gdb) print type
$1 = (const char **) 0xfffffffffffc8f48
(gdb) print *type
$2 = 0x200c11 "3[4i]]"
(gdb) n
80 fprintf(stderr, "parse_array: element_count: %i, type: %s\n",
element_count, *type);
(gdb) print element_count
$3 = 3
(gdb) s
fprintf (fp=0x2042ad278, fmt=0x20ba0de38 "parse_array: element_count: %i, type:
%s\n") at /usr/src/lib/libc/stdio/fprintf.c:44
44 /usr/src/lib/libc/stdio/fprintf.c: No such file or directory.
in /usr/src/lib/libc/stdio/fprintf.c
(gdb) n
45 in /usr/src/lib/libc/stdio/fprintf.c
(gdb)
40 in /usr/src/lib/libc/stdio/fprintf.c
(gdb)
45 in /usr/src/lib/libc/stdio/fprintf.c
(gdb)
40 in /usr/src/lib/libc/stdio/fprintf.c
(gdb)
45 in /usr/src/lib/libc/stdio/fprintf.c
(gdb)
parse_array: element_count: 3, type: [4i]]
48 in /usr/src/lib/libc/stdio/fprintf.c
(gdb)
parse_array (type=0xfffffffffffc8f48, callback=0x20b8f5908 <sizeof_type>,
context=0xfffffffffffc8f40) at encoding2.c:81
81 *type = callback(*type, context);
(gdb) s
sizeof_type (type=0x200c12 "[4i]]", size=0xfffffffffffc8f40) at encoding2.c:154
154 fprintf(stderr, "sizeof_type: type before objc_skip_type_qualifiers:
%s\n", type);
(gdb) n
sizeof_type: type before objc_skip_type_qualifiers: [4i]]
155 type = objc_skip_type_qualifiers(type);
(gdb)
objc_skip_type_qualifiers returning type: [4i]]156 fprintf(stderr,
"sizeof_type: type after objc_skip_type_qualifiers: %s\n", type);
(gdb) n
sizeof_type: type after objc_skip_type_qualifiers: [4i]]
157 switch (*type)
(gdb)
197 const char *t = type;
(gdb) list
192 round_up(size, align * 8);
193 return t;
194 }
195 case '[':
196 {
197 const char *t = type;
198 int element_size = 0;
199 // FIXME: aligned size
200 int element_count = parse_array(&t,
(type_parser)sizeof_type, &element_size);
201 (*size) += element_size * element_count;
(gdb) n
198 int element_size = 0;
(gdb) n
200 int element_count = parse_array(&t,
(type_parser)sizeof_type, &element_size);
(gdb) s
parse_array (type=0xfffffffffffc8d88, callback=0x20b8f5908 <sizeof_type>,
context=0xfffffffffffc8d80) at encoding2.c:78
78 (*type)++;
(gdb) list
73 typedef const char *(*type_parser)(const char*, void*);
74
75 static int parse_array(const char **type, type_parser callback, void
*context)
76 {
77 // skip [
78 (*type)++;
79 int element_count = (int)strtol(*type, (char**)type, 10);
80 fprintf(stderr, "parse_array: element_count: %i, type: %s\n",
element_count, *type);
81 *type = callback(*type, context);
82 // skip ]
(gdb) n
79 int element_count = (int)strtol(*type, (char**)type, 10);
(gdb) print *type
$4 = 0x200c13 "4i]]"
(gdb) n
80 fprintf(stderr, "parse_array: element_count: %i, type: %s\n",
element_count, *type);
(gdb) print element_count
$5 = 4
(gdb) n
parse_array: element_count: 4, type: i]]
81 *type = callback(*type, context);
(gdb) print *type
$6 = 0x200c14 "i]]"
(gdb) n
sizeof_type: type before objc_skip_type_qualifiers: i]]
objc_skip_type_qualifiers returning type: i]]sizeof_type: type after
objc_skip_type_qualifiers: i]]
83 (*type)++;
(gdb) list
78 (*type)++;
79 int element_count = (int)strtol(*type, (char**)type, 10);
80 fprintf(stderr, "parse_array: element_count: %i, type: %s\n",
element_count, *type);
81 *type = callback(*type, context);
82 // skip ]
83 (*type)++;
84 return element_count;
85 }
86
87 static void parse_struct_or_union(const char **type, type_parser
callback, void *context, char endchar)
(gdb) print *type
$7 = 0x200c15 "]]"
(gdb) n
84 return element_count;
(gdb) print element_count
$8 = 4
(gdb) n
85 }
(gdb) list
80 fprintf(stderr, "parse_array: element_count: %i, type: %s\n",
element_count, *type);
81 *type = callback(*type, context);
82 // skip ]
83 (*type)++;
84 return element_count;
85 }
86
87 static void parse_struct_or_union(const char **type, type_parser
callback, void *context, char endchar)
88 {
89 // Skip the ( and structure name
(gdb) n
sizeof_type (type=0x200c12 "[4i]]", size=0xfffffffffffc8f40) at encoding2.c:201
201 (*size) += element_size * element_count;
(gdb) list
196 {
197 const char *t = type;
198 int element_size = 0;
199 // FIXME: aligned size
200 int element_count = parse_array(&t,
(type_parser)sizeof_type, &element_size);
201 (*size) += element_size * element_count;
202 return t;
203 }
204 case '(':
205 {
(gdb) print element_size
$9 = 0
(gdb) print element_count
$10 = 4
(gdb) list
206 const char *t = type;
207 size_t union_size = 0;
208 parse_union(&t,
(type_parser)sizeof_union_field, &union_size);
209 *size += union_size;
210 return t;
211 }
212 case 'b':
213 {
214 // Consume the b
215 type++;
(gdb) bt
#0 sizeof_type (type=0x200c12 "[4i]]", size=0xfffffffffffc8f40) at
encoding2.c:201
#1 0x000000020b8f56ec in parse_array (type=0xfffffffffffc8f48,
callback=0x20b8f5908 <sizeof_type>, context=0xfffffffffffc8f40) at
encoding2.c:81
#2 0x000000020b8f6184 in sizeof_type (type=0x200c10 "[3[4i]]",
size=0xfffffffffffc9028) at encoding2.c:200
#3 0x000000020b8f6d34 in objc_sizeof_type (type=0x200c10 "[3[4i]]") at
encoding2.c:323
#4 0x0000000000100bbc in main ()
(gdb) frame 0
#0 sizeof_type (type=0x200c12 "[4i]]", size=0xfffffffffffc8f40) at
encoding2.c:201
201 (*size) += element_size * element_count;
(gdb) list
196 {
197 const char *t = type;
198 int element_size = 0;
199 // FIXME: aligned size
200 int element_count = parse_array(&t,
(type_parser)sizeof_type, &element_size);
201 (*size) += element_size * element_count;
202 return t;
203 }
204 case '(':
205 {
(gdb) n
202 return t;
(gdb) print t
$11 = 0x200c16 "]"
(gdb) print *t
$12 = 93 ']'
(gdb) n
235 }
(gdb) n
parse_array (type=0xfffffffffffc8f48, callback=0x20b8f5908 <sizeof_type>,
context=0xfffffffffffc8f40) at encoding2.c:83
83 (*type)++;
(gdb) list
78 (*type)++;
79 int element_count = (int)strtol(*type, (char**)type, 10);
80 fprintf(stderr, "parse_array: element_count: %i, type: %s\n",
element_count, *type);
81 *type = callback(*type, context);
82 // skip ]
83 (*type)++;
84 return element_count;
85 }
86
87 static void parse_struct_or_union(const char **type, type_parser
callback, void *context, char endchar)
(gdb) print type
$13 = (const char **) 0xfffffffffffc8f48
(gdb) print *type
$14 = 0x200c16 "]"
(gdb) n
84 return element_count;
(gdb) print element_count
$15 = 3
(gdb) n
85 }
(gdb) n
sizeof_type (type=0x200c10 "[3[4i]]", size=0xfffffffffffc9028) at
encoding2.c:201
201 (*size) += element_size * element_count;
(gdb) list
196 {
197 const char *t = type;
198 int element_size = 0;
199 // FIXME: aligned size
200 int element_count = parse_array(&t,
(type_parser)sizeof_type, &element_size);
201 (*size) += element_size * element_count;
202 return t;
203 }
204 case '(':
205 {
(gdb) print element_size
$16 = 0
(gdb) print element_count
$17 = 3
(gdb) n
202 return t;
(gdb) print t
$18 = 0x200c17 ""
(gdb) n
235 }
(gdb) n
objc_sizeof_type (type=0x200c10 "[3[4i]]") at encoding2.c:324
324 return size / 8;
(gdb) list
319
320 size_t objc_sizeof_type(const char *type)
321 {
322 size_t size = 0;
323 sizeof_type(type, &size);
324 return size / 8;
325 }
326
327 size_t objc_alignof_type (const char *type)
328 {
(gdb) print size
$19 = 0
(gdb) The program is running. Exit anyway? (y or n) y
I added some more fprintf's to the functions that are involved, hope the output
also helps:
$ ./a.out
sizeof_type: type before objc_skip_type_qualifiers: [3[4i]] size: 0
objc_skip_type_qualifiers returning type: [3[4i]]
sizeof_type: type after objc_skip_type_qualifiers: [3[4i]]
parse_array: element_count: 3, type: [4i]]
sizeof_type: type before objc_skip_type_qualifiers: [4i]] size: 4294928257
objc_skip_type_qualifiers returning type: [4i]]
sizeof_type: type after objc_skip_type_qualifiers: [4i]]
parse_array: element_count: 4, type: i]]
sizeof_type: type before objc_skip_type_qualifiers: i]] size: 4294927809
objc_skip_type_qualifiers returning type: i]]
sizeof_type: type after objc_skip_type_qualifiers: i]]
I used attched patch for the fprintfs.
Sebastian
encoding2.diff
Description: Binary data
- Re: problem with gnustep on OpenBSD sparc64, (continued)
- Re: problem with gnustep on OpenBSD sparc64, Sebastian Reitenbach, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, Sebastian Reitenbach, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, Sebastian Reitenbach, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, Sebastian Reitenbach, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, Sebastian Reitenbach, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64,
Sebastian Reitenbach <=
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, Sebastian Reitenbach, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/06
- Re: problem with gnustep on OpenBSD sparc64, Sebastian Reitenbach, 2011/07/07
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/07
- Re: problem with gnustep on OpenBSD sparc64, Wolfgang Lux, 2011/07/07
- Re: problem with gnustep on OpenBSD sparc64, David Chisnall, 2011/07/07
- Re: problem with gnustep on OpenBSD sparc64 -- the journey goes on, Sebastian Reitenbach, 2011/07/07
- Re: problem with gnustep on OpenBSD sparc64 -- the journey goes on, David Chisnall, 2011/07/07
- Re: problem with gnustep on OpenBSD sparc64 -- the journey goes on, Sebastian Reitenbach, 2011/07/07