As, Government of KSA has granted more than one time extension on the Crackdown against Illegal Expats. It is started and turning out to be a great move by the Government.
Those who were illegal in the cases of Iqama Expiry and they are arrested and spending their life in Prison can get out from this trouble in 2 ways.
1: Contact your Kafeel, Pay them the Government's fine and violation fee and Renew your Iqama is the only way to come out. If your kafeel deny to renew your iqama then arrange another Kafeel who will take your sponsorship and the further procedure continues.
2: If you were in KSA on Visit or Umrah Visa and didn't left the kingdom in the limited time and now you are arrested, The only way to go back to your country is to contact your Embassy and ask them for help.
Regards.
UT