00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <blackboard/shmem/lister.h>
00025 #include <utils/system/console_colors.h>
00026 #include <utils/ipc/shm.h>
00027
00028 #include <iostream>
00029 #include <cstdio>
00030
00031 using namespace std;
00032 namespace fawkes {
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 BlackBoardSharedMemoryLister::BlackBoardSharedMemoryLister()
00043 {
00044 num = 0;
00045 }
00046
00047
00048
00049 BlackBoardSharedMemoryLister::~BlackBoardSharedMemoryLister()
00050 {
00051 }
00052
00053
00054
00055
00056
00057
00058 void
00059 BlackBoardSharedMemoryLister::print_header()
00060 {
00061 cout << endl << cblue << "Fawkes BlackBoard Shared Memory Segments" << cnormal << endl
00062 << "========================================================================" << endl
00063 << cdarkgray;
00064 printf ("%-3s %-10s %-11s %-16s %-12s %s\n",
00065 "#", "ShmID", "Semaphore", "Bytes", "# attached", "State");
00066 cout << cnormal
00067 << "------------------------------------------------------------------------" << endl;
00068 num = 0;
00069 }
00070
00071
00072
00073
00074
00075
00076 void
00077 BlackBoardSharedMemoryLister::print_footer()
00078 {
00079 cout << "========================================================================" << endl;
00080 }
00081
00082
00083
00084
00085
00086 void
00087 BlackBoardSharedMemoryLister::print_no_segments()
00088 {
00089 cout << "No Fawkes BlackBoard shared memory segments found" << endl;
00090 }
00091
00092
00093
00094
00095
00096
00097 void
00098 BlackBoardSharedMemoryLister::print_no_orphaned_segments()
00099 {
00100 cout << "No " << cdarkgray << "orphaned" << cnormal
00101 << " Fawkes BlackBoard shared memory segments found" << endl;
00102 }
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 void
00116 BlackBoardSharedMemoryLister::print_info(const SharedMemoryHeader *header,
00117 int shm_id, int semaphore,
00118 unsigned int mem_size,
00119 const void *memptr)
00120 {
00121 unsigned int nattch = SharedMemory::num_attached(shm_id);
00122 bool swapable = SharedMemory::is_swapable(shm_id);
00123 bool destroyed = SharedMemory::is_destroyed(shm_id);
00124
00125 printf ("%-3u %-10d 0x%08x %-16u %-12u %s%s%s%s%s\n",
00126 ++num, shm_id, semaphore, mem_size, nattch,
00127 ((nattch > 1) ? "active" : "orphaned"),
00128 ((swapable || destroyed) ? " (" : ""),
00129 (swapable ? "S" : ""),
00130 (destroyed ? "D" : ""),
00131 ((swapable || destroyed) ? ")" : "")
00132 );
00133 }
00134
00135 }