diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-08-29 20:15:13 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-08-29 20:15:13 +0000 |
commit | 8c625dcd3353333b75276195845cfcfbe752d3cf (patch) | |
tree | 467185cfd84154026f9ffa1a3618ae095a6137bf | |
parent | 07cbfba0dba62c6c0723c1f01a10bbbb5f525b95 (diff) | |
download | ATCD-8c625dcd3353333b75276195845cfcfbe752d3cf.tar.gz |
ChangeLogTag:Sun Aug 29 07:53:33 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
-rw-r--r-- | ChangeLog-99b | 7 | ||||
-rw-r--r-- | ace/Malloc.cpp | 13 | ||||
-rw-r--r-- | ace/Malloc.h | 5 | ||||
-rw-r--r-- | ace/OS.i | 2 | ||||
-rw-r--r-- | tests/Malloc_Test.cpp | 59 |
5 files changed, 53 insertions, 33 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index 122d2f22d84..23d34e143e0 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,5 +1,12 @@ Sun Aug 29 07:53:33 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + * tests/Malloc_Test.cpp: Improved the test by printing out + additional diagnostic information. Also validated that it works + when ACE_DEFAULT_BASE_ADDR == 0 on Solaris using SunCC (with + purify) and EGCS. + + * ace/Malloc: Added a dump() method to ACE_Malloc_Header. + * ace/Process_Manager.cpp (ACE_Process_Descriptor): Changed a -1 to a 0 to prevent a compiler warning. Thanks to David Levine and DEC UNIX for reporting this. diff --git a/ace/Malloc.cpp b/ace/Malloc.cpp index f4d6d1274b7..696d03d4f54 100644 --- a/ace/Malloc.cpp +++ b/ace/Malloc.cpp @@ -24,13 +24,24 @@ ACE_Allocator *ACE_Allocator::allocator_ = 0; int ACE_Allocator::delete_allocator_ = 0; void +ACE_Malloc_Header::dump (void) const +{ + ACE_TRACE ("ACE_Malloc_Header::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\ns_.next_block = %x"), (ACE_Malloc_Header *) this->s_.next_block_)); + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\ns_.size = %d\n"), this->s_.size_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +void ACE_Control_Block::dump (void) const { ACE_TRACE ("ACE_Control_Block::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ((ACE_Name_Node *) this->name_head_)->dump (); - ACE_DEBUG ((LM_DEBUG, ASYS_TEXT("freep_ = %x"), (ACE_Malloc_Header *) this->freep_)); + ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("freep_ = %x"), (ACE_Malloc_Header *) this->freep_)); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } diff --git a/ace/Malloc.h b/ace/Malloc.h index 42722d64ccd..5e75cc28b64 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -111,9 +111,8 @@ public: long padding_[ACE_MALLOC_PADDING_SIZE < 1 : ACE_MALLOC_PADDING_SIZE]; #endif /* ACE_MALLOC_PADDING > 0 */ - ACE_UNIMPLEMENTED_FUNC (void dummy (void)) - // A dummy for egcs (or all g++ variants?) to prevent them from - // complaining "all member functions are private." + void dump (void) const; + // Dump the state of the object. #if defined (ACE_HAS_POSITION_INDEPENDENT_MALLOC) private: @@ -10327,7 +10327,7 @@ ACE_INLINE int ACE_OS::kill (pid_t pid, int signum) { ACE_TRACE ("ACE_OS::kill"); -#if defined (ACE_WIN32) || defined (CHORUS) || defined(ACE_PSOS) +#if defined (ACE_WIN32) || defined (CHORUS) || defined (ACE_PSOS) ACE_UNUSED_ARG (pid); ACE_UNUSED_ARG (signum); ACE_NOTSUP_RETURN (-1); diff --git a/tests/Malloc_Test.cpp b/tests/Malloc_Test.cpp index 60fcd6bb272..ead1f26e7b6 100644 --- a/tests/Malloc_Test.cpp +++ b/tests/Malloc_Test.cpp @@ -54,14 +54,10 @@ static MALLOC * myallocator (const void *base_addr = 0) { static ACE_MMAP_Memory_Pool_Options options (base_addr); - static MALLOC *static_allocator; - - ACE_NEW_RETURN (static_allocator, - MALLOC ("test_file", - "test_lock", - &options), - 0); - return static_allocator; + static MALLOC static_allocator ("test_file", + "test_lock", + &options); + return &static_allocator; } static Test_Data * @@ -81,7 +77,6 @@ initialize (MALLOC *allocator) ACE_ALLOCATOR_RETURN (gap, allocator->malloc (sizeof (256)), 0); - allocator->free (gap); ACE_ALLOCATOR_RETURN (ptr, @@ -181,18 +176,22 @@ child (void) { void *bar; // Perform "busy waiting" here until the parent stores data under a - // new name called "bar" in <ACE_Malloc>. This isn't really a good - // design -- it's just to test that synchronization is working - // across processes via <ACE_Malloc>. - while (myallocator ()->find ("bar", - bar) == -1) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("(%P) spinning in child!\n"))); + // new name called "bar" in <ACE_Malloc>. This isn't a good design + // -- it's just to test that synchronization is working across + // processes via <ACE_Malloc>. + for (ACE_Time_Value timeout (0, 1000 * 10); + myallocator ()->find ("bar", + bar) == -1; + ) + { + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("(%P) sleeping for 10 milliseconds!\n"))); + ACE_OS::sleep (timeout); + } print ("child", ACE_reinterpret_cast (Test_Data *, bar)); - return 0; } @@ -204,7 +203,7 @@ main (int argc, ASYS_TCHAR *[]) ACE_START_TEST (ASYS_TEXT ("Malloc_Test")); ACE_INIT_LOG (ASYS_TEXT ("Malloc_Test-child")); - // No arguments means we're the initial test. + // No arguments means we're the parent process. ACE_Process_Options options (1); options.command_line (ACE_TEXT (".") ACE_DIRECTORY_SEPARATOR_STR @@ -212,14 +211,16 @@ main (int argc, ASYS_TCHAR *[]) ACE_PLATFORM_EXE_SUFFIX ACE_TEXT (" run_as_test")); - Test_Data *data = initialize (myallocator (PARENT_BASE_ADDR)); + MALLOC *myalloc = myallocator (PARENT_BASE_ADDR); + Test_Data *data = initialize (myalloc); ACE_ASSERT (data != 0); ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("(%P) data allocated at address %x in parent\n"), + ASYS_TEXT ("(%P) PARENT allocator at = %x, data allocated at %x\n"), + myalloc, data)); - - int result = myallocator ()->bind ("foo", data); + myalloc->dump (); + int result = myalloc->bind ("foo", data); ACE_ASSERT (result != -1); ACE_Process p; @@ -229,8 +230,9 @@ main (int argc, ASYS_TCHAR *[]) parent (data); // Synchronize on the exit of the child. - p.wait (); - myallocator ()->remove (); + result = p.wait (); + ACE_ASSERT (result != -1); + myalloc->remove (); ACE_END_TEST; return 0; } @@ -240,14 +242,15 @@ main (int argc, ASYS_TCHAR *[]) ACE_APPEND_LOG (ASYS_TEXT ("Malloc_Test-child")); void *data = 0; - int result = myallocator (CHILD_BASE_ADDR)->find ("foo", - data); + MALLOC *myalloc = myallocator (CHILD_BASE_ADDR); + int result = myalloc->find ("foo", data); ACE_ASSERT (result != -1); ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("(%P) data allocated at address %x in child\n"), + ASYS_TEXT ("(%P) CHILD allocator at = %x, data allocated at %x\n"), + myalloc, data)); - + myalloc->dump (); child (); ACE_END_LOG; return 0; |