Section 24. If a debtor committed to prison on a warrant of distress in favor of the commonwealth is unable to pay the debt for which he is imprisoned, he shall be entitled to discharge in like manner as a debtor before a court on supplementary proceedings; and the laws relative to such proceedings so far as applicable shall apply, except as hereinafter provided.