Changeset 813dfd86 for driver


Ignore:
Timestamp:
Dec 6, 2021, 5:06:04 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
295dd61
Parents:
c60e5094
Message:

print better information when asm check fails to find debug C code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/as.cc

    rc60e5094 r813dfd86  
    1111// Created On       : Wed Aug  1 10:49:42 2018
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sat Sep  8 08:40:16 2018
    14 // Update Count     : 97
     13// Last Modified On : Mon Dec  6 16:57:45 2021
     14// Update Count     : 104
    1515//
    1616
     
    4848                if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); };
    4949
    50                 if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?
     50                if ( char * dcursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ?
    5151                        // Expand file by one byte to hold 2 character Cforall language code.
    5252                        if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
    5353
     54                        char * cursor = dcursor;
    5455                        for ( int i = 0; i < 8; i += 1 ) {                      // move N (magic) lines forward
    5556                                cursor = strstr( cursor, "\n" ) + 1;
     
    5758
    5859                        cursor -= 2;                                                            // backup over "c\n" language value
    59                         if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); };
     60                        if ( *(cursor - 1) != 'x' ) {                           // 0x before code
     61                                fprintf( stderr, "*** ERROR *** Invalid C language code found in assembler file: %s\n"
     62                                                 "Assembler debug information:\n%.*s",
     63                                                 argv[argc - 1], (int)(cursor - dcursor) + 2, dcursor );
     64                                exit( EXIT_FAILURE );
     65                        };
    6066
    6167                        memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right
Note: See TracChangeset for help on using the changeset viewer.