Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clang-format stuff #11

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ BasedOnStyle: LLVM
IndentWidth: 4
UseTab: Never
BreakBeforeBraces: Linux
AlwaysBreakBeforeMultilineStrings: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
Expand All @@ -14,8 +13,6 @@ AlignOperands: true
AllowAllParametersOfDeclarationOnNextLine: false
AlignAfterOpenBracket: true
SpaceAfterCStyleCast: false
MaxEmptyLinesToKeep: 2
BreakBeforeBinaryOperators: NonAssignment
BreakStringLiterals: false
SortIncludes: false
ContinuationIndentWidth: 4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config.h
libtrdb.a
tests
trdb
benchmarks


Makefile.in
Expand Down
26 changes: 10 additions & 16 deletions src/disassembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ int trdb_init_disassembler_unit_for_pulp(struct disassembler_unit *dunit,
return -trdb_invalid;
trdb_init_disassemble_info_for_pulp(dinfo);
dinfo->disassembler_options = options;
dunit->disassemble_fn = disassembler(bfd_arch_riscv, false,
bfd_mach_riscv32, NULL);
dunit->disassemble_fn =
disassembler(bfd_arch_riscv, false, bfd_mach_riscv32, NULL);
return 0;
}

Expand Down Expand Up @@ -157,10 +157,8 @@ int trdb_init_disassembler_unit(struct disassembler_unit *dunit, bfd *abfd,
return -trdb_invalid;

trdb_init_disassemble_info_from_bfd(dinfo, abfd, options);
dunit->disassemble_fn = disassembler(bfd_get_arch(abfd),
bfd_big_endian(abfd),
bfd_get_mach(abfd),
abfd);
dunit->disassemble_fn = disassembler(
bfd_get_arch(abfd), bfd_big_endian(abfd), bfd_get_mach(abfd), abfd);
if (!dunit->disassemble_fn)
return -trdb_arch_support;

Expand Down Expand Up @@ -557,10 +555,9 @@ find_symbol_for_address(bfd_vma vma, struct disassemble_info *inf, long *place)
* the relocation table. Also give the target a chance to reject symbols.
*/
want_section =
(aux->require_sec || ((abfd->flags & HAS_RELOC) != 0 &&
vma >= bfd_section_vma(sec) &&
vma < (bfd_section_vma(sec) +
bfd_section_size(sec) / opb)));
(aux->require_sec ||
((abfd->flags & HAS_RELOC) != 0 && vma >= bfd_section_vma(sec) &&
vma < (bfd_section_vma(sec) + bfd_section_size(sec) / opb)));
if ((sorted_syms[thisplace]->section != sec && want_section) ||
!inf->symbol_is_valid(sorted_syms[thisplace], inf)) {
long i;
Expand Down Expand Up @@ -656,8 +653,7 @@ static void trdb_print_addr_with_sym(bfd *abfd, asection *sec, asymbol *sym,
if (sym == NULL) {
bfd_vma secaddr;

(*inf->fprintf_func)(inf->stream, " <%s",
bfd_section_name(sec));
(*inf->fprintf_func)(inf->stream, " <%s", bfd_section_name(sec));
secaddr = bfd_section_vma(sec);
if (vma < secaddr) {
(*inf->fprintf_func)(inf->stream, "-0x");
Expand Down Expand Up @@ -873,10 +869,8 @@ int trdb_alloc_dinfo_with_bfd(struct trdb_ctx *c, bfd *abfd,
}

/* Use libopcodes to locate a suitable disassembler. */
dunit->disassemble_fn = disassembler(bfd_get_arch(abfd),
bfd_big_endian(abfd),
bfd_get_mach(abfd),
abfd);
dunit->disassemble_fn = disassembler(
bfd_get_arch(abfd), bfd_big_endian(abfd), bfd_get_mach(abfd), abfd);
if (!dunit->disassemble_fn) {
err(c, "can't disassemble for architecture %s\n",
bfd_printable_arch_mach(bfd_get_arch(abfd), 0));
Expand Down
3 changes: 1 addition & 2 deletions src/trace_debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1864,8 +1864,7 @@ int trdb_decompress_trace(struct trdb_ctx *c, bfd *abfd,
status = -trdb_bad_vma;
goto fail;
}
stop_offset =
bfd_section_size(section) / dinfo.octets_per_byte;
stop_offset = bfd_section_size(section) / dinfo.octets_per_byte;

free_section_for_debugging(&dinfo);
if ((status = alloc_section_for_debugging(c, abfd, section,
Expand Down
4 changes: 2 additions & 2 deletions src/trdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ static int disassemble_trace(struct trdb_ctx *c, FILE *output_fp, bfd *abfd,
/* if we can't use a bfd assume its pulp riscv */
init_disassemble_info(&dinfo, stdout, (fprintf_ftype)fprintf);
trdb_init_disassemble_info_for_pulp(&dinfo);
dunit.disassemble_fn = disassembler(bfd_arch_riscv, false,
bfd_mach_riscv32, NULL);
dunit.disassemble_fn =
disassembler(bfd_arch_riscv, false, bfd_mach_riscv32, NULL);
}

trdb_disassemble_trace(samplecnt, *samples, &dunit);
Expand Down
16 changes: 8 additions & 8 deletions test/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ static int test_disasm_bfd()
/* set up disassembly context */
struct disassembler_unit dunit = {0};
dunit.dinfo = &dinfo;
dunit.disassemble_fn = disassembler(bfd_get_arch(abfd),
bfd_big_endian(abfd),
bfd_get_mach(abfd),
abfd);
dunit.disassemble_fn = disassembler(
bfd_get_arch(abfd), bfd_big_endian(abfd), bfd_get_mach(abfd), abfd);
if (!dunit.disassemble_fn) {
LOG_ERRT("No suitable disassembler found\n");
return TRDB_FAIL;
Expand Down Expand Up @@ -878,8 +876,9 @@ static int test_decompress_trace(const char *bin_path, const char *trace_path)
}

static int test_decompress_cvs_trace_differential(const char *bin_path,
const char *trace_path,
bool differential, bool implicit_ret)
const char *trace_path,
bool differential,
bool implicit_ret)
{
bfd *abfd = NULL;
size_t instrcnt = 0;
Expand Down Expand Up @@ -1001,8 +1000,9 @@ static int test_decompress_cvs_trace_differential(const char *bin_path,
}

static int test_decompress_trace_differential(const char *bin_path,
const char *trace_path,
bool differential, bool implicit_ret)
const char *trace_path,
bool differential,
bool implicit_ret)
{
bfd *abfd = NULL;
struct tr_instr *tmp = NULL;
Expand Down
Loading