<s> """<STR_LIT>""" <EOL> import os <EOL> import subprocess <EOL> from qisys import ui <EOL> import qisys . sh <EOL> import qisys . command <EOL> def contains_debug_info ( filename , objdump = None ) : <EOL> """<STR_LIT>""" <EOL> if not objdump : <EOL> objdump = "<STR_LIT>" <EOL> retcode = subprocess . call ( [ objdump , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , filename ] , <EOL> stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) <EOL> return ( retcode == <NUM_LIT:0> ) <EOL> def split_debug ( src , objcopy = None , objdump = None ) : <EOL> """<STR_LIT>""" <EOL> if objcopy is None : <EOL> objcopy = "<STR_LIT>" <EOL> if objdump is None : <EOL> objdump = "<STR_LIT>" <EOL> if not contains_debug_info ( src , objdump = objdump ) : <EOL> ui . info ( "<STR_LIT>" , src ) <EOL> return <EOL> src_stat = os . stat ( src ) <EOL> dirname , basename = os . path . split ( src ) <EOL> debug_dir = os . path . join ( dirname , "<STR_LIT>" ) <EOL> qisys . sh . mkdir ( debug_dir ) <EOL> dest = os . path . join ( src , debug_dir , basename ) <EOL> to_run = list ( ) <EOL> to_run . append ( [ objcopy , "<STR_LIT>" , src , dest ] ) <EOL> to_run . append ( [ objcopy , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" % dest , src ] ) <EOL> try : <EOL> for cmd in to_run : <EOL> qisys . command . check_output ( cmd , stderr = subprocess . STDOUT ) <EOL> ui . info ( "<STR_LIT>" , src ) <EOL> except qisys . command . CommandFailedException as e : <EOL> ui . error ( "<STR_LIT>" % src ) <EOL> ui . error ( str ( e ) ) <EOL> os . utime ( src , ( src_stat . st_atime , src_stat . st_mtime ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import sys <EOL> split_debug ( sys . argv [ <NUM_LIT:1> ] ) </s>
