Changeset 88792f3 for driver


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

add debug C89/C code to assembler check

File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/as.cc

    r130a778 r88792f3  
    1111// Created On       : Wed Aug  1 10:49:42 2018
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Dec  7 20:49:15 2021
    14 // Update Count     : 121
     13// Last Modified On : Tue Dec  7 21:15:25 2021
     14// Update Count     : 132
    1515//
    1616
     
    1818#include <cstdlib>                                                                              // exit
    1919#include <fcntl.h>                                                                              // open
    20 #include <unistd.h>
    21 #include <sys/stat.h>
     20#include <cstring>                                                                              // strstr, memmove
     21#include <unistd.h>                                                                             // ftruncate,execvp
     22#include <sys/stat.h>                                                                   // fstat
    2223#include <sys/mman.h>                                                                   // mmap
    23 #include <string.h>
    2424
    2525//#define __DEBUG_H__
    26 
    27 #ifdef __DEBUG_H__
    28 #include <iostream>
    29 using namespace std;
    30 #endif // __DEBUG_H__
    3126
    3227int main( const int argc, const char * argv[] ) {
    3328        #ifdef __DEBUG_H__
    3429        for ( int i = 0; i < argc; i += 1 ) {
    35                 cerr << argv[i] << endl;
     30                fprintf( stderr, "%s\n", argv[i] );
    3631        } // for
    3732        #endif // __DEBUG_H__
     
    5651                                } // for
    5752                                cursor -= 1;                                                    // backup over '\n'
    58                                 if ( (*(cursor - 3) == '0' && *(cursor - 2) == 'x' && *(cursor - 1) == 'c') ) { // 0xc => C99
     53                                // From elfcpp/dwarf.h in the binutils source tree.
     54                                // DW_LANG_C89 = 0x1, DW_LANG_C = 0x2, DW_LANG_C99 = 0xc, DW_LANG_C11 = 0x1d
     55                                if ( *(cursor - 3) == '0' && *(cursor - 2) == 'x' &&
     56                                         (*(cursor - 1) == 'c' || *(cursor - 1) == '1' || *(cursor - 1) == '2') ) { // C89/C/C99
    5957                                        // Expand file by one byte to hold 2 character Cforall language code.
    6058                                        if ( ftruncate( fd, size + 1 ) ) { perror( "ftruncate" ); exit( EXIT_FAILURE ); };
    6159                                        memmove( cursor + 1, cursor, start + size - cursor ); // move remaining text 1 character right
    62                                 } else if ( *(cursor - 4) == '0' && *(cursor - 3) == 'x' && *(cursor - 2) == '1' && *(cursor - 1) == 'd' ) { // 0x1d => C11
    63                                         // replace "1d" with "25"
     60                                } else if ( *(cursor - 4) == '0' && *(cursor - 3) == 'x' && *(cursor - 2) == '1' && *(cursor - 1) == 'd' ) { // C11
    6461                                } else {
    6562                                        for ( int i = 0; i < 6; i += 1 ) {      // move N (magic) lines forward
     
    7269                                } // if
    7370
    74                                 *(cursor - 2) = '2';                                    // replace C/C11 language value with CFA
     71                                *(cursor - 2) = '2';                                    // replace C89/C/C99/C11 language code with CFA code
    7572                                *(cursor - 1) = '5';
    7673                        } // if
Note: See TracChangeset for help on using the changeset viewer.