I am so sorry to hear about your little guy's cough! Could it be an allergy?
My 3 year old had something quite similar to what you described. He coughed so hard that he vomited too! Turns out he is allergic to sugar and cow's milk. We were giving him things and it was bothering him and we had no idea. He had that cough for almost a YEAR before we figured it out.
There is a great book called "is this your child" by Dr Doris Rapp. We did the elimination diet that she talks about in the book to determine what the issue was.
The dr wanted to put him on allergy medications right away before investigating. I am so glad we decided not to medicate him and took it into our own hands.
Sorry for the "novel" here, I just wanted to let you know that I had a similar situation and drs are so quick to medicate. I am really big into natural alternatives if you'd like to hear more about what we did!