juvf 22 January 25, 2022 Posted January 25, 2022 · Report post Есть патченое ядро Linux 4 в исходниках. Компилируется, собирается и работает. в нем есть правки в драйвере /driver/media/bla/bla/bla/mxc.c там используется структура struct timeval cur_time; Структура timeval объявлена в /include/MecTo/rge/HeT/cBeTa/time.h Вопрос: как компилятор из mxc.c достукивается до time.h? Вернее.... я хочу понять, как компилятор включает time.h в mxc.c? через какой путь? Вот какие хидеры в mxc.c #include <linux/version.h> #include <linux/module.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/fs.h> #include <linux/slab.h> #include <linux/ctype.h> #include <linux/clk.h> #include <linux/io.h> #include <linux/semaphore.h> #include <linux/pagemap.h> #include <linux/vmalloc.h> #include <linux/types.h> #include <linux/fb.h> #include <linux/dma-mapping.h> #include <linux/delay.h> #include <linux/mxcfb.h> #include <linux/of_device.h> #include <media/v4l2-chip-ident.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-device.h> #include "v4l2-int-device.h" #include <linux/fsl_devices.h> #include "mxc_v4l2_capture.h" #include "ipu_prp_sw.h" тут "time.h" - нету. Хорошо... заглядываю в <linux/version.h>, там инклудится #include <linux/list.h> #include <linux/stat.h> #include <linux/compiler.h> #include <linux/cache.h> #include <linux/kmod.h> #include <linux/elf.h> #include <linux/stringify.h> #include <linux/kobject.h> #include <linux/moduleparam.h> #include <linux/jump_label.h> #include <linux/export.h> Заглядываю в <linux/list.h>.... потом в <linux/stat.h>.... и пошло поехало... через какие терни time.h инклудится в mxc.c? Есть какие нибудь автоматизированные средства разбора включений? Quote Share this post Link to post Share on other sites More sharing options...
Arlleex 281 January 25, 2022 Posted January 25, 2022 · Report post Попробуйте включить вывод препроцессированных файлов (насколько помню, какая-то опция -E, что ли) для mxc.c, и посмотрите на его листинг - так будет проще понять. Quote Share this post Link to post Share on other sites More sharing options...
dxp 112 January 26, 2022 Posted January 26, 2022 · Report post А если поиск по файлам зарядить на '#include+s+.+time.h' (например, grep'ом)? Quote Share this post Link to post Share on other sites More sharing options...
juvf 22 January 26, 2022 Posted January 26, 2022 · Report post 2 часа назад, dxp сказал: А если поиск по файлам зарядить на '#include+s+.+time.h' (например, grep'ом)? искать текст "time.h" в фалах "*.h" - найдено 169 файлов". 17 часов назад, Arlleex сказал: Попробуйте включить вывод препроцессированных файлов... не совсем понял как это сделать..... с мэйком на "вы". Есть мэйкфал с такой строкой obj-$(CONFIG_MXC) += mxc.o как сюда прикрутить -Е? Quote Share this post Link to post Share on other sites More sharing options...
dxp 112 January 26, 2022 Posted January 26, 2022 · Report post 1 час назад, juvf сказал: искать текст "time.h" в фалах "*.h" - найдено 169 файлов". /usr/include/linux$ grep -E -r -e "\#include\s+.*time\.h" * coda.h:#include <sys/time.h> coda.h:#include <linux/time.h> dvb/dmx.h:#include <time.h> dvb/video.h:#include <time.h> elfcore.h:#include <linux/time.h> input.h:#include <sys/time.h> resource.h:#include <linux/time.h> timex.h:#include <linux/time.h> videodev2.h:#include <sys/time.h> Quote Share this post Link to post Share on other sites More sharing options...
juvf 22 January 26, 2022 Posted January 26, 2022 · Report post а что дальше? dvb/dmx.h:#include <time.h>, dmx.h может быть включен в asd.h, asd.h включен в dsa.h, ..., ..., ..., ........................... и вот тут device.h включен в mxc.c Как понять по какому именно пути time.h включен в mxc.c? Quote Share this post Link to post Share on other sites More sharing options...
Arlleex 281 January 26, 2022 Posted January 26, 2022 · Report post С GCC я знаком мало, к сожалению. Хотел всего лишь направить в сторону получения полных исходных файлов (с раскрытыми директивами препроцессора), и по ним определить, где был первым подключен нужный заголовочник. Quote Share this post Link to post Share on other sites More sharing options...
Artem_Petrik 0 January 26, 2022 Posted January 26, 2022 (edited) · Report post почитайте тут: http://citforum.ru/operating_systems/gnumake/gnumake_02.shtml раздел Quote 1.4. Автоматическое построение зависимостей от заголовочных файлов. Я так понимаю, это ответит на вопрос. P.S. Хотя, похоже это не очень удобное решение вопроса. Хоть положение искомого файла в списке зависимостей и определяется путем включения, восстановить этот путь не так просто... P.P.S посмотрел содержимое файлов *.d - норм, определить путь не сложно) Edited January 26, 2022 by Artem_Petrik Quote Share this post Link to post Share on other sites More sharing options...
ruslan21083i 0 June 21, 2022 Posted June 21, 2022 (edited) · Report post Каким образом gcc будет искать заголовочные файлы зависит от того с какими флагами запущена компиляция для конкретного mxc.c файла. Это можно выяснить так: запустить компиляцию так: make SHELL='/bin/sh -x' на выходе будет то какие команды исполняет make найти в этом выводе то что касается файла mxc.c, что-то типа: gcc -O2 -o mxc.o mxc.c скопировать эту строку добавить флаг -v (verbose) и исполнить: gcc -v -O2 -o mxc.o mxc.c В выводе будет: #include "..." search starts here: #include <...> search starts here: ./arch/arm/include ./arch/arm/include/generated ./include ./arch/arm/include/uapi ./arch/arm/include/generated/uapi Edited June 21, 2022 by ruslan21083i Quote Share this post Link to post Share on other sites More sharing options...
Eddy_Em 2 June 21, 2022 Posted June 21, 2022 · Report post Если добавить опцию -MD к CGLAGS, то для каждого файла будет сгенерирован dependency-файл, в котором и будут перечисленны все-все файлы из дерева include'ов, от которых данный объектник зависит. Зачастую многие заголовочные файлы никто напрямую и не включает: они включаются из каких-либо других. Скажем, вы не включаете же bits/types.h напрямую, а пишете [inline]#include <stdint.h>[/inline]. Quote Share this post Link to post Share on other sites More sharing options...
Dvorkin 1 December 9, 2022 Posted December 9, 2022 (edited) · Report post На сайте https://elixir.bootlin.com/linux/v4.14/source выбираете версию ядра и ищете timeval (в поле поиска Search Identifier). Или открываете файл mxc.c и, кликнув по #include "time.h", медитируете до просветления. Edited December 9, 2022 by Dvorkin Quote Share this post Link to post Share on other sites More sharing options...