Shock formation and breaking in granular avalanches