Skip to content

Commit

Permalink
Added a maxBytesToPrint arg to snoopsharedmem
Browse files Browse the repository at this point in the history
  • Loading branch information
jfriesne committed Oct 27, 2023
1 parent 0b1ffd2 commit f719845
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ key: - new feature
when possible.
- Added IsAtStart() and IsAtEnd() convenience-methods to the
HashtableIterator class.
- The snoopsharedmem tool now support an optional (maxBytesToPrint)
argument, in case you only want to see the header of the region.
o Removed obsolete references to TARGET_PLATFORM_XENOMAI.
o Updated the captive zlib library to the current GitHub version,
to avoid "function declaration without a prototype is deprecated"
Expand Down
15 changes: 13 additions & 2 deletions tools/snoopsharedmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ using namespace muscle;
int main(int argc, char ** argv)
{
CompleteSetupSystem css;
uint32 maxBytesToPrint = MUSCLE_NO_LIMIT;

if (argc < 2)
{
LogTime(MUSCLE_LOG_CRITICALERROR, "Usage: ./snoopsharedmem shared_memory_region_name\n");
LogTime(MUSCLE_LOG_CRITICALERROR, "Usage: ./snoopsharedmem shared_memory_region_name [maxBytesToPrint]\n");
return 0;
}

const char * shmemName = argv[1];

if (argc > 2)
{
const uint32 numBytes = atol(argv[2]);
if (numBytes > 0)
{
LogTime(MUSCLE_LOG_INFO, "Limiting printouts to the first " UINT32_FORMAT_SPEC " bytes of the shared memory area.\n", numBytes);
maxBytesToPrint = numBytes;
}
}

status_t ret;
SharedMemory m;
if (m.SetArea(shmemName, 0, false).IsOK(ret))
Expand All @@ -32,7 +43,7 @@ int main(int argc, char ** argv)
while(1)
{
(void) Snooze64(MillisToMicros(100));
PrintHexBytes(a, memSize);
PrintHexBytes(a, muscleMin(memSize, maxBytesToPrint));
}
}
else LogTime(MUSCLE_LOG_ERROR, "SetArea(%s) failed, exiting! [%s]\n", shmemName, ret());
Expand Down

0 comments on commit f719845

Please sign in to comment.