use Debug flag

This commit is contained in:
Kelvin Sherlock 2012-05-11 21:21:29 -04:00
parent ffbc0ad320
commit 2ab70fbaff
6 changed files with 63 additions and 8 deletions

View File

@ -3,6 +3,7 @@
#include <errno.h> #include <errno.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "s16debug.h"
#pragma noroot #pragma noroot
#pragma optimize 79 #pragma optimize 79
@ -17,6 +18,13 @@ int mattach(int type, void *p1, void *p2, void *p3, void *p4, void *p5)
// p2 = selwakeup. // p2 = selwakeup.
int protocol = *(int *)p3; int protocol = *(int *)p3;
if (Debug > 0)
{
s16_debug_printf("socket type = %d protocol = %d",
type, protocol);
}
if (type != SOCK_STREAM) return ESOCKTNOSUPPORT; if (type != SOCK_STREAM) return ESOCKTNOSUPPORT;
//if (protocol != 6) return EPROTONOSUPPORT; //if (protocol != 6) return EPROTONOSUPPORT;
// TODO -- check protocol? 6 = tcp, 1 = icmp, 17 = udp. // TODO -- check protocol? 6 = tcp, 1 = icmp, 17 = udp.

View File

@ -2,11 +2,19 @@
#include <gno/kerntool.h> #include <gno/kerntool.h>
#include <errno.h> #include <errno.h>
#include <misctool.h> #include <misctool.h>
#include "s16debug.h" #include "s16debug.h"
#pragma noroot #pragma noroot
#pragma optimize 79 #pragma optimize 79
union split {
LongWord i32;
Word i16[2];
Byte i8[4];
};
int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5) int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
{ {
Word port; Word port;
@ -29,6 +37,14 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
sta <port sta <port
} }
if (Debug > 0)
{
union split s;
s.i32 = sin->sin_addr;
s16_debug_printf("connect address = %d.%d.%d.%d port = %d",
s.i8[0], s.i8[1], s.i8[2], s.i8[3], port);
}
// check if already connected. // check if already connected.
IncBusy(); IncBusy();
terr = TCPIPStatusTCP(e->ipid, &e->sr); terr = TCPIPStatusTCP(e->ipid, &e->sr);
@ -77,8 +93,6 @@ int mconnect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
xerrno = queue_command(e, kCommandConnect, 0, timeout); xerrno = queue_command(e, kCommandConnect, 0, timeout);
s16_debug_printf("mconnect: %d - %d - %d",
e->semaphore, xerrno, e->command);
// hmmm .. should these abort? // hmmm .. should these abort?
if (xerrno == EINTR) if (xerrno == EINTR)

22
mread.c
View File

@ -4,6 +4,8 @@
#include <misctool.h> #include <misctool.h>
#include "s16debug.h"
#pragma noroot #pragma noroot
#pragma optimize 79 #pragma optimize 79
@ -22,7 +24,11 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
LongWord nbytes = *(LongWord *)p2; LongWord nbytes = *(LongWord *)p2;
*(LongWord *)p2 = 0; *(LongWord *)p2 = 0;
if (Debug > 0)
{
s16_debug_printf("read nbytes = %ld", nbytes);
}
count = e->_RCVLOWAT; count = e->_RCVLOWAT;
if (count > nbytes) count = nbytes; if (count > nbytes) count = nbytes;
@ -53,7 +59,13 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
DecBusy(); DecBusy();
if (t) terr = t; if (t) terr = t;
*(LongWord *)p2 = rr.rrBuffCount; *(LongWord *)p2 = rr.rrBuffCount;
if (Debug > 1)
{
s16_debug_dump(buffer, (Word)rr.rrBuffCount);
}
} }
return 0; return 0;
} }
@ -100,6 +112,12 @@ int mread(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
DecBusy(); DecBusy();
*(LongWord *)p2 = rr.rrBuffCount; *(LongWord *)p2 = rr.rrBuffCount;
if (Debug > 1)
{
s16_debug_dump(buffer, (Word)rr.rrBuffCount);
}
} }
return 0; return 0;
} }

View File

@ -2,6 +2,8 @@
#include <gno/kerntool.h> #include <gno/kerntool.h>
#include <errno.h> #include <errno.h>
#include "s16debug.h"
#pragma noroot #pragma noroot
#pragma optimize 79 #pragma optimize 79
@ -75,6 +77,12 @@ int mselect(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
*(int *)p3 = 0; *(int *)p3 = 0;
if (Debug > 0)
{
s16_debug_printf("select pid = %5d flag = %d", pid, flag);
}
IncBusy(); IncBusy();
terr = TCPIPStatusTCP(e->ipid, &e->sr); terr = TCPIPStatusTCP(e->ipid, &e->sr);
t = _toolErr; t = _toolErr;

View File

@ -3,6 +3,7 @@
#include <sys/signal.h> #include <sys/signal.h>
#include <errno.h> #include <errno.h>
#include "s16debug.h"
#pragma noroot #pragma noroot
#pragma optimize 79 #pragma optimize 79
@ -19,6 +20,10 @@ int mwrite(Entry *e, void *p1, void *p2, void *p3, void *p4, void *p5)
*(LongWord *)p2 = 0; *(LongWord *)p2 = 0;
if (Debug > 0)
{
s16_debug_printf("write nbytes = %ld", nbytes);
}
// todo -- queue up if pending >= _SNDLOWAT? // todo -- queue up if pending >= _SNDLOWAT?
// todo -- push? // todo -- push?

10
table.c
View File

@ -155,11 +155,13 @@ void process_table(void)
if (t) terr = t; if (t) terr = t;
e->terr = terr; e->terr = terr;
s16_debug_printf("process: %04x : %04x : expired: %d", if (Debug > 2)
e->ipid, command, expired); {
s16_debug_printf("- ipid: %d command %d",
e->ipid, command);
s16_debug_srbuff(&e->sr); s16_debug_srbuff(&e->sr);
}
state = e->sr.srState; state = e->sr.srState;
sig = 0; sig = 0;