1

Can a debugger let me see the queries that the application does? For example if I have a database application (written in C or in Java) that connect itself to postgresql, can gdb show me the statments inside the program? Thank you

DarkCoffee
  • 930
  • 3
  • 17
  • 30
  • If you are looking to see a log of the queries, I would look at logging such as these: http://chrismiles.info/systemsadmin/databases/articles/viewing-current-postgresql-queries/ and http://stackoverflow.com/questions/8597516/app-to-monitor-postgresql-queries-in-real-time – Frank van Puffelen Dec 17 '12 at 18:03
  • 1
    @frank-van-puffelen Thank you. I've read it, but for me is a little different because I need to know the input parameters and the queries. So I've thought that maybe with the debugger I can see both of them (input and statement) – DarkCoffee Dec 17 '12 at 19:18

1 Answers1

1

can gdb show me the statments inside the program?

Yes, but you'll need to find a place in the database server where that info is conveniently available, and set a breakpoint there.

It's possible that the client library turns the query and parameters into a packed structure of some sort before sending it to the server, and the info may not be conveniently available on the server side at all. But that's not very likely, as the server probably has ability to log the queries.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Do you mean that I have to check in the log db? – DarkCoffee Dec 18 '12 at 17:07
  • @DarkCoffee No, I don't mean that. I mean that you need to read the sources of your DB Server (if available) or reverse-engineer it (if sources are not available). Once you find the *place where statements being executed* are available (as function parameters, or values of variables), then set a breakpoint there and observe them. – Employed Russian Dec 18 '12 at 17:32
  • Thank you so much! I am going to try it! – DarkCoffee Dec 19 '12 at 00:12