This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

I am writing an amf plugin . I want to debug it during live packet capture. Is it possible?

asked 06 Nov '12, 21:15

Akhil's gravatar image

Akhil
53272831
accept rate: 0%

edited 09 Nov '12, 02:29

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
24.8k1039237


Sure, although processing the captured packets will necessarily be inhibited while you have the program halted in the debugger.

Due to the vagaries of network transmissions I think that attempting to do so will make your debugging much more difficult. Why not just capture the amf traffic to a file, then in your debug session load the capture file. This will allow you to debug the dissector in a much more controlled fashion as you know what packets should be there (by prior inspection of the raw packet data before dissection).

permanent link

answered 07 Nov '12, 00:25

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

But how to start a debug session???? I couldn't find debug console in Edit->Preferences

(07 Nov '12, 02:37) Akhil

Go to "Edit->Preference". In the option "Open a console window", change it from "Never" to "Always(debugging)" and click "Apply"

(07 Nov '12, 02:53) SidR

The console window allows "printf" style debugging. This may be all you require, but you can also use whatever other debuggers your Os supports, e.g. gdb for linux and other unicies, or WinDBg and Visual Studio for Windows.

(07 Nov '12, 03:20) grahamb ♦

I couldn't find the option "Open a console window" in Edit->Preferences. I am using wireshark 1.7.0 in Ubuntu 10.04

(07 Nov '12, 03:34) Akhil

Linux doesn't need this option, just launch Wireshark from a terminal window.

(07 Nov '12, 03:49) Jaap ♦

I am launching wireshark from terminal. How to start debug session??????????????

(07 Nov '12, 04:01) Akhil

As said earlier nothing will be shown there unless you add debug code to your plugin.

(07 Nov '12, 04:02) Anders ♦

how to add debug code???

(07 Nov '12, 04:10) Akhil
1

By typing? - seriosly - you need to have an idea of what you want to "debug" say a value of a variable before a switch statment or something like that. Try browsing the code of other dissectors to see how people have done things there ( grep -r DRBUG * )(grep -r g_warning *). If you say you want to do debuging that implies something is not working as expected so you need to find out why another wy is to try to find similar code and figure ut how that works.

(07 Nov '12, 05:00) Anders ♦

I need to set breakpoints in my plugin. How should I do it?

(07 Nov '12, 22:54) Akhil

You will need to run Wireshark in a debugger then. gdb is the usual debugger on your platform, but there are some wrinkles to running Wireshark under the debugger. If you have a look at the Developers Guide there is a section on debugging

(08 Nov '12, 00:20) grahamb ♦

I tried debygging using DDD.When i open my plugin .c file. the debugger prompts "File format not recognised"

(08 Nov '12, 00:48) Akhil

Akhil, this is the Wireshark Q&A site. If you have specific questions about a certain debugger (DDD), I recommend to visit a forum dedicated to that debugger or ask the question in stackoverflow.com (a Q&A site dedicated to programming).

Furthermore, the documentation of DDD contains a fairly good tutorial how to use DDD.

http://www.gnu.org/software/ddd/#Doc

BTW: Did you read the Dev Guide section about debugging and the way how to run ddd?

http://www.wireshark.org/docs/wsdg_html_chunked/ChSrcDebug.html#ChSrcUnixDebug

(08 Nov '12, 01:10) Kurt Knochner ♦

I have read the Dev Guide section about debugging....but could find how to set breakpoint?????

(08 Nov '12, 02:11) Akhil

see my comment in your other question.

http://wiki.wireshark.org/Development/Tips

(08 Nov '12, 02:15) Kurt Knochner ♦

I have added "g_printf()" statement in my code.....but where could i find it printed?????

Nothing is printed on the console

(08 Nov '12, 02:57) Akhil
1

I need to set breakpoints in my plugin. How should I do it?

Besides setting the Breakpoint manually in the debugger, you can use the macro G_BREAKPOINT() anywhere in your code. Code execution will stop as soon as that statement gets executed and the debugger will "jump" to the next line of code and wait for your commands. Tested with ddd on Ubuntu 12.04.

(08 Nov '12, 06:00) Kurt Knochner ♦

Thanks Kurt. I added G_BREAKPOINT() in my dissector and I could debug my dissector using gdb successfully

(08 Nov '12, 22:41) Akhil
showing 5 of 19 show 14 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×154
×80
×23

question asked: 06 Nov '12, 21:15

question was seen: 4,648 times

last updated: 09 Nov '12, 02:29

p​o​w​e​r​e​d by O​S​Q​A