HOME  NEWS  FORUM  DOWNLOAD  LINK
OpenCOBOL - an open-source COBOL compiler
Main Menu
Download
Documentation
Development
Who's Online
17 user(s) are online (6 user(s) are browsing Forum)

Members: 1
Guests: 16

human, more...
Powered by
SourceForge

Xoops

Creative Commons

OpenCOBOL Forum Index
   OpenCOBOL
     FR (common.c, cob_runtime_error): Output the call stack that led to the error
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
human
Posted on: 2009/10/29 11:33
Home away from home
Joined: 2007/5/15
From:
Posts: 967
Online
FR (common.c, cob_runtime_error): Output the call stack that led to the error
I thought of something like
	/* prefix */
	if (cob_source_file) {
		fprintf (stderr, "%s:%d: ", cob_source_file, cob_source_line);
	}
	fputs ("libcob: ", stderr);

	/* body */
	va_start (ap, fmt);
	vfprintf (stderr, fmt, ap);
	va_end (ap);

	/* postfix */
	fputs ("\n", stderr);
	fflush (stderr);

	/* call stack */
	while ( cob_module ) {
		fprintf (stderr, "Called from %s", cob_module->cob_name);
		if (cob_source_file) {
			fprintf (stderr, ", %s:%d: \n", cob_module->cob_source_file, cob_module->cob_source_line);
		}
		fprintf (stderr, "\n");
		cob_module = cob_module->next;
	}

What do you think of this suggestion?

human
btiffin
Posted on: 2009/10/30 1:40
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 755
Re: FR (common.c, cob_runtime_error): Output the call stack that led to the error
I like that human.

With the caveat that it gets wrapped in tests for appropriate -f options (-debug -ftraceall ?), that's a good idea.

And once again; glad to see the C code and what looks like a continually deeper understanding of the compiler sources. Woohoo!!

Cheers,
Brian
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 
Copyright (C) 2005 The OpenCOBOL Project. All rights reserved.
Powered by Xoops2 | PHP | MySQL | Apache
ocean-net