Skip to content

Commit

Permalink
Add [hide_prefix] command-line option
Browse files Browse the repository at this point in the history
  • Loading branch information
MatwayBurkow committed Jan 13, 2021
1 parent cfc365a commit 924d63f
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 30 deletions.
19 changes: 12 additions & 7 deletions debugWriter.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,20 @@ addFuncSubroutineInfo: [
addFuncDebugInfo: [
compileOnce
position: funcName: funcIRName: funcDebugIndex: processor: ;;;;;

subroutineIndex: @processor addFuncSubroutineInfo;
funcImplementation: funcName makeStringView getStringImplementation;

funcImplementation: (position.file.name dup ".mpl" makeStringView endsWith [4] [0] if untail " " funcName) assembleString getStringImplementation;
(
"!" funcDebugIndex " = distinct !DISubprogram(name: \"" funcImplementation "\", linkageName: \"" @funcIRName
"\", scope: !" position.file.debugId
", file: !" position.file.debugId ", line: " position.line ", type: !" subroutineIndex
", scopeLine: " position.line ", unit: !" processor.debugInfo.unit ")") assembleString addDebugString
"!" funcDebugIndex " = distinct !DISubprogram("
"name: \"" funcImplementation "\", "
"linkageName: \"" @funcIRName "\", "
"scope: !" position.file.debugId ", "
"file: !" position.file.debugId ", "
"line: " position.line ", "
"type: !" subroutineIndex ", "
"scopeLine: " position.line ", "
"unit: !" processor.debugInfo.unit
")"
) assembleString addDebugString
];

addDebugLocation: [
Expand Down
14 changes: 8 additions & 6 deletions defaultImpl.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ getStackDepth: [
processor.positions.getSize [
currentPosition: processor.positions.getSize 1 - i - processor.positions.at;

(
"at fileName: " currentPosition.file.name
", token: " currentPosition.token
", line: " currentPosition.line
", column: " currentPosition.column LF
) printList
processor.options.hidePrefixes [currentPosition.file.name swap beginsWith ~] all [
(
"at fileName: " currentPosition.file.name
", token: " currentPosition.token
", line: " currentPosition.line
", column: " currentPosition.column LF
) printList
] when
] times

@processor block defaultPrintStack
Expand Down
8 changes: 6 additions & 2 deletions irWriter.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ createCallIR: [
haveRet: refToRet.var isNil ~;
retName: 0;

processor.options.callTrace hasCallTrace and [@processor @block createCallTraceProlog] when
processor.options.hidePrefixes [processor.positions.last.file.name swap beginsWith ~] all [
processor.options.callTrace hasCallTrace and [@processor @block createCallTraceProlog] when
] when

offset: block.programTemplate.size;

Expand Down Expand Up @@ -506,7 +508,9 @@ createCallIR: [

@processor @block addDebugLocationForLastInstruction

processor.options.callTrace hasCallTrace and [@processor @block createCallTraceEpilog] when
processor.options.hidePrefixes [processor.positions.last.file.name swap beginsWith ~] all [
processor.options.callTrace hasCallTrace and [@processor @block createCallTraceEpilog] when
] when

retName
];
Expand Down
25 changes: 16 additions & 9 deletions main.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ printInfo: [
] when
" -dynalit Number literals are dynamic constants, which are not used in analysis; default mode is static literals" print LF print
" -end_func <name> Name of end function, default value is \"main\"" print LF print
" -hide_prefix <path> Ignore files with this prefix in stack trace outputs" print LF print
" -linker_option Add linker option for LLVM" print LF print
" -ndebug Disable debug info; value of \"DEBUG\" constant in code turn to FALSE" print LF print
" -o <file> Write output to <file>, default output file is \"mpl.ll\"" print LF print
Expand Down Expand Up @@ -159,20 +160,21 @@ checkedSaveString: [

success: TRUE dynamic;

OPT_ANY: [0 dynamic];
OPT_OUTPUT_FILE_NAME: [1 dynamic];
OPT_LINKER_OPTION: [3 dynamic];
OPT_DEFINITION: [4 dynamic];
OPT_ARRAY_CHECK: [5 dynamic];
OPT_CALL_TRACE: [6 dynamic];
OPT_RECURSION_DEPTH_LIMIT: [7 dynamic];
OPT_PRE_RECURSION_DEPTH_LIMIT: [8 dynamic];
OPT_STATIC_LOOP_LENGTH_LIMIT: [9 dynamic];
OPT_ANY: [ 0 dynamic];
OPT_OUTPUT_FILE_NAME: [ 1 dynamic];
OPT_LINKER_OPTION: [ 3 dynamic];
OPT_DEFINITION: [ 4 dynamic];
OPT_ARRAY_CHECK: [ 5 dynamic];
OPT_CALL_TRACE: [ 6 dynamic];
OPT_RECURSION_DEPTH_LIMIT: [ 7 dynamic];
OPT_PRE_RECURSION_DEPTH_LIMIT: [ 8 dynamic];
OPT_STATIC_LOOP_LENGTH_LIMIT: [ 9 dynamic];
OPT_INCLUDE_PATH: [10 dynamic];
OPT_BEGIN_FUNC: [11 dynamic];
OPT_END_FUNC: [12 dynamic];
OPT_TRIPLE: [13 dynamic];
OPT_DATA_LAYOUT: [14 dynamic];
OPT_HIDE_PREFIX: [15 dynamic];

nextOption: OPT_ANY;

Expand Down Expand Up @@ -232,6 +234,7 @@ checkedSaveString: [
] when
"-dynalit" [FALSE @options.!staticLiterals]
"-end_func" [OPT_END_FUNC !nextOption]
"-hide_prefix" [OPT_HIDE_PREFIX !nextOption]
"-linker_option" [OPT_LINKER_OPTION !nextOption]
"-ndebug" [FALSE @options.!debug]
"-o" [OPT_OUTPUT_FILE_NAME !nextOption]
Expand Down Expand Up @@ -322,6 +325,10 @@ checkedSaveString: [
TRUE !hasTriple
OPT_ANY !nextOption
]
OPT_HIDE_PREFIX [
option simplifyFileName @options.@hidePrefixes.pushBack
OPT_ANY !nextOption
]
[]
) case
] if
Expand Down
1 change: 1 addition & 0 deletions processor.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ProcessorOptions: [{
endFunc: String;
fileNames: StringArray;
includePaths: StringArray;
hidePrefixes: StringArray;
pointerSize: 64nx dynamic;
staticLiterals: TRUE dynamic;
debug: TRUE dynamic;
Expand Down
16 changes: 10 additions & 6 deletions processorImpl.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,19 @@ debugMemory [
current.position.getSize 0 = [
("error, " current.message LF) [@result.cat] each
] [
first: TRUE;
current.position.getSize [
nodePosition: i current.position @;
(nodePosition.file.name "(" nodePosition.line "," nodePosition.column "): ") [@result.cat] each
processor.options.hidePrefixes [nodePosition.file.name swap beginsWith ~] all [
(nodePosition.file.name "(" nodePosition.line "," nodePosition.column "): ") [@result.cat] each

i 0 = [
("error, [" nodePosition.token "], " current.message LF) [@result.cat] each
] [
("[" nodePosition.token "], called from here" LF) [@result.cat] each
] if
first [
("error, [" nodePosition.token "], " current.message LF) [@result.cat] each
FALSE !first
] [
("[" nodePosition.token "], called from here" LF) [@result.cat] each
] if
] when
] times
] if
] times
Expand Down

0 comments on commit 924d63f

Please sign in to comment.