Why did Atticus look like "his stomach hurt" after questioning Mayella during the trial?
Atticus was aware of Mayella's poor home life and he no doubt found her a young woman to be pitied. He probably knew of prior verbal and physical abuse she suffered at the hands of her father, and Atticus did not relish the idea of bringing the Ewell family indiscretions out in a public setting. Atticus probably had no qualms about exposing Bob Ewell's evil ways to the jury and courtroom spectators, but his sense of honor and gentlemanly nature was compromised when he was forced to do the same with Mayella. Of course, Atticus trusted that Tom was innocent of the charges brought against him, so he had no choice but to try and force the truth out of Mayella.
I think that there are three possible reasons why Atticus might feel this way.
First, I think he probably feels bad for having cross-examined her the way that he has. I think he feels bad that he had to ask her the sorts of personal questions he did and he feels bad for having to sort of bully her, trying to get her to admit the truth.
Second, I think that he probably feels sorry for her. If you knew that this girl had a father who treats her the way Mayella's dad does, how would you feel?
Finally, I think he may feel that he has lost the case already. He may feel that his only hope was to get Mayella to confess the truth.