Author Topic: Need verification on steps to enable pretty printers  (Read 6415 times)

Offline Sab

  • Multiple posting newcomer
  • *
  • Posts: 13
Need verification on steps to enable pretty printers
« on: May 12, 2015, 02:21:19 pm »
OS : Windows 7 64-bit
C::B version : 13.12
gcc version:4.9.2

I got gcc from equations.com http://www.equation.com/servlet/equation.cmd?fa=fortran

I want to enable pretty printers so I checked the form and read through posts.

1.http://forums.codeblocks.org/index.php/topic,11301.msg77000.html#msg77000
2.https://code.google.com/p/qp-gcc/wiki/GDB
3.http://wiki.codeblocks.org/index.php?title=Pretty_Printers

I still have some confusions so I am going to state the steps to follow as I understood

1. Install python version 2.7.5(when I checked that download page it stated that there are few bugs and then ended up at Python 2.7.8 )
2. get gdb package from http://sourceforge.net/projects/gdbmingw/files/gdb2014-05-23.zip/download
3. get python scripts from http://qp-gcc.googlecode.com/files/stdcxx_and_wx_pythonscript.7z
4. Add the script path as mention in the second URL I used for reference (https://code.google.com/p/qp-gcc/wiki/GDB)

and I am good to go?
« Last Edit: May 12, 2015, 02:34:38 pm by Sab »

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Need verification on steps to enable pretty printers
« Reply #1 on: May 12, 2015, 06:20:49 pm »
I don't think you need a python installation to use pretty printers but a python enabled gdb.

Offline Sab

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Need verification on steps to enable pretty printers
« Reply #2 on: May 12, 2015, 07:16:15 pm »
I don't think you need a python installation to use pretty printers but a python enabled gdb.


.http://forums.codeblocks.org/index.php/topic,11301.msg77000.html#msg77000 and https://code.google.com/p/qp-gcc/wiki/GDB in these post it is mentioned that installing python is a must.

And the my previous version (gcc4.7.2) which I also downloaded from http://www.equation.com/servlet/equation.cmd?fa=fortran was python enabled but the gcc 4.9.2 is not. After installing I noticed that there is a python command prompt in c:/MinGw/bin. I have attached screenshot for the same.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Need verification on steps to enable pretty printers
« Reply #3 on: May 12, 2015, 07:55:23 pm »
You're mixing GCC and GDB. These are two separate projects!
GCC is the compiler, GDB is the debugger.
GCC has nothing to do with python.

You need python enabled GDB! I don't know if you really need to have separate python installation.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Need verification on steps to enable pretty printers
« Reply #4 on: May 12, 2015, 08:04:11 pm »
Hmm, I think ollydbg's gdb is linking to the official python installation which might be the case. The compiler and debugger I use (the one from mingw-builds) doesn't need a python installation and comes pretty much with everything bundled including a python interpreter (as in your screen shot), startup scripts and pretty printers. All I have to do is install the compiler, configure in CB, make sure 'settings->debugger->disable startup scripts' is not checked and it's ready to use with pretty printers. No python installation necessary. For your consideration...

Offline Sab

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Need verification on steps to enable pretty printers
« Reply #5 on: May 13, 2015, 05:57:10 am »
Hmm, I think ollydbg's gdb is linking to the official python installation which might be the case. The compiler and debugger I use (the one from mingw-builds) doesn't need a python installation and comes pretty much with everything bundled including a python interpreter (as in your screen shot), startup scripts and pretty printers. All I have to do is install the compiler, configure in CB, make sure 'settings->debugger->disable startup scripts' is not checked and it's ready to use with pretty printers. No python installation necessary. For your consideration...


Thanks for your help it worked. I didn't check the 'Enable startup script'.

I am summarizing:

For gdb which is not python enabled but came with a python interpreter, follow the steps below:

1.Add the following lines in 'Settings->Debugger->Debugger initalization commands'
  source C:\MinGW\bin\stl.gdb
  source C:\MinGW\bin\wx.gdb
2. Check the 'Enable watch script' checkbox

and pretty printers are ready to use.

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 190
Re: Need verification on steps to enable pretty printers
« Reply #6 on: March 06, 2016, 05:03:01 am »
Sorry, can't get it to work.

I can not watch wxString in the dbg debugger output. In Locals I see the variable name of my wxString, but the column with the content stays empty. wxRect remains empty as well.

I am runnig Win7, x64 and I am using wxWidgets 2.9.3(which is unicode only), C::B 15.12. The project and all libs are 32bit.

Thats was the procedure:
1. Installed Installer V15.12. with MinGw (yield V4.9.2). Moved MinGw to C:\MinGw for easier handling
2. downloaded http://qp-gcc.googlecode.com/files/stdcxx_and_wx_pythonscript.7z, unzipped in MinGw/Bin/*.*
3. In Settings/Debugger/gdb/Default/InitCommands added the follwing and checked Enable Watch scripts. Unchecked
    "Disable startup scripts"
       source C:\MinGW\bin\stl.gdb
       source C:\MinGW\bin\wx.gdb
4. downloaded http://sourceforge.net/projects/gdbmingw/files/gdb2014-05-23.zip/download and unzipped into C:/MinGw/
5.downloaded python from https://www.python.org/ftp/python/2.7.6/python-2.7.6.msi and installed it (I noted that the modified gdb only needs a "python27.dll" which was installed by the Python x86 version, but not by the x64 version).
6. Changed the following 2 lines of the file C:/MinGw/bin/libwx/v28/printer.py
 
Code
val['m_pchData'].string()           => val['m_impl']['_M_dataplus']['_M_p'].string()
return self.val['m_pchData'].string()     =>  return self.val['m_impl']['_M_dataplus']['_M_p'].string()

According to what I found that should do it? But what did I forget, since the result is unchanged.

Since the pyEnabled failed to work without that dll expect that the GDB is python enabled indeed and should work (I tried all other versions of PythonEnabled gbd's I could find with no difference). In the debug output I can see the string data in the _M_dataplus _M_p structure, so dbg is reading the value OK, but its not printed out.

Seems that pretty printing generally is off? I am really bad with scripting, so I have no clue what the thing is doing  :-[

Looking at the debug log the init commans do not create any error or unusual output:
Code
[debug]>C:\MinGW\bin\stl.gdb
C:\MinGW\bin\wx.gdb
[debug]>>>>>cb_gdb:>>>>>>cb_gdb:

I do not know how I can find out wether or not pretty printers are actually working at all. Maybe I do not have
a problem with wxString but pretty printing.

Solving that issue would really make my day :-* . I am struggeling with that issue for ages and never got it really stable.

Regards,
Tiger


PS. I also tried with the MinGw-W64 32bit install with no other result.

 


« Last Edit: March 06, 2016, 05:15:17 am by tigerbeard »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Need verification on steps to enable pretty printers
« Reply #7 on: March 06, 2016, 12:52:28 pm »
In the debug log you can execute the command "info pretty-printer". It will show you some output or an error.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 190
Re: Need verification on steps to enable pretty printers
« Reply #8 on: March 06, 2016, 01:15:56 pm »
it says:

Code
[debug]global pretty-printers
[debug]  .*
[debug]    bound
[debug]>>>>>>>>>>cb_gdb:

Hm. Seems to mean that the pretty printers are working, right?

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 190
Re: Need verification on steps to enable pretty printers
« Reply #9 on: March 07, 2016, 03:02:15 pm »
The advice lead me to the solution.
In the debug log you can execute the command "info pretty-printer". It will show you some output or an error.
Thanks a lot, oFBfusCATed -> you made my day 8).
So the procedure I followed was correct.

It showed me that I had been looking at the wrong end. Most of the versions I tried actually were python
enabled and worked fine with pretty-printing itself. Just I did not recognise. The problem was in my
manual script change in  "http://qp-gcc.googlecode.com/files/stdcxx_and_wx_pythonscript.7z". The change
itself was syntactically correct but obviously I used a TAB somewhere. I just learned that python seems
to be pretty allergic against tabs - quite a surprise. I remove any tabs and, voila, my wxString content
printouts were there, wether or not _T("..") or "..".

So I learned for my procedure :
 - check if the gdb base is ok: Run debug, enter in its command line "info pretty-printer". If you get
  ' Undefined info command: "pretty-printer".', you need another gdb or python or you would'nt see
   a wxString output.
 - Enable Settings/Debugger/Full log and look at the line where the source commands are executed.
   The OK output shoudl be '>>>>>>cb_gdb:>>>>>>cb_gdb:'
 - Only if both is OK, start looking at the syntax in the scripts

Now, I have two more things:

1) am intertested in thoughts on the following approach:
I have to use different version of gcc in some cases. Thus I install my compilers not in the C::B directory
but on the same level as C::B itself. I found that seems to work for the debugger as well. I just did
the setup today and need to work a bit still to see any side effects. Maybe someone else is already
working with that setup.
The setup looks like this
Code
C:/
  CodeBlocks/
  Gdb_wxUnicode/
      bin/
          libstdcxx/
          libwx/
      include/
      share/
  Gdb_beforeUnicode/
  MinGw4.62/
  MinGw5.3/
  MinGw64bit

The gdb bin only has a gdb.exe and a gdbserver.exe and the printer scripts including their subdirs. I was a
bit surprised that it does not require more resources of the MinGw directory, but so far works fine. The very
nice thing is that I can switch between gdb setups by only editing the C::B/Settings/Debugger/Default/
ExecutablePath. I could install/deinstall MinGw without the need to touch gdb again.
Maybe I overlooked something?

2) I think it would be nice to have an updated Zip file with that fully working setup. A python enabled gdb
  and the script files with the changes (but without python installer) for convenience of others (an myself
  in the future) with a link it in the post. I do not have any cloud space and also wouldn't think its good
  to put it somewhere where  the link dies when the provide company decide its time to change their
  business model. There are too many dead links to interesting stuff in other forums I use. If someone
  is willing to help me finding a place where to put it I can offer to prepare the package with instructions.
  Maybe there is even a newer python enabled gdb than 23.05.2014. I did not find any links or hints
  to the pything enabled gdbs on the MinGw website, but I probably just missed then.
 
Cheers,
Tiger