Hi David-

>> The goal here is to do what you suggested above, namely, force the ObjC 
>> runtime to turn the NSException into a C++ exception for delivery to the 
>> tryCpp method, which is a plain C++ instance method.  But the debug output 
>> (copied below) suggests that is not happening: all of the exception 
>> personalities are of class GNUCOBJC.  Am I missing a step here, or not 
>> understanding the way exception personalities are passed through frames?  
>> I'm still learning this, so maybe I'm missing something obvious.
> 
> Try to recreate the structure of your original failure with the same mix of 
> ObjC/C++/ObjC++ stack frames and the same cleanups / catches.

I've got a working unit test in the libobjc2 Test directory, which depends only 
on libobjc2.  I'm trying to reproduce my original failure by doing the 
following:

1. Throw an exception from a .mm file.

2. Pass it through a .m file.

3. Catch the exception in a C++ class in another .mm file.

I tried a few versions of this, including catching the exception inside a C++ 
class, but so far I have not been able to induce the runtime to coerce a 
GNUCOBJC exception into a GNUCC++ one.  The debug logs report:

New personality function called 0xd28300
Class: GNUCOBJC
LSDA: 0x4024ec
Search phase...
handler: 1
New personality function called 0xd28300
Class: GNUCOBJC
LSDA: 0x4024ec
Phase 2: Fight!
Not the handler frame, looking up the cleanup again
Caught exception in C++

Are there certain code blocks that might make it more likely for the runtime to 
turn GNUCOBJC into GNUC++?  I've tried throwing the ObjC exception from inside 
a C++ try/catch block, but there's no GNUC++ exception in sight.  I've attached 
the files for this test, and the modified version of the CMakeLists.txt needed 
to build it (there's also a modified version of Test.h that separates class 
implementation from interface, since I'm using the class in multiple files for 
this test).

--David

Attachment: Chowda1.h
Description: Chowda1.h

Attachment: Chowda1.mm
Description: Chowda1.mm

Attachment: Chowda2.h
Description: Chowda2.h

Attachment: Chowda2.m
Description: Chowda2.m

Attachment: Chowda3.mm
Description: Chowda3.mm

Attachment: Clam.h
Description: Clam.h

Attachment: Clam.mm
Description: Clam.mm

# Clear the LD_LIBRARY_PATH if GNUstep set it so that we don't accidentally use
# the installed version


# List of single-file tests.
set(TESTS
        #alignTest.m
        AllocatePair.m
        AssociatedObject.m
        AssociatedObject2.m
        BlockImpTest.m
        BlockTest_arc.m
        BoxedForeignException.m
        ExceptionTest.m
        ForeignException.m
        Forward.m
        ManyManySelectors.m
        NestedExceptions.m
        PropertyAttributeTest.m
        PropertyIntrospectionTest.m
        PropertyIntrospectionTest2.m
        ProtocolCreation.m
        ResurrectInDealloc_arc.m
        RuntimeTest.m
        WeakReferences_arc.m
        objc_msgSend.m
        msgInterpose.m
        NilException.m
        MethodArguments.m
)

# Function for adding a test.  This takes the name of the test and the list of
# source files as arguments.
function(addtest_flags TEST FLAGS TEST_SOURCE)
        if (TEST MATCHES ".*_arc")
                # Only compile the main file with ARC
                set_source_files_properties(${TEST_SOURCE}
                        COMPILE_FLAGS "-fobjc-arc")
                # Add the ARC-incompatible definitions of the test class.
                list(APPEND TEST_SOURCE "Test.m")
        endif()
        add_executable(${TEST} ${TEST_SOURCE})
        add_test(${TEST} ${TEST})
        set(ARC "")
        set_target_properties(${TEST} PROPERTIES
                INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
                COMPILE_FLAGS "-fobjc-runtime=gnustep-1.7 -fblocks ${FLAGS}"
                LINKER_LANGUAGE C
        )
        set_property(TEST ${TEST} PROPERTY
                ENVIRONMENT "LD_LIBRARY_PATH="
        )
        target_link_libraries(${TEST} objc)
endfunction(addtest_flags)

foreach(TEST_SOURCE ${TESTS})
        get_filename_component(TEST ${TEST_SOURCE} NAME_WE)
        addtest_flags(${TEST} "-O0" ${TEST_SOURCE})
        addtest_flags("${TEST}_optimised" "-O3" ${TEST_SOURCE})
endforeach()

# Tests that are more than a single file.
addtest_flags(CXXExceptions "-O0" "CXXException.m;CXXException.cc")
addtest_flags(CXXExceptions_optimised "-O3" "CXXException.m;CXXException.cc")
addtest_flags(Chowda "-O0" "Chowda1.mm;Chowda2.m;Chowda3.mm;ModTest.m")

Attachment: ModTest.h
Description: ModTest.h

Attachment: ModTest.m
Description: ModTest.m






_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to