00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "DebugCommand.h"
00019 #include "memory/Memory.h"
00020
00021 namespace oasys {
00022
00023 DebugCommand::DebugCommand()
00024 : TclCommand("debug")
00025 {
00026 #ifdef OASYS_DEBUG_MEMORY_ENABLED
00027 add_to_help("dump_memory", "Dump memory usage");
00028 add_to_help("dump_memory_diffs", "Dump memory diff of usage");
00029 #endif
00030 }
00031
00032 int
00033 DebugCommand::exec(int argc, const char** argv, Tcl_Interp* interp)
00034 {
00035 (void)interp;
00036
00037 if (argc < 2) {
00038 resultf("need a subcommand");
00039 return TCL_ERROR;
00040 }
00041 const char* cmd = argv[1];
00042
00043 #ifdef OASYS_DEBUG_MEMORY_ENABLED
00044
00045 if (!strcmp(cmd, "dump_memory")) {
00046 DbgMemInfo::debug_dump();
00047 return TCL_OK;
00048 } else if (!strcmp(cmd, "dump_memory_diffs")) {
00049 DbgMemInfo::debug_dump(true);
00050 return TCL_OK;
00051 }
00052 #endif // OASYS_DEBUG_MEMORY_ENABLED
00053
00054 resultf("unimplemented debug subcommand: %s", cmd);
00055 return TCL_ERROR;
00056 }
00057
00058 }