Skip to content

Commit

Permalink
clang-format: Sort #include orders automatically
Browse files Browse the repository at this point in the history
We can sort include orders using .clang-format and automatically
check the include orders using pre-commit.

By doing this, uftrace can prevent potential warnings and errors,
and maintain codes in more neat condition.

Signed-off-by: Kang Minchul <[email protected]>
  • Loading branch information
kangtegong authored and namhyung committed Jul 30, 2022
1 parent 0733293 commit fb495a8
Show file tree
Hide file tree
Showing 103 changed files with 386 additions and 386 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ PenaltyReturnTypeOnItsOwnLine: 60

PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SortIncludes: true
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
Expand Down
10 changes: 5 additions & 5 deletions arch/aarch64/mcount-dynamic.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include <string.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>

/* This should be defined before #include "utils.h" */
#define PR_FMT "dynamic"
#define PR_DOMAIN DBG_DYNAMIC

#include "libmcount/mcount.h"
#include "libmcount/internal.h"
#include "libmcount/dynamic.h"
#include "libmcount/internal.h"
#include "libmcount/mcount.h"
#include "mcount-arch.h"
#include "utils/utils.h"
#include "utils/symbol.h"
#include "utils/rbtree.h"
#include "utils/symbol.h"
#include "utils/utils.h"

#define CODE_SIZE 8

Expand Down
2 changes: 1 addition & 1 deletion arch/aarch64/mcount-insn.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "libmcount/internal.h"
#include "libmcount/dynamic.h"
#include "libmcount/internal.h"
#include "mcount-arch.h"

#define INSN_SIZE 8
Expand Down
2 changes: 1 addition & 1 deletion arch/aarch64/mcount-support.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdlib.h>

#include "libmcount/internal.h"
#include "utils/utils.h"
#include "utils/filter.h"
#include "utils/utils.h"

/* FIXME: x0 is overwritten before calling _mcount() */
static int mcount_get_register_arg(struct mcount_arg_context *ctx, struct uftrace_arg_spec *spec)
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/mcount-support.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdlib.h>
#include <link.h>
#include <elf.h>
#include <link.h>
#include <stdlib.h>

#ifndef EF_ARM_VFP_FLOAT
#define EF_ARM_VFP_FLOAT 0x400
Expand All @@ -11,10 +11,10 @@
#endif

#include "libmcount/internal.h"
#include "utils/utils.h"
#include "utils/symbol.h"
#include "utils/rbtree.h"
#include "utils/filter.h"
#include "utils/rbtree.h"
#include "utils/symbol.h"
#include "utils/utils.h"

struct lr_offset {
int offset; // 4-byte unit
Expand Down
4 changes: 2 additions & 2 deletions arch/i386/mcount-dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#define PR_FMT "dynamic"
#define PR_DOMAIN DBG_DYNAMIC

#include "libmcount/internal.h"
#include "libmcount/dynamic.h"
#include "utils/utils.h"
#include "libmcount/internal.h"
#include "utils/symbol.h"
#include "utils/utils.h"

static const unsigned char fentry_nop_patt[] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };

Expand Down
6 changes: 3 additions & 3 deletions arch/x86_64/mcount-dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#define PR_FMT "dynamic"
#define PR_DOMAIN DBG_DYNAMIC

#include "mcount-arch.h"
#include "libmcount/internal.h"
#include "libmcount/dynamic.h"
#include "utils/utils.h"
#include "libmcount/internal.h"
#include "mcount-arch.h"
#include "utils/symbol.h"
#include "utils/utils.h"

static const unsigned char fentry_nop_patt1[] = { 0x67, 0x0f, 0x1f, 0x04, 0x00 };
static const unsigned char fentry_nop_patt2[] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/mcount-event.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <signal.h>
#include <stdbool.h>
#include <ucontext.h>
#include <sys/mman.h>
#include <ucontext.h>

/* This should be defined before #include "utils.h" */
#define PR_FMT "event"
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/mcount-insn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define PR_FMT "dynamic"
#define PR_DOMAIN DBG_DYNAMIC

#include "libmcount/internal.h"
#include "libmcount/dynamic.h"
#include "libmcount/internal.h"
#include "mcount-arch.h"
#include "utils/utils.h"

Expand Down
6 changes: 3 additions & 3 deletions arch/x86_64/mcount-noplt.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#define PR_FMT "mcount"
#define PR_DOMAIN DBG_MCOUNT

#include "uftrace.h"
#include "libmcount/mcount.h"
#include "libmcount/internal.h"
#include "utils/utils.h"
#include "libmcount/mcount.h"
#include "uftrace.h"
#include "utils/symbol.h"
#include "utils/utils.h"

#define TRAMP_ENT_SIZE 16 /* size of trampoilne for each entry */
#define TRAMP_PLT0_SIZE 32 /* module id + address of plthook_addr() */
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/mcount-support.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define PR_DOMAIN DBG_MCOUNT

