implement the functions in debug.c