Re: Strange C error



In message
<6b7f18f3-f9a0-4c1d-930d-757cd2716b65@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
davehigton wrote:

On 16 Dec, 23:46, Martin Wuerthner <spamt...@xxxxxxxxxxxxxxx> wrote:

In message <10e94e524f.davehigton@xxxxxxxxxxxxx>
Dave Higton <davehigton@xxxxxxxxxxxxx> wrote:
I've checked, by using Error_Report (), what is in the various
buffers, including "line".

Getting debug output back via wimp error boxes sounds a bit painful!
Unless there's a specific reason for doing it that way, there're a
couple of alternatives. DeskLib provides a Debug module which has a
"Debug_Printf" function which you can write to using the syntax of the
printf family of functions. The debug output is automatically removed
from your code when you /don't/ define DeskLib_DEBUG. When you /are/
debugging, the output can appear in a taskwindow. However, in version
2.80 using the Debug module is a bit clumsy as you have to link with
another bit of library.

The current development version of DeskLib makes things a bit more
straightforward and offers the option of using Martin Avison's excellent
Reporter to show the output instead. This is what I do. [1]

Possibly the easiest solution for you would be to just use the Reporter
SWI yourself in a debug function. Something like:
SWI(1 ,0 , 0x054C80 | XOS_Bit, text);
where 'text' is a char pointer to your debug text.

Or you could borrow someone else's code, e.g. from DeskLib:
http://tinyurl.com/3akzce
http://tinyurl.com/35bs7n


I've done some more investigation, and I can see a change that
kills it, though I still don't know why it does so. The (by now
much shortened) version of CreateCommand () is:

char username[64];
[...]
/* Extract the username and realm from the icon */
Icon_GetText (mainh, MAIN_USERNAME, username);
[...]

If I delete the "Icon_GetText (mainh, MAIN_USERNAME, username);"
line (and the Error_Report 2 lines later), it doesn't crash.
The Error_Report line is something I added /after/ discovering
that the presence of the line made the difference; it shows that
what is in username is what I expect, and is 7 characters long
plus terminator: it's "1988290".
That may be the length of the text contained in the icon, but what
is the length of the icon's buffer (as set in the templates file)?
A quick look at the Icon_GetText sources reveals that it usually
overwrites as much memory as specifed in the icon definition, not
only as much as currently used by the contents of the icon.

I've only had a quick glance at the source, but do you mean that the
line

strncpy(text, buffer, len);

will write the whole of the indirected icon's 'buffer' into 'text' if
the string is CR-terminated? If so, changing it to

strncpycr(text, buffer, len);

and adding

#include "DeskLib:Str.h"

ought to do the trick. Hmm, looks like the termination section seems to
go round the houses a bit too...


Oh, good grief. That'll be it, then.

To be fair, the function description does say "the minimum [size is] the
size of the [indirected] icon's buffer". I agree it's not particularly
clear though! I'll change that, at least.


And I can see a swift modification to my copy of Icon_GetText ()
coming up, too.

If you're feeling community-minded, feel free to feed back any
improvements. :)


Is there a limit to how much char[] space I can create as local
variables in a function with gcc?

I have no idea, but in general GCC would be the last place I'd look for
bugs or unexpected or restrictive behaviour. ;)


I haven't built DeskLib since I downloaded it; should I rebuild
it under gcc?

I don't think so. What would you be looking to achieve? DeskLib 2.80 was
built using GCC 3.4.6.


Cheers,
Adam

[1] If it is helpful I could send you a pre-built version of the
development version.
--
Adam Richardson Carpe Diem
http://www.snowstone.org.uk/riscos/
.



Relevant Pages

  • Re: Stream Device Driver How-to
    ... I get the debug output as below that was taken from Hyperterminal hanging on ... beitman AT applieddata DOT net ...
    (microsoft.public.windowsce.platbuilder)
  • Re: cxx0017: ... symbol not found VC++6
    ... You are running a debug build of the project with debug symbols ... // At this point should be pointing at workingBuf at the point of the ... // buffer end is reached before a $ is found the device should be ... // First check for end of buffer and read input buffer (newBuf) if ...
    (microsoft.public.vc.language)
  • LoadUserProfile() returns ERROR_ACCESS_DENIED
    ... GetLastError() returns 5 ... debug(buffer); ... debug("Couldn't set 'SE_ASSIGNPRIMARYTOKEN_NAME' privilege for this ...
    (microsoft.public.platformsdk.security)
  • Re: VerQueryValue Bug?
    ... call to verqueryvalue was not called there was not problem. ... I believe that debug and verqueryvalue can have unexpected side effects. ... >> Allocated a buffer ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Windows CE image download
    ... in this case your CEPC will send all debug messages to the terminal. ... But the debug output you posted shows that your debug connection through ... > Kernel debugger failed to connect with target. ... > And the x86 board's bootup process freezes with the same "jumping to ...
    (microsoft.public.windowsce.embedded)