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
Farlex Dictionary of Idioms.

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.
See also: all, can, could, somebody, something
Farlex Partner Idioms Dictionary
See also:
  • (one) could use (something)
  • as one door closes, another (one) opens
  • as one door closes, another one opens
  • as one door closes, another opens
  • drive (one) out of office
  • force (one) out of office
  • force out of office
  • give (one) (one's) head
  • give head
  • give somebody their head