Changes in driver/as.cc [245a92c:fc846ae]
- File:
-
- 1 edited
-
driver/as.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
driver/as.cc
r245a92c rfc846ae 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // as.c -- map assembler file, scan for debug information. If found, expand file by one character and insert Cforall 8 // language code on the N line from the start of the debug information. 7 // as.c -- 9 8 // 10 9 // Author : Peter A. Buhr 11 10 // Created On : Wed Aug 1 10:49:42 2018 12 11 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Sat Sep 8 08:40:16201814 // Update Count : 9 712 // Last Modified On : Thu Aug 2 17:50:09 2018 13 // Update Count : 90 15 14 // 16 15 … … 24 23 25 24 //#define __DEBUG_H__ 26 27 #ifdef __DEBUG_H__28 #include <iostream>29 using namespace std;30 #endif // __DEBUG_H__31 25 32 26 int main( const int argc, const char * argv[] ) { … … 44 38 off_t size = mystat.st_size; 45 39 46 if ( size ) { // cannot map 0 sized file 47 char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); 48 if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); }; 40 char * start = (char *)mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); 41 if ( start == (void *)-1 ) { perror( "mmap" ); exit( EXIT_FAILURE ); }; 49 42 50 if ( char * cursor = 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 ); };43 if ( char * cursor = strstr( start, ".Ldebug_info0:" ) ) { // debug information ? 44 // Expand file by one byte to hold 2 character Cforall language code. 45 if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); }; 53 46 54 for ( int i = 0; i < 8; i += 1 ) {// move N (magic) lines forward55 cursor = strstr( cursor, "\n" ) + 1;56 } // for47 for ( int i = 0; i < 8; i += 1 ) { // move N (magic) lines forward 48 cursor = strstr( cursor, "\n" ) + 1; 49 } // for 57 50 58 cursor -= 2;// backup over "c\n" language value59 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); };51 cursor -= 2; // backup over "c\n" language value 52 if ( *(cursor - 1) != 'x' ) { fprintf( stderr, "invalid C language code\n" ); exit( EXIT_FAILURE ); }; 60 53 61 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right54 memmove( cursor + 2, cursor + 1, start + size - cursor - 1 ); // move remaining text 1 character right 62 55 63 *(cursor) = '2';// replace C language value with CFA64 *(cursor + 1) = '5';65 } // if56 *(cursor) = '2'; // replace C language value with CFA 57 *(cursor + 1) = '5'; 58 } // if 66 59 67 if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk 68 } // if 60 if ( munmap( start, size ) ) { perror( "munmap" ); exit( EXIT_FAILURE ); }; // update on disk 69 61 70 62 argv[0] = "as";
Note:
See TracChangeset
for help on using the changeset viewer.