[net.unix] calling procedures from dbx

baer@Rand-Unix.ARPA@sri-unix.UUCP (03/26/84)

From:  Larry Baer <baer@Rand-Unix.ARPA>

I am moving my C programming effort from our 4.1bsd system to our
4.2bsd system; therefore I will be using dbx instead of sdb.  I
have come to rely heavily on my own data-structure printing
routines while debugging under sdb.  I cannot figure out how to
call these procedures successfully under dbx.

Often dbx complains that I am giving it arguments of incorrect
type when trying to call a procedure (I claim I am not), and on
those occasions when it does accept my arguments to a procedure,
it invariably dies with the message "program terminated by signal
1".  Once this has happened the debugger no longer pays any
attention to breakpoints that have been set, and my program
terminates "unexpectedly" when I give the "run" command.

This happens even with a procedure that tries to print its single
argument of type int.

Appended to this message are a simple test program, and a script
from a dbx session over said program illustrating my problem.
Can anyone tell me what magic to invoke to get this to work
correctly?

Helpful or informative responses will be summarized & posted to
this newsgroup unless

	(1) the newsgroup was copied in the response
    OR  (2) the sender asks that his response not be posted.

Thanks,

Larry Baer <baer at rand-unix.ARPA>


-----------------------------------------
#include <stdio.h>

typedef struct SimpleStruct {
    char simple_char;
    int  simple_int;
} SimpleObject;

typedef SimpleObject *SimpleObjectPtr;

ShowSimple(s)
SimpleObject s;
{
    fprintf(stderr, "SimpleObject = (char: %c, int: %d)\n",
	    s.simple_char, s.simple_int);
}

ShowSimplePtr(sp)
SimpleObjectPtr sp;
{

***Sender closed connection***

=== Network Mail from host brl-tgr on Mon Mar 26 11:17:20  ===

baer@Rand-Unix.ARPA@sri-unix.UUCP (03/26/84)

From:  Larry Baer <baer@Rand-Unix.ARPA>

I am moving my C programming effort from our 4.1bsd system to our
4.2bsd system; therefore I will be using dbx instead of sdb.  I
have come to rely heavily on my own data-structure printing
routines while debugging under sdb.  I cannot figure out how to
call these procedures successfully under dbx.

Often dbx complains that I am giving it arguments of incorrect
type when trying to call a procedure (I claim I am not), and on
those occasions when it does accept my arguments to a procedure,
it invariably dies with the message "program terminated by signal
1".  Once this has happened the debugger no longer pays any
attention to breakpoints that have been set, and my program
terminates "unexpectedly" when I give the "run" command.

This happens even with a procedure that tries to print its single
argument of type int.

Appended to this message are a simple test program, and a script
from a dbx session over said program illustrating my problem.
Can anyone tell me what magic to invoke to get this to work
correctly?

Helpful or informative responses will be summarized & posted to
this newsgroup unless

	(1) the newsgroup was copied in the response
    OR  (2) the sender asks that his response not be posted.

Thanks,

Larry Baer <baer at rand-unix.ARPA>


-----------------------------------------
#include <stdio.h>

typedef struct SimpleStruct {
    char simple_char;
    int  simple_int;
} SimpleObject;

typedef SimpleObject *SimpleObjectPtr;

ShowSimple(s)
SimpleObject s;
{
    fprintf(stderr, "SimpleObject = (char: %c, int: %d)\n",
	    s.simple_char, s.simple_int);
}

ShowSimplePtr(sp)
SimpleObjectPtr sp;
{
    SimpleObject s;
    fprintf(stderr, "SimpleObjectPtr = %d. It points to:\n\t", sp);
    if (sp == (SimpleObjectPtr)NULL) fprintf(stderr, "nothing.\n");
    else {
	s = *sp;
	ShowSimple(s);
    }
}

main()
{
    SimpleObject sim;
    SimpleObjectPtr simp = &sim;
    int i = (int)simp;

    sim.simple_char = 'S';
    sim.simple_int = 12345;

    ShowSimple(sim);
    ShowSimplePtr(simp);

    exit(0);
}
-----------------------------------------
Script started on Sat Mar 24 10:03:08 1984
% cc -g -p dbxtest1.c
% dbx a.out
dbx version of 3/23/84 10:12 (randgr).
Type 'help' for help.
reading symbolic information ...
(dbx) run
SimpleObject = (char: S, int: 12345)
SimpleObjectPtr = 2147479144. It points to:
	SimpleObject = (char: S, int: 12345)

execution completed, exit code is 0
(dbx) func main
(dbx) list 29,40
   29   main()
   30   {
   31       SimpleObject sim;
   32       SimpleObjectPtr simp = &sim;
   33       int i = (int)simp;
   34
   35       sim.simple_char = 'S';
   36       sim.simple_int = 12345;
   37
   38       ShowSimple(sim);
   39       ShowSimplePtr(simp);
   40
(dbx) stop at 38
(2) stop at 38
(dbx) status
(2) stop at 38
(dbx) run
stopped in main at line 38
   38       ShowSimple(sim);
(dbx) print sim
(simple_char = 'S', simple_int = 12345)
(dbx) print simp
0x7fffee68
(dbx) call ShowSimplePtr(simp)
program terminated by signal 1
(dbx) run
SimpleObject = (char: S, int: 12345)
SimpleObjectPtr = 2147479144. It points to:
	SimpleObject = (char: S, int: 12345)
program unexpectedly exited with 0
(dbx) quit
% ^D
script done on Sat Mar 24 10:06:23 1984