Changeset 63f2697


Ignore:
Timestamp:
Dec 7, 2021, 5:01:23 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
130a778
Parents:
75873cf
Message:

try plan B to find debug C code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/as.cc

    r75873cf r63f2697  
    1111// Created On       : Wed Aug  1 10:49:42 2018
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Dec  7 10:03:34 2021
    14 // Update Count     : 108
     13// Last Modified On : Tue Dec  7 16:56:24 2021
     14// Update Count     : 115
    1515//
    1616
     
    4848                if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); };
    4949
    50                 if ( char * dcursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?
    51                         // Expand file by one byte to hold 2 character Cforall language code.
    52                         if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
     50                char * dcursor;
     51                if ( (dcursor = strstr( start, ".Ldebug_info0:" ) ) ) { // debug information ?
    5352
    54                         char * cursor = dcursor;
    55                         for ( int i = 0; i < 8; i += 1 ) {                      // move N (magic) lines forward
    56                                 cursor = strstr( cursor, "\n" ) + 1;
    57                         } // for
    58 
    59                         cursor -= 2;                                                            // backup over "c\n" language value
    60                         if ( *(cursor - 1) != 'x' ) {                           // 0x before code
    61                                 for ( int i = 0; i < 8; i += 1 ) {                      // move N (magic) lines forward
     53                        if ( char * cursor = strstr( dcursor, ".long\t.LASF" ) ) { // debug information ?
     54                                for ( int i = 0; i < 2; i += 1 ) {              // move N (magic) lines forward
    6255                                        cursor = strstr( cursor, "\n" ) + 1;
    6356                                } // for
    64                                 fprintf( stderr, "*** ERROR *** Invalid C language code found in assembler file: %s\n"
    65                                                  "Assembler debug information:\n%.*s",
    66                                                  argv[argc - 1], (int)(cursor - dcursor) + 2, dcursor );
    67                                 exit( EXIT_FAILURE );
    68                         };
    6957
    70                         memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right
     58                                cursor -= 2;                                                    // backup over "c\n" language value
     59                                if ( *(cursor - 1) != 'x' ) {                   // 0x before code
     60                                        for ( int i = 0; i < 6; i += 1 ) {      // move N (magic) lines forward
     61                                                cursor = strstr( cursor, "\n" ) + 1;
     62                                        } // for
     63                                        fprintf( stderr, "*** ERROR *** Invalid C language code found in assembler file: %s\n"
     64                                                         "Assembler debug information:\n%.*s",
     65                                                         argv[argc - 1], (int)(cursor - dcursor), dcursor );
     66                                        exit( EXIT_FAILURE );
     67                                };
    7168
    72                         *(cursor) = '2';                                                        // replace C language value with CFA
    73                         *(cursor + 1) = '5';
     69                                // Expand file by one byte to hold 2 character Cforall language code.
     70                                if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
     71
     72                                memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right
     73
     74                                *(cursor) = '2';                                                // replace C language value with CFA
     75                                *(cursor + 1) = '5';
     76                        } // if
    7477                } // if
    7578
Note: See TracChangeset for help on using the changeset viewer.