in src/main/kotlin/com/github/mkartashev/hserr/miner/artifact/Instructions.kt [24:41]
override fun extract(log: HsErrLog): InstructionsArtifact {
val instructionsSelection = log.start.moveToLineStartsWithString("Instructions: (pc=").selectUpToFirstEmptyLine()
if (instructionsSelection.isEmpty()) fail("Couldn't find the instructions section")
val pcSelection = instructionsSelection.start.moveToString("(pc=", false).selectCurrentHexNumber()
val pc = pcSelection.toString()
if (pc.isBlank()) fail("Couldn't extract PC from the instructions section")
val codeStart = instructionsSelection.start.moveToLineStartsWithString("$pc:")
val code = TextRange.of(codeStart, instructionsSelection.endInclusive).toString()
// Now strip address prefixes:
val instructionsFromPC = code.lines().joinToString("\n")
{ it.substringAfter(": ") }.trimEnd()
return InstructionsArtifact(log, instructionsSelection, instructionsFromPC)
}