Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Clang build with ASAN

From: Bill Meier <wmeier@xxxxxxxxxxx>
Date: Fri, 06 Sep 2013 14:35:44 -0400
On 8/13/2013 9:43 AM, Evan Huus wrote:
On Mon, Aug 12, 2013 at 11:17 AM, Alexis La Goutte
<alexis.lagoutte@xxxxxxxxx <mailto:alexis.lagoutte@xxxxxxxxx>> wrote:

    Hi,

    it is now possible to build wireshark with clang (CC=clang
    ./configure && make) (i fix last issue last week end).


    I will try the ASAN feature (
    http://clang.llvm.org/docs/AddressSanitizer.html )


I wonder if it is possible to also run include-what-you-use now?
https://code.google.com/p/include-what-you-use/


I've done a little trial of include-what-you-use (iwyu).

IMO, the output is a bit useful but most of theoutput is not .

It appears, for example, that iwyu seems wants to, in effect, "expand" .h file includes (e.g., packet.h) and then just include the actual .h files needed.

This (obviously) can be valid (and might reduce compile time) but I certainly don't think going through and substituting individual #includes for packet.h as suggested by iwyu is something that should be done.

One possible action might be to look at the "remove these lines" suggestions; individual inspection would probably be required to determine if an #include can be removed w/o having to add a "sub-include".

Bottom line (IMO):

1. Blindly applying all the suggestions is a non-starter.

2. Manually applying certain suggested items seems like a lot of work
   for not much result.

So, I thoink there's other stuff with much higher priority.

Bill

==============

[[ iwyu output for packet-netsync.c and packet-tcp.c ]]

packet-netsync.c should add these lines:
#include <stddef.h>                     // for NULL
#include "./column-utils.h"             // for col_set_str
#include "./ftypes/ftypes.h"            // for ftenum::FT_BYTES, etc
#include "./proto.h" // for proto_tree_add_item, HFILL, etc
#include "./tvbuff.h"                   // for tvbuff_t, tvb_get_guint8, etc
#include "./value_string.h"             // for val_to_str, value_string
#include "epan/column_info.h"           // for ::COL_PROTOCOL
#include "epan/packet_info.h"           // for packet_info
#include "glib/gmacros.h"               // for TRUE, FALSE
#include "glib/gtypes.h"                // for gint, guint, gboolean
#include "glibconfig.h"                 // for guint8, guint32

packet-netsync.c should remove these lines:
- #include <epan/addr_resolv.h> // lines 34-34 [[[ OK: included in prefs.h ]]]
- #include <epan/strutil.h>  // lines 36-36  [[[ OK: Not needed ]]]
- #include <glib.h>  // lines 31-31

The full include-list for packet-netsync.c:
#include <epan/packet.h>                // for array_length, etc
#include <epan/prefs.h>
#include <stddef.h>                     // for NULL
#include "./column-utils.h"             // for col_set_str
#include "./ftypes/ftypes.h"            // for ftenum::FT_BYTES, etc
#include "./proto.h" // for proto_tree_add_item, HFILL, etc
#include "./tvbuff.h"                   // for tvbuff_t, tvb_get_guint8, etc
#include "./value_string.h"             // for val_to_str, value_string
#include "config.h"                     // for _U_
#include "epan/column_info.h"           // for ::COL_PROTOCOL
#include "epan/packet_info.h"           // for packet_info
#include "glib/gmacros.h"               // for TRUE, FALSE
#include "glib/gtypes.h"                // for gint, guint, gboolean
#include "glibconfig.h"                 // for guint8, guint32
#include "packet-tcp.h"                 // for tcp_dissect_pdus
---

====================

  CC       libdissectors_la-packet-tcp.lo

packet-tcp.h should add these lines:
#include "./address.h"                  // for address
#include "./proto.h"                    // for proto_tree
#include "./tvbuff.h"                   // for tvbuff_t
#include "epan/conversation.h"          // for __CONVERSATION_H__, etc
#include "epan/packet.h"                // for dissector_t
#include "epan/packet_info.h"           // for packet_info
#include "epan/wmem/wmem_tree.h"        // for wmem_tree_t
#include "glib/gtypes.h"                // for gboolean, gchar, guint
#include "glibconfig.h"                 // for guint32, guint16, gint32, etc
#include "wsutil/nstime.h"              // for nstime_t

packet-tcp.h should remove these lines:
- #include <epan/wmem/wmem.h>  // lines 37-37

The full include-list for packet-tcp.h:
#include "./address.h"                  // for address
#include "./proto.h"                    // for proto_tree
#include "./tvbuff.h"                   // for tvbuff_t
#include "epan/conversation.h"          // for __CONVERSATION_H__, etc
#include "epan/packet.h"                // for dissector_t
#include "epan/packet_info.h"           // for packet_info
#include "epan/wmem/wmem_tree.h"        // for wmem_tree_t
#include "glib/gtypes.h"                // for gboolean, gchar, guint
#include "glibconfig.h"                 // for guint32, guint16, gint32, etc
#include "ws_symbol_export.h"           // for WS_DLL_PUBLIC
#include "wsutil/nstime.h"              // for nstime_t
---

packet-tcp.c should add these lines:
#include "./column-utils.h"             // for col_prepend_fence_fstr, etc
#include "./exceptions.h"               // for ENDTRY, TRY, CATCH_ALL, etc
#include "./frame_data.h"               // for frame_data, etc
#include "./ftypes/ftypes.h"            // for ftenum::FT_BOOLEAN, etc
#include "./tfs.h"                      // for tfs_set_notset, etc
#include "./to_str.h"                   // for ip_to_str
#include "./value_string.h"             // for val_to_str_ext_const, etc
#include "epan/column_info.h"           // for ::COL_INFO, ::COL_PROTOCOL
#include "epan/params.h"                // for enum_val_t
#include "epan/wmem/wmem_core.h"        // for wmem_new, wmem_free, etc
#include "epan/wmem/wmem_scopes.h"      // for wmem_file_scope, etc
#include "epan/wmem/wmem_strbuf.h" // for wmem_strbuf_append_printf, etc
#include "epan/wmem/wmem_strutl.h"      // for wmem_strdup
#include "glib/gmacros.h"               // for TRUE, FALSE, MIN
#include "glib/gstring.h"               // for GString

packet-tcp.c should remove these lines:
- #include <epan/wmem/wmem.h>  // lines 39-39
- #include <glib.h>  // lines 29-29

The full include-list for packet-tcp.c:
#include "packet-tcp.h"
#include <epan/addr_resolv.h>           // for get_tcp_port
#include <epan/conversation.h>          // for conversation_t, etc
#include <epan/expert.h>                // for expert_add_info, EI_INIT, etc
#include <epan/follow.h>                // for reassemble_tcp
#include <epan/in_cksum.h>              // for vec_t, in_cksum, etc
#include <epan/ip_opts.h>               // for ip_tcp_opt, etc
#include <epan/ipproto.h>               // for IP_PROTO_TCP
#include <epan/packet.h>                // for dissector_try_uint, etc
#include <epan/prefs.h>
#include <epan/reassemble.h> // for fragment_head, fragment_add, etc
#include <epan/show_exception.h>        // for show_exception, etc
#include <epan/tap.h>                   // for register_tap, etc
#include <stdio.h>                      // for NULL, FILE
#include <string.h>                     // for strstr
#include "./column-utils.h"             // for col_prepend_fence_fstr, etc
#include "./exceptions.h"               // for ENDTRY, TRY, CATCH_ALL, etc
#include "./frame_data.h"               // for frame_data, etc
#include "./ftypes/ftypes.h"            // for ftenum::FT_BOOLEAN, etc
#include "./tfs.h"                      // for tfs_set_notset, etc
#include "./to_str.h"                   // for ip_to_str
#include "./value_string.h"             // for val_to_str_ext_const, etc
#include "config.h"                     // for _U_
#include "epan/column_info.h"           // for ::COL_INFO, ::COL_PROTOCOL
#include "epan/params.h"                // for enum_val_t
#include "epan/wmem/wmem_core.h"        // for wmem_new, wmem_free, etc
#include "epan/wmem/wmem_scopes.h"      // for wmem_file_scope, etc
#include "epan/wmem/wmem_strbuf.h" // for wmem_strbuf_append_printf, etc
#include "epan/wmem/wmem_strutl.h"      // for wmem_strdup
#include "glib/gmacros.h"               // for TRUE, FALSE, MIN
#include "glib/gstring.h"               // for GString
---