be all somebody can/could do to do something

be all (one) could do (not) to (do something)

To be a struggle for one to do (something). The phrase often includes "not" when one is trying to avoid doing something. It was all I could do to keep from crying when the teacher yelled at me in front of the whole class. It was all I could do to not cry when the teacher yelled at me in front of the whole class.
See also: all, could

be all somebody can/could ˈdo (not) to do something

(informal) be very difficult (not) to do something: His face looked so funny that it was all she could do not to laugh.