I've had pretty severe anxiety for a few years now and used to get jolted awake too just as I was about to fall asleep which was pretty upsetting and frustrating. I also get weak and dizzy when I am about to have a panicky episode.
I've done TONS of research online and have a bunch of theories, one is that somehow the vagus nerve is being irritated causing all kinds of disturbing symptoms. Maybe all the bloating is causing the diaphragm to push up on everything, including the vagus nerve as well as the lungs, which would explain why I feel short of breath sometimes. I also agree there may be some malabsorption, as well as possibly lack of oxygen to the brain.
However, I have learned recently that Pepto stops my panicky feelings when I get glutened. Within 30 minutes of taking it, I feel 100% better. I also noticed that if I took it before bed, I would not be jolted awake or have nightmares. Pepto has been my best friend lately. Besides helping the panic attacks, it also really eases my GI symptoms like nausea, burning, etc.
I really hope this will help anyone having anxiety attacks from gluten. Pepto is pretty safe so it's worth a try!