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

Wireshark Building and debugging on visual c++ or Visual studio

0

Hi all,

I am having the free version of Visual c++ 2008 for running the build of wireshark. But debugging and development through command prompt seems to be difficult task. Is there anyway I can do the development in visual c++/Studio. Plz guide me through the steps.

asked 28 Jan '12, 01:26

ashish_goel's gravatar image

ashish_goel
15121216
accept rate: 0%

Hey guys.. hasn't anybody buid wireshark on visual studio??

(28 Jan '12, 07:29) ashish_goel

(Answer converted to a comment in keeping with the way ask.wireshark.org works; Please see the FAQ).

(28 Jan '12, 07:48) Bill Meier ♦♦

One Answer:

2

The short answer: Wireshark on Windows is built using nmake as described in the Developer's Guide.

AFAIKT there is no .proj file, etc which can be used to do all the development in directly in Visual Studio.

That being said, it's quite easy to use Visual Studio for debugging once Wireshark has been built using nmake.

What is it that you find is a "difficult task" when "debugging and developing through the command prompt" ?

===

OK: To use Visual Studio for debugging Wireshark:

From: wireshark-shows-error-message-box-while-debugging-in-vs-2008

"To create the project/Solution. in VS, do File ! Open ! Project/Solution of the executable in the wireshark-gtk2 directory (rather than using the executable in the top-level directory)."

Once you've done the above you can use all the normal VS functionality to open source files, to do source level debugging actions such as setting breakpoints, starting and stepping through the program and so on...

======

Using the "View references for a symbol" function in Visual Studio (Updated: June 13,2012)

The Microsoft Visual Studio documentation indicates that you need to build a "Browse Information File" (for Wireshark: as described below)

Using .bsc Files to Enable Browsing To References of C++ Symbols

However: Based upon chatter on the web (and my own failed attempts), using a "Browse Information File" with Visual Studio 2010 doesn't work (isn't supported ?)

The function may work when using Visual Studio 2008 (I haven't actually tried it).

See (for example): using a .bsc (source browser) file with Visual Studio 2010

Creating a .bsc file when building Wireshark:

  1. Before doing the normal command-line procedure to build Wireshark, do

    $set WIRESHARK_GENERATE_BSC_FILE=1

    Defining this environment variable will cause the Wireshark make process to build the intermediate .sbr files and then create the desired .bsc file (Browse Information File)

  2. Rebuild Wireshark (doing a 'clean' first)

    The created (combined) .bsc file will be located in the wireshark-gt2 directory along with the Wireshark.exe and etc.

answered 28 Jan '12, 07:52

Bill%20Meier's gravatar image

Bill Meier ♦♦
3.2k1850
accept rate: 17%

edited 13 Jun '12, 08:58

how to set breakpoints at specific position in a file. and then how to proceed step by step watching the code using command prompt

(28 Jan '12, 08:13) ashish_goel

(ask.wireshark.org is not a forum. Please see the FAQ about proper use of this site. IOW: answers should be used only to answer the original question ...)

(28 Jan '12, 08:30) Bill Meier ♦♦

sry.. didn't noticed. I tried using what you suggested. But the files doesn't load into the solution explorer. I have to manually open the file to set up a break point. And neither do I can search for references (Go to definition/declaration of any variable). Do u have any idea??

(28 Jan '12, 08:46) ashish_goel

But the files doesn't load into the solution explorer. I have to manually open the file to set up a break point.

True ...

And neither do I can search for references (Go to definition/declaration of any variable

I've updated the answer as to how you might be able to get this working ...

(28 Jan '12, 09:44) Bill Meier ♦♦

Hi.. I am getting the following error while trying to build the .bsc file.

" NMAKE : fatal error U1073: don't know how to make '*.sbr' stop. "

(28 Jan '12, 09:55) ashish_goel

now running fine.. thanx :)

Only rebuilding was giving the error. I distclean the solution and build it again then it worked. once again Thanx for your help bill :).

But why is it that rebuilding doesn't work many times and we have to clean the solution and build it again ??

(28 Jan '12, 10:27) ashish_goel

" NMAKE : fatal error U1073: don't know how to make '*.sbr' stop. "

Yep: maybe no-one has ever used this target ? :)

See my edit of step 3.

(28 Jan '12, 10:42) Bill Meier ♦♦

Actually: I'm wrong: step 3 does work (as long as there are .sbr files in each referenced dir).

IOW: the error message is because nmake couldn't find any .sbr dfiles in the dir. After adding the /FR did you do a clean followed by a build ?

(I'll update step 3 to indicate that nmake .... should work just fine).

(28 Jan '12, 10:52) Bill Meier ♦♦

But why is it that rebuilding doesn't work many times and we have to clean the solution and build it again ??

The Wireshark Makefile.nmake doesn't do that well at handling dependencies. E.g., Makefile.nmake doesn't know about most .h file dependencies so changing a most .h files doesn't cause required re-compiles.

I think this is also true when config.nmake is changed.

(We now can use CMake to build on Windows. I wonder if CMake has the ability to determine dependencies ?).

(P.s. Fell free to "accept" this answer).

(28 Jan '12, 11:08) Bill Meier ♦♦

@bill yeah.. and Thanks for your replies.

I am in learning phase of Wireshark development. hope to get more replies from you in future ;)

(28 Jan '12, 11:51) ashish_goel

Did you add /FR to LOCAL_CFLAGS in config.nmake and made clean and rebuilt? revision 40765 should make this easier.

(29 Jan '12, 14:03) Anders ♦

I built Wireshark with /FR and etc and then opened Wireshark.exe (& the associated .bsc file) in VC2008 (VC9).

I found that I could only see public global symbols (e.g., I could not see static functions or static global variables);

Poking around the web a bit, I get the impression that "source browsing" as it existed in VC6 doesn't really exist in the newer compilers.

Question: After "it worked. once again" for you were you able to see local symbols in the browser ?

(30 Jan '12, 15:25) Bill Meier ♦♦

It is not working properly. Sometimes going for the definition of a local variable it loads some other same name variable of other files :(

(Converting to a comment in keeping with the style of ask.wireshark.org. Please see the FAQO.

(01 Feb '12, 09:53) ashish_goel

I've noticed in the past that the VS debugger has problems at times with (ISTR) [static global] structs of the same name in different source files.

(I don't remember seeing the issue with local variables).

(I ended up changing the names to be unique so I could debug.

I'd be interested as to specific instances you are encountering.

(01 Feb '12, 10:24) Bill Meier ♦♦

Also: Googling "site:wireshark.org text2pcap user encap dlt" finds some relevant links...

(01 Feb '12, 10:51) Bill Meier ♦♦
showing 5 of 15 show 10 more comments