#include "libmcount/internal.h"
#include "utils/filter.h"
#include "utils/arch.h"
#include "utils/filter.h"

#define COPY_XMM(xmm) \
do { \
Expand Down
10 changes: 5 additions & 5 deletions arch/x86_64/symbol.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>

/* This should be defined before #include "utils.h" */
#define PR_FMT "symbol"
#define PR_DOMAIN DBG_SYMBOL

#include "uftrace.h"
#include "utils/utils.h"
#include "utils/symbol.h"
#include "libmcount/internal.h"
#include "mcount-arch.h"
#include "uftrace.h"
#include "utils/symbol.h"
#include "utils/utils.h"

#define R_OFFSET_POS 2
#define JMP_INSN_SIZE 6
Expand Down
6 changes: 3 additions & 3 deletions check-deps/__have_libcapstone.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <capstone/capstone.h>
#include <capstone/platform.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <capstone/platform.h>
#include <capstone/capstone.h>

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion check-deps/__have_libelf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <libelf.h>
#include <gelf.h>
#include <libelf.h>

int main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion check-deps/__have_libluajit.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

int main(void)
{
Expand Down
4 changes: 2 additions & 2 deletions check-deps/__perf_clockid.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define _GNU_SOURCE
#include <linux/perf_event.h>
#include <sys/syscall.h>
#include <time.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/perf_event.h>

int main(void)
{
Expand Down
4 changes: 2 additions & 2 deletions check-deps/__perf_context_switch.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/perf_event.h>
#include <sys/syscall.h>
#include <unistd.h>

int main(void)
{
Expand Down
22 changes: 11 additions & 11 deletions cmds/dump.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#include <time.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/stat.h>
#include <time.h>

#include "libtraceevent/event-parse.h"
#include "libtraceevent/kbuffer.h"
#include "uftrace.h"
#include "version.h"
#include "utils/list.h"
#include "utils/utils.h"
#include "utils/event.h"
#include "utils/fstack.h"
#include "utils/filter.h"
#include "utils/kernel.h"
#include "utils/fstack.h"
#include "utils/graph.h"
#include "libtraceevent/kbuffer.h"
#include "libtraceevent/event-parse.h"
#include "utils/kernel.h"
#include "utils/list.h"
#include "utils/utils.h"
#include "version.h"

/* target sampling frequency for flame graph */
#define FLAME_GRAPH_SAMPLE_FREQ 1000000
Expand Down
12 changes: 6 additions & 6 deletions cmds/graph.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>

#include "uftrace.h"
#include "utils/utils.h"
#include "utils/symbol.h"
#include "utils/field.h"
#include "utils/filter.h"
#include "utils/fstack.h"
#include "utils/field.h"
#include "utils/graph.h"
#include "utils/symbol.h"
#include "utils/utils.h"

static LIST_HEAD(output_fields);
static LIST_HEAD(output_task_fields);
Expand Down
18 changes: 9 additions & 9 deletions cmds/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
* Released under the GPL v2.
*/

#include <stdio.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <time.h>
#include <unistd.h>

#include "uftrace.h"
#include "libmcount/mcount.h"
#include "utils/utils.h"
#include "uftrace.h"
#include "utils/filter.h"
#include "utils/symbol.h"
#include "utils/fstack.h"
#include "utils/symbol.h"
#include "utils/utils.h"
#include "version.h"

struct read_handler_arg {
Expand Down
10 changes: 5 additions & 5 deletions cmds/live.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <signal.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>

#include "libmcount/mcount.h"
#include "uftrace.h"
#include "utils/utils.h"
#include "utils/fstack.h"
#include "utils/kernel.h"
#include "libmcount/mcount.h"
#include "utils/utils.h"

static char *tmp_dirname;
static void cleanup_tempdir(void)
Expand Down
32 changes: 16 additions & 16 deletions cmds/record.c
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <glob.h>
#include <inttypes.h>
#include <poll.h>
#include <dirent.h>
#include <pthread.h>
#include <signal.h>
#include <glob.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/personality.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/eventfd.h>
#include <sys/resource.h>
#include <sys/epoll.h>
#include <sys/personality.h>
#include <unistd.h>

#include "uftrace.h"
#include "libmcount/mcount.h"
#include "utils/utils.h"
#include "utils/symbol.h"
#include "utils/list.h"
#include "uftrace.h"
#include "utils/filter.h"
#include "utils/kernel.h"
#include "utils/list.h"
#include "utils/perf.h"
#include "utils/symbol.h"
#include "utils/utils.h"

#ifndef EFD_SEMAPHORE
#define EFD_SEMAPHORE (1 << 0)
Expand Down
Loading

0 comments on commit fb495a8

Please sign in to comment.