DebugCommand.cc

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
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     // debug dump_memory
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 } // namespace oasys

Generated on Thu Jun 7 12:54:26 2007 for DTN Reference Implementation by  doxygen 1.5.1