Wireshark-dev: Re: [Wireshark-dev] Question regarding emem -> wmem conversion

From: Dario Lombardo <dario.lombardo.ml@xxxxxxxxx>
Date: Fri, 13 Sep 2013 11:22:42 +0200
I'm testing a way to speed up the process, for trivial cases. This is the script I'm using. 

#!/bin/bash

for file in `../../tools/checkAPIs.pl -g emem packet-*.c  2>&1 | egrep "ep_alloc$" | awk ' { print $6 } ' | sed 's/://g'`
do
    echo "patching $file"
    sed -i 's/#include <epan\/emem.h>/#include <epan\/wmem\/wmem.h>/g' $file
    sed -i 's/ep_alloc(/wmem_alloc(wmem_packet_scope(), /g' $file
done

I can open a bug with the output of this script, so we can share the result.


On Thu, Sep 12, 2013 at 11:46 PM, Joerg Mayer <jmayer@xxxxxxxxx> wrote:
Hello Kauschik,

On Fri, Sep 13, 2013 at 02:53:50AM +0530, kaushik varanasi wrote:
> Can any of you brief me about what should be done. I would like to get
> involved and learn.

Here is what I do (now) - I'm on Linux:
- cd epan/dissectors/
- Pick a letter from the alphabet.
- grep emem.h packet-<letter>*.c
- ../../tools/checkAPI.pl -g emem packet-<letter>*.c
- Fix inconsistencies (remove includes for emem.h from files that don't
  use ep_ or se_ functions, add the include where it is missing
- Go through all files that only contain "simple to convert" functions
  + Replace the include statement and se_ and ep_ functions the way Evan
    described, then compile and install libwireshark (I do:
    "make -C epan install)
  + run "tshark -v" to find obvious breakages. If it breaks, "svn revert"
    the file
  + Next file
- Commit my changes

Maybe you can do this and once you have successfully converted the fist
file open a bug and attach your patch to it. Depending on the feedback
go over the patch again or (once sufficiently confident) finish all
dissectors for that letter and attach the patch to the previous bug again.

 Ciao
       Jörg

> > Unfortunately emem.h is included everywhere via packet.h via
> > packet_info.h via address.h, so there are dissectors that use it
> > without including it directly. check-APIs is more reliable since it
> > actually looks for the function calls.
> >
> > >
> > > > P.S. I have a few vim macros that I wrote to speed up the process. I
> > can
> > > > share them if anybody using vim wants to help :)
> > >
> > > Sure, go ahead please.
> >
> > Put the following in your vimrc:
> > let @e = 'xxiwmem^[/(^Mawmem_packet_scope(), ^[/\<ep_^Mkj'
> > let @s = 'xxiwmem^[/(^Mawmem_file_scope(), ^[/\<se_^Mkj'
> >
> > Then the 'e' macro will convert an ep_* call and jump to the next one,
> > the 's' macro will convert an se_* call and jump to the next one.
> > These only work for functions like _alloc and _strdup, for
> > data-structures (like ep_strbuf_append) which take the data-structure
> > and not the scope as the first argument you will have to convert
> > manually still, but there are not many of those.
> >
> > On Thu, Sep 12, 2013 at 11:54 AM, Dario Lombardo
> > <dario.lombardo.ml@xxxxxxxxx> wrote:
> > >
> > > On Thu, Sep 12, 2013 at 5:36 PM, Joerg Mayer <jmayer@xxxxxxxxx> wrote:
> > >>
> > >> So if we could split this between a few people at least the trivial part
> > >> could be done quickly.
> > >
> > >
> > > Can you please show us what should be done? I could get a part of it if
> > it's clear what to do.
> >
> > The doc/README.wmem section 2.1.1 includes a brief example of how
> > calls can be replaced. You can also take a look at some of my (and
> > Joerg's) previous commits doing conversion.

--
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe