All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: Markus Elfring <Markus.Elfring@web.de>, cocci@inria.fr
Subject: Re: [cocci] Searching for special function implementations with SmPL
Date: Tue, 31 Jan 2023 17:59:04 +0200	[thread overview]
Message-ID: <e0723c0018803fd18ffed163d620f901b385ffe2.camel@coelho.fi> (raw)
In-Reply-To: <48a02a321c06093966bc9999f9e8333f391475d7.camel@coelho.fi>

[-- Attachment #1: Type: text/plain, Size: 1785 bytes --]

On Tue, 2023-01-31 at 17:57 +0200, Luca Coelho wrote:
> On Mon, 2023-01-30 at 12:59 +0200, Luca Coelho wrote:
> > On Mon, 2023-01-30 at 11:47 +0100, Julia Lawall wrote:
> > > It doesn't find the file with the definition.  You may need to give more
> > > paths.
> > > 
> > > I have the impression that the result is improved with
> > > 
> > > -I drivers/gpu/drm/i915
> > > 
> > > Maybe -I drivers/gpu/drm/i915/display is necessary also.  If you add the
> > > argument --relax-include-path then just -I drivers/gpu/drm/i915 may be
> > > sufficient.  With that option, it will just hunt around in and under the
> > > various include paths for a unique file that has the required name.
> > 
> > Alright! That _does_ improve things! Now I can see lots of DPLL matches
> > in that file!
> 
> These files I'm trying to parse are so complex that I keep bumping into
> other parsing errors.  Here's one of them:
> 
> parse error 
>  = File "./drivers/gpu/drm/i915/i915_drv.h", line 385, column 1, charpos = 9644
>   around = 'for',
>   whole content =       for ((id__) = 0; \
> badcount: 7
> bad: }
> bad: 
> bad: /* Simple iterator over all initialised engines */
> bad: #define for_each_engine(engine__, dev_priv__, id__) \
> BAD:!!!!!       for ((id__) = 0; \
> bad:         (id__) < I915_NUM_ENGINES; \
> bad:         (id__)++) \
> bad:            for_each_if ((engine__) = (dev_priv__)->engine[(id__)])
> ERROR-RECOV: found sync end of #define, line 395
> 
> 
> I believe the parser is getting confused by an iterator inside an
> iterator's definition... I already tried to add them both with the
> "iterator name" directive, but it didn't help...
> 
> Any idea what I can do about this?

Oh, and here's the full debugging output.

--
Luca.

[-- Attachment #2: output.txt --]
[-- Type: text/plain, Size: 11361 bytes --]

init_defs_builtins: /home/luca/public/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: /home/luca/dev_priv_i915.spatch
with isos from: /home/luca/public/coccinelle/standard.iso
-----------------------------------------------------------------------
@macros_noargs@
iterator name with_intel_display_power_if_enabled;
iterator name with_intel_display_power;
iterator name for_each_power_domain;
iterator name with_intel_pps_lock;
iterator name for_each_pipe;
iterator name for_each_intel_encoder;
//iterator name for_each_engine;
iterator name for_each_engine_masked;
iterator name for_each_if;


iterator name for_each_engine;
iterator name for_each_engine_masked;
iterator name for_each_uabi_engine;
iterator name for_each_uabi_class_engine;
iterator name __for_each_sgt_daddr;
iterator name for_each_sgt_page;
iterator name priolist_for_each_request;
iterator name priolist_for_each_request_consume;
iterator name for_each_waiter;
iterator name for_each_signaler;
iterator name for_each_until;
iterator name for_each_ggtt_vma;
iterator name for_each_memory_region;
iterator name for_each_fw_domain_masked;
iterator name for_each_fw_domain;


identifier m;
expression e =~ "dev_priv";
@@
#define m <+...e...+>

@nested_macros@
identifier macros_noargs.m;
identifier nm;
identifier list il;
@@
#define nm(il) <+...m...+>

@@
identifier nested_macros.nm;
identifier dev_priv, f;
expression list el;
@@
f(...) {
	...
	struct drm_i915_private *dev_priv = ...;

	<+...
	nm(
+	dev_priv,	
	el)
	...+>
}

@@
identifier nested_macros.nm;
identifier dev_priv, f;
expression list el;
@@
f(..., struct drm_i915_private *dev_priv, ...) {
	<+...
	nm(
+	dev_priv,
	el)
	...+>
}

-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
macros_noargs = 
-----------------------------------------------------------------------
binding in = []
binding relevant in = []
-----------------------------------------------------------------------
nested_macros = 
-----------------------------------------------------------------------
binding in = []
binding relevant in = []
-----------------------------------------------------------------------
rule starting on line 42 = 
-----------------------------------------------------------------------
binding in = []
binding relevant in = []
-----------------------------------------------------------------------
rule starting on line 58 = 
-----------------------------------------------------------------------
binding in = []
binding relevant in = []
-----------------------------------------------------------------------
Finished
-----------------------------------------------------------------------
HANDLING: ./drivers/gpu/drm/i915/display/intel_display_power.c
remapping: for_each_engine to an ident in macro name
remapping: for_each_engine_masked to an ident in macro name
remapping: for_each_uabi_engine to an ident in macro name
remapping: for_each_uabi_class_engine to an ident in macro name
ERROR-RECOV: found sync end of #define, line 388
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 388
parse error 
 = File "./drivers/gpu/drm/i915/i915_drv.h", line 385, column 1, charpos = 9644
  around = 'for',
  whole content = 	for ((id__) = 0; \
badcount: 7
bad: }
bad: 
bad: /* Simple iterator over all initialised engines */
bad: #define for_each_engine(engine__, dev_priv__, id__) \
BAD:!!!!! 	for ((id__) = 0; \
bad: 	     (id__) < I915_NUM_ENGINES; \
bad: 	     (id__)++) \
bad: 		for_each_if ((engine__) = (dev_priv__)->engine[(id__)])
ERROR-RECOV: found sync end of #define, line 395
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 395
parse error 
 = File "./drivers/gpu/drm/i915/i915_drv.h", line 392, column 1, charpos = 9895
  around = 'for',
  whole content = 	for ((tmp__) = (mask__) & (gt__)->info.engine_mask; \
badcount: 7
bad: 		for_each_if ((engine__) = (dev_priv__)->engine[(id__)])
bad: 
bad: /* Iterator over subset of engines selected by mask */
bad: #define for_each_engine_masked(engine__, gt__, mask__, tmp__) \
BAD:!!!!! 	for ((tmp__) = (mask__) & (gt__)->info.engine_mask; \
bad: 	     (tmp__) ? \
bad: 	     ((engine__) = (gt__)->engine[__mask_next_bit(tmp__)]), 1 : \
bad: 	     0;)
ERROR-RECOV: found sync end of #define, line 403
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 403
parse error 
 = File "./drivers/gpu/drm/i915/i915_drv.h", line 401, column 1, charpos = 10182
  around = 'for',
  whole content = 	for ((engine__) = rb_to_uabi_engine(rb_first(&(i915__)->uabi_engines));\
badcount: 5
bad: 	rb_entry_safe(rb, struct intel_engine_cs, uabi_node)
bad: 
bad: #define for_each_uabi_engine(engine__, i915__) \
BAD:!!!!! 	for ((engine__) = rb_to_uabi_engine(rb_first(&(i915__)->uabi_engines));\
bad: 	     (engine__); \
bad: 	     (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))
ERROR-RECOV: found sync end of #define, line 408
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 408
parse error 
 = File "./drivers/gpu/drm/i915/i915_drv.h", line 406, column 1, charpos = 10412
  around = 'for',
  whole content = 	for ((engine__) = intel_engine_lookup_user((i915__), (class__), 0); \
badcount: 5
bad: 	     (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))
bad: 
bad: #define for_each_uabi_class_engine(engine__, class__, i915__) \
BAD:!!!!! 	for ((engine__) = intel_engine_lookup_user((i915__), (class__), 0); \
bad: 	     (engine__) && (engine__)->uabi_class == (class__); \
bad: 	     (engine__) = rb_to_uabi_engine(rb_next(&(engine__)->uabi_node)))
ERROR-RECOV: found sync end of #define, line 662
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 662
parse error 
 = File "./drivers/gpu/drm/i915/i915_drv.h", line 662, column 40, charpos = 21985
  around = ')',
  whole content = 	 IS_GRAPHICS_STEP(__i915, since, until))
badcount: 4
bad: 	 IS_GRAPHICS_STEP(__i915, since, until))
bad: 
bad: #define IS_TGL_GRAPHICS_STEP(__i915, since, until) \
bad: 	(IS_TIGERLAKE(__i915) && !IS_TGL_UY(__i915)) && \
BAD:!!!!! 	 IS_GRAPHICS_STEP(__i915, since, until))
remapping: for_each_power_domain to an ident in macro name
remapping: with_intel_display_power to an ident in macro name
remapping: with_intel_display_power_if_enabled to an ident in macro name
ERROR-RECOV: found sync end of #define, line 162
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 162
parse error 
 = File "./drivers/gpu/drm/i915/display/intel_display_power.h", line 161, column 1, charpos = 3932
  around = 'for',
  whole content = 	for ((__domain) = 0; (__domain) < POWER_DOMAIN_NUM; (__domain)++)	\
badcount: 4
bad: };
bad: 
bad: #define for_each_power_domain(__domain, __mask)				\
BAD:!!!!! 	for ((__domain) = 0; (__domain) < POWER_DOMAIN_NUM; (__domain)++)	\
bad: 		for_each_if(test_bit((__domain), (__mask)->bits))
ERROR-RECOV: found sync end of #define, line 282
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 282
parse error 
 = File "./drivers/gpu/drm/i915/display/intel_display_power.h", line 281, column 1, charpos = 8725
  around = 'for',
  whole content = 	for ((wf) = intel_display_power_get((i915), (domain)); (wf); \
badcount: 4
bad: 			     u8 req_slices);
bad: 
bad: #define with_intel_display_power(i915, domain, wf) \
BAD:!!!!! 	for ((wf) = intel_display_power_get((i915), (domain)); (wf); \
bad: 	     intel_display_power_put_async((i915), (domain), (wf)), (wf) = 0)
ERROR-RECOV: found sync end of #define, line 286
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 286
parse error 
 = File "./drivers/gpu/drm/i915/display/intel_display_power.h", line 285, column 1, charpos = 8925
  around = 'for',
  whole content = 	for ((wf) = intel_display_power_get_if_enabled((i915), (domain)); (wf); \
badcount: 4
bad: 	     intel_display_power_put_async((i915), (domain), (wf)), (wf) = 0)
bad: 
bad: #define with_intel_display_power_if_enabled(i915, domain, wf) \
BAD:!!!!! 	for ((wf) = intel_display_power_get_if_enabled((i915), (domain)); (wf); \
bad: 	     intel_display_power_put_async((i915), (domain), (wf)), (wf) = 0)
ERROR-RECOV: found sync end of #define, line 20
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 20
parse error 
 = File "./drivers/gpu/drm/i915/display/intel_display_power_well.h", line 20, column 23, charpos = 588
  around = '',
  whole content = 	     (__power_well)++)
badcount: 6
bad: struct i915_power_well;
bad: 
bad: #define for_each_power_well(__dev_priv, __power_well)				\
bad: 	for ((__power_well) = (__dev_priv)->display.power.domains.power_wells;	\
bad: 	     (__power_well) - (__dev_priv)->display.power.domains.power_wells <	\
bad: 		(__dev_priv)->display.power.domains.power_well_count;		\
BAD:!!!!! 	     (__power_well)++)
ERROR-RECOV: found sync end of #define, line 26
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 26
parse error 
 = File "./drivers/gpu/drm/i915/display/intel_display_power_well.h", line 26, column 23, charpos = 903
  around = '',
  whole content = 	     (__power_well)--)
badcount: 6
bad: 	     (__power_well)++)
bad: 
bad: #define for_each_power_well_reverse(__dev_priv, __power_well)			\
bad: 	for ((__power_well) = (__dev_priv)->display.power.domains.power_wells +		\
bad: 			      (__dev_priv)->display.power.domains.power_well_count - 1;	\
bad: 	     (__power_well) - (__dev_priv)->display.power.domains.power_wells >= 0;	\
BAD:!!!!! 	     (__power_well)--)
ERROR-RECOV: found sync end of #define, line 28
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 28
parse error 
 = File "./drivers/gpu/drm/i915/display/intel_display_power.c", line 28, column 2, charpos = 730
  around = 'for_each_if',
  whole content = 		for_each_if(test_bit((__domain), (__power_well)->domains.bits))
badcount: 4
bad: #include "vlv_sideband.h"
bad: 
bad: #define for_each_power_domain_well(__dev_priv, __power_well, __domain)	\
bad: 	for_each_power_well(__dev_priv, __power_well)				\
BAD:!!!!! 		for_each_if(test_bit((__domain), (__power_well)->domains.bits))
ERROR-RECOV: found sync end of #define, line 32
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 32
parse error 
 = File "./drivers/gpu/drm/i915/display/intel_display_power.c", line 32, column 2, charpos = 944
  around = 'for_each_if',
  whole content = 		for_each_if(test_bit((__domain), (__power_well)->domains.bits))
badcount: 4
bad: 		for_each_if(test_bit((__domain), (__power_well)->domains.bits))
bad: 
bad: #define for_each_power_domain_well_reverse(__dev_priv, __power_well, __domain) \
bad: 	for_each_power_well_reverse(__dev_priv, __power_well)		        \
BAD:!!!!! 		for_each_if(test_bit((__domain), (__power_well)->domains.bits))
dependencies for rule macros_noargs satisfied:
dependencies for rule nested_macros satisfied:
dependencies for rule rule starting on line 42 satisfied:
     (ONCE) USING optional_qualifier builtin isomorphism
dependencies for rule rule starting on line 58 satisfied:
     (ONCE) USING optional_storage builtin isomorphism
Check duplication for 20 files

  reply	other threads:[~2023-01-31 15:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27 17:07 [cocci] Nested macros Luca Coelho
2023-01-27 18:34 ` [cocci] Checking selected macro calls with SmPL Markus Elfring
2023-01-27 20:52 ` [cocci] Nested macros Julia Lawall
2023-01-27 22:00   ` Luca Coelho
2023-01-28  9:19     ` Julia Lawall
2023-01-28  9:25       ` Luca Coelho
2023-01-28  9:46     ` [cocci] Searching for special function implementations with SmPL Markus Elfring
2023-01-28  9:49       ` Julia Lawall
2023-01-28 10:03         ` Luca Coelho
2023-01-28 13:33           ` Julia Lawall
2023-01-29 16:39             ` Luca Coelho
2023-01-29 17:28               ` Julia Lawall
2023-01-29 17:55                 ` Luca Coelho
2023-01-29 19:15                   ` Luca Coelho
2023-01-29 20:09                     ` Julia Lawall
2023-01-30  6:32                       ` Luca Coelho
2023-01-30  8:37                         ` Julia Lawall
2023-01-30  8:50                           ` Luca Coelho
2023-01-30  8:56                             ` Julia Lawall
2023-01-30  9:05                               ` Luca Coelho
2023-01-30  9:34                             ` Markus Elfring
2023-01-30  9:41                               ` Luca Coelho
2023-01-30  9:50                                 ` Markus Elfring
2023-01-30  9:52                                   ` Luca Coelho
2023-01-30  9:55                                     ` Julia Lawall
2023-01-30 10:07                                     ` Markus Elfring
2023-01-30 10:47                                     ` Julia Lawall
2023-01-30 10:59                                       ` Luca Coelho
2023-01-30 11:25                                         ` Markus Elfring
2023-01-31 15:57                                         ` Luca Coelho
2023-01-31 15:59                                           ` Luca Coelho [this message]
2023-01-31 16:08                                           ` Julia Lawall
2023-01-31 16:10                                             ` Luca Coelho
2023-01-31 16:20                                               ` Julia Lawall
2023-01-29 18:01               ` [cocci] Adding a parameter for special macro calls " Markus Elfring
2023-01-29 19:11                 ` Luca Coelho
2023-01-28 13:43           ` [cocci] Searching for special function implementations " Markus Elfring
2023-01-29 16:41             ` Luca Coelho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e0723c0018803fd18ffed163d620f901b385ffe2.camel@coelho.fi \
    --to=luca@coelho.fi \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=julia.lawall@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.