(no subject)
(no subject)
- Subject: (no subject)
- From: Mike Lazear <email@hidden>
- Date: Thu, 13 Nov 2003 09:53:40 -0800
I'm in the process of converting an application to OS X using Carbon.
I was using PB but switched to XCode when Panther was released.
(Haven't decided yet if that was a good or bad decision).
I was having problems with debugging strings in PB and so I thought
XCode might be better. Basically I found that XCode works just as bad
as PB for this.
I'm hoping I'm doing something really stupid and there is a simple way
to fix this.
I have a variable defined as Str255 stg;
where Str255 is defined by typedef unsigned char Str255[256];
I'm not yet using Unicode strings and this string is a C string and
not
a Pascal string.
When I debug the code the variable show up as:
variable Type value
stg Str255 [-1]
I'm not sure why it shows with a value of [-1]. When I click the
expand arrow to the left of stg it thinks that the string is an array
from 0 to 255 (which it is) of unsigned char[256] (which it is not).
Basically it thinks its an array of arrays rather than an array of
unsigned char.
If I Control click on the 0 index under stg and select View Variable
as
Expression then I get the following in the Expressions dialog
Expression Value
(stg)[0] [256]
If I click the expand arrow to the left of stg I then see the
characters that make up my string.
This is a very painful way to see the characters in a string. Not to
mention what I really wanted was just to see the string as a string.
Something like:
variable Type value
stg Str255 "My String"
If I go to the Console mode I can type
set print null-stop
print stg
and it prints:
$1 = "My String"
which is exactly what I want but that's a real pain every time I want
to look at a string.
I've got to believe that debugging strings is common and I'm doing
something stupid here. What am I doing wrong?
I use a method which works in PB, and may work in XCode, provided that
there's still a console interface to GDB.
I defined a function called "pr255" in my code. This function returns
a (char *). It accepts a StringPtr, which is a pointer to a Str255, as
a parameter. The action of this function is to convert the Pascal
string into a C string and to return the address of a global buffer
which contains the C string.
You can invoke this function from the GDB command line (it's called
"Console" in Project Builder) by typing
p pr255(myStr255)
and GDB will print the contents of your string.
It beats turning triangles all day.
Hugh Sontag
Thanks for the suggestion. That idea will come in handy. In this
particular case what I have is a C string so
p stg (or print stg)
works fine. It just seems totally bizarre that the debugger doesn't
support viewing string variables naturally as strings. It is not
exactly like strings are a new concept. I have 10-20 strings that I'm
trying to monitor and having to type in a print command every time I
step thru the code seems silly. XCode has a lot of work to do in the
debugging area. Can one of the Apple folks here confirm this issue.
Thanks,
Mike
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.