Skip to content
Snippets Groups Projects
Commit c4381bc3 authored by Martin Karsten's avatar Martin Karsten
Browse files

- minor bugfixes in gdb support and webserver program

parent bab3c557
No related branches found
No related tags found
No related merge requests found
......@@ -6,12 +6,16 @@ import gdb
from contextlib import contextmanager
class FibreSupport():
def __init__(self):
FibreSupport.saved = False
def stop_handler(event):
if (gdb.lookup_symbol("_globalStackList")[0] == None):
print("WARNING: no fibre debugging support - did you enable TESTING_ENABLE_DEBUGGING?")
return
FibreSupport.list = []
FibreSupport.active = {}
FibreSupport.saved = True
# save register context for later continuation
FibreSupport.rsp = str(gdb.parse_and_eval("$rsp")).split(None, 1)[0]
FibreSupport.rbp = str(gdb.parse_and_eval("$rbp")).split(None, 1)[0]
......@@ -37,7 +41,7 @@ class FibreSupport():
}
orig_thread.switch()
# restore() is hooked to continue events via basic script hooks
# restore() is hooked to continue events via script hooks to 'fibre reset'
def restore():
FibreSupport.prep_frame()
# restore original register context
......@@ -45,6 +49,7 @@ class FibreSupport():
gdb.execute("set $rbp = " + str(FibreSupport.rbp))
gdb.execute("set $rip = " + str(FibreSupport.rip))
gdb.execute("set Context::currStack = " + str(FibreSupport.currStack))
FibreSupport.saved = False
def prep_frame():
# walk stack down to innermost frame
......@@ -138,6 +143,8 @@ class InfoFibres(gdb.Command):
super(InfoFibres, self).__init__("info fibres", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
if (not FibreSupport.saved):
return
curr = gdb.parse_and_eval("Context::currStack")
print(" Idx \tTarget\tPtr \t\t Frame")
for i in range(len(FibreSupport.list)):
......@@ -169,6 +176,8 @@ class FibrePtr(gdb.Command):
super(FibrePtr, self).__init__("fibre ptr", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
if (not FibreSupport.saved):
return
FibreSupport.backtrace(gdb.parse_and_eval(arg))
class FibreIdx(gdb.Command):
......@@ -177,6 +186,8 @@ class FibreIdx(gdb.Command):
super(FibreIdx, self).__init__("fibre idx", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
if (not FibreSupport.saved):
return
index = int(gdb.parse_and_eval(arg))
if (index >= len(FibreSupport.list)):
print("fibre", index, "does not exist")
......@@ -189,6 +200,8 @@ class FibreSetPtr(gdb.Command):
super(FibreSetPtr, self).__init__("fibre setptr", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
if (not FibreSupport.saved):
return
FibreSupport.prep_frame()
FibreSupport.set_fibre(gdb.parse_and_eval(arg))
......@@ -198,6 +211,8 @@ class FibreSetIdx(gdb.Command):
super(FibreSetIdx, self).__init__("fibre setidx", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
if (not FibreSupport.saved):
return
index = int(gdb.parse_and_eval(arg))
if (index >= len(FibreSupport.list)):
print("fibre", index, "does not exist")
......@@ -212,6 +227,8 @@ before continuing the target with 'step', 'next', 'cont', etc..."""
super(FibreReset, self).__init__("fibre reset", gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
if (not FibreSupport.saved):
return
FibreSupport.restore()
FibreSupport()
......
......@@ -161,6 +161,9 @@ static void opts(int argc, char** argv) {
if (clusterSize == 0 || threadCount == 0) {
cerr << "none of -c, -t can be zero" << endl;
}
#if defined __U_CPLUSPLUS__
singleServerSocket = true;
#endif
}
static const char* RESPONSE = "HTTP/1.1 200 OK\r\n" \
......@@ -201,11 +204,10 @@ static inline bool connHandler(void* connFD) {
/* read request(s) */
ssize_t rret;
#if defined __U_CPLUSPLUS__
for (;;) {
try {
rret = ((uSocketAccept*)connFD)->recv(buf + buflen, sizeof(buf) - buflen, 0);
if (rret > 0) break;
} catch(uSocketAccept::ReadFailure& rderr) {}
try {
rret = ((uSocketAccept*)connFD)->recv(buf + buflen, sizeof(buf) - buflen, 0);
} catch(uSocketAccept::ReadFailure& rderr) {
goto closeAndOut;
}
#else
while ((rret = lfInput(recv, (uintptr_t)connFD, (void*)(buf + buflen), sizeof(buf) - buflen, 0)) < 0 && errno == EINTR);
......@@ -285,7 +287,7 @@ closeAndOut:
#endif
return false;
}
#if defined __U_CPLUSPLUS__
static uSocketServer* create_socket() {
return new uSocketServer(8800, SOCK_STREAM, 0, maxBacklog);
......@@ -491,7 +493,7 @@ static void scopemain() {
// wait for all listeners
for (Fibre* f : fibreList) delete f;
// close server socket, if neccessary
// close server socket, if neccessary
if (singleServerSocket) {
#if defined __U_CPLUSPLUS__
delete servFD;
......
......@@ -12,8 +12,10 @@ import (
)
var (
clusterSize = flag.Int("c", 64, "Size of clusters (ignored)")
clusterSize = flag.Int("c", 64, "Size of clusters (compatibility only, ignored)")
scopeCount = flag.Int("e", 64, "Number of event scopes (compatibility only, ignored)")
listenerCount = flag.Int("l", 1, "Number of listeners")
singleServerSocket = flag.Bool("m", true, "socket per listener compatibility only, ignored)")
threadcount = flag.Int("t", 1, "Number of system threads")
listenAddr = flag.String("addr", ":8800", "TCP address to listen to")
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment