Skip to content

Commit

Permalink
Fixes for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Jul 30, 2023
1 parent d9cd5f0 commit 5eb3552
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 35 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,9 @@ Dependencies
* libczmq-dev
* ncurses
* libsdl
* libdw-dev
* libelf-dev
* libcapstone-dev

Note that `objdump` version at least 2.33.1 is also required. By default the suite will run `arm-none-eabi-objdump` but another binary or pathname can be subsituted via the OBJDUMP environment variable.

Build
-----

Expand All @@ -261,7 +258,7 @@ If you do want to build the system, then the command line to build the Orbuculum
>ninja -C build
```

You may need to change the paths to your libusb files, depending on how well your build environment is set up.
You may need to change the paths to your libusb files, depending on how well your build environment is set up. It's also worth noting that Ubuntu comes with a pretty old version of meson so if you get errors you may need to install a more recent one via pip.

Permissions and Access
----------------------
Expand Down
54 changes: 39 additions & 15 deletions Src/getline.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,73 @@
#include <stdio.h>
#include <stdlib.h>

size_t getline(char **lineptr, size_t *n, FILE *stream) {
size_t getline( char **lineptr, size_t *n, FILE *stream )
{
char *bufptr = NULL;
char *p = bufptr;
size_t size;
int c;

if (lineptr == NULL) {
if ( lineptr == NULL )
{
return -1;
}
if (stream == NULL) {

if ( stream == NULL )
{
return -1;
}
if (n == NULL) {

if ( n == NULL )
{
return -1;
}

bufptr = *lineptr;
size = *n;

c = fgetc(stream);
if (c == EOF) {
c = fgetc( stream );

if ( c == EOF )
{
return -1;
}
if (bufptr == NULL) {
bufptr = malloc(128);
if (bufptr == NULL) {

if ( bufptr == NULL )
{
bufptr = malloc( 128 );

if ( bufptr == NULL )
{
return -1;
}

size = 128;
}

p = bufptr;
while(c != EOF) {
if ((p - bufptr) > (size - 1)) {

while ( c != EOF )
{
if ( ( p - bufptr ) > ( size - 1 ) )
{
size = size + 128;
bufptr = realloc(bufptr, size);
if (bufptr == NULL) {
bufptr = realloc( bufptr, size );

if ( bufptr == NULL )
{
return -1;
}
}

*p++ = c;
if (c == '\n') {

if ( c == '\n' )
{
break;
}
c = fgetc(stream);

c = fgetc( stream );
}

*p++ = '\0';
Expand Down
24 changes: 9 additions & 15 deletions Src/loadelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "generics.h"

#if defined(WIN32)
extern size_t getline(char **lineptr, size_t *n, FILE *stream);
extern size_t getline( char **lineptr, size_t *n, FILE *stream );
#endif

#define MAX_LINE_LEN (4095)
Expand Down Expand Up @@ -250,7 +250,7 @@ static void _dump_die_attribs( Dwarf_Debug dbg, Dwarf_Die die )
}

dwarf_get_AT_name( attr, &name );
printf( "Attribute Name: %s\n", name );
fprintf( stderr, "Attribute Name: %s\n", name );
}

// Free attribute list
Expand Down Expand Up @@ -278,11 +278,6 @@ static void _getSourceLines( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die die )
Dwarf_Bool begin;
Dwarf_Bool isset;

//Dwarf_Bool ispend;
//Dwarf_Bool ispbegin;
//Dwarf_Unsigned isa;
//Dwarf_Unsigned disc;

/* Now, for each source line, pull it into the line storage */
if ( DW_DLV_OK == dwarf_srclines_b( die, &version, &tc, &linecontext, 0 ) )
{
Expand Down Expand Up @@ -313,12 +308,12 @@ static void _getSourceLines( struct symbol *p, Dwarf_Debug dbg, Dwarf_Die die )
if ( ( zero_start_dont_store && ( ( !begin ) || ( !line_addr ) || ( ( line_addr - tracked_addr ) < 16 ) ) ) )
{
zero_start_dont_store = true;
// printf("!");
// printf("!");
}
else
{
/* We are going to store this one */
//if (zero_start_dont_store) printf("\n%08x: ",(uint32_t)line_addr);
// if (zero_start_dont_store) printf("\n%08x: ",(uint32_t)line_addr);
//else printf("*");
zero_start_dont_store = false;
dwarf_lineno( linebuf[i], &line_num, 0 );
Expand Down Expand Up @@ -476,7 +471,7 @@ static bool _readLines( int fd, struct symbol *p )
Dwarf_Addr cu_low_addr;
Dwarf_Half address_size;
Dwarf_Unsigned next_cu_header = 0;
Dwarf_Die cu_die;
Dwarf_Die cu_die;

bool retval = false;
Dwarf_Half dw_length_size;
Expand Down Expand Up @@ -518,9 +513,11 @@ static bool _readLines( int fd, struct symbol *p )

/* 1: Collect the functions and lines */
/* ---------------------------------- */
while ( ( 0 == dwarf_next_cu_header_d( dbg, 0, &cu_header_length, &version_stamp, &abbrev_offset, &address_size, &dw_length_size, &dw_extension_size, &dw_type_signature, &dw_typeoffset, &next_cu_header, &dw_header_cu_type, &err ) ) )
while ( ( 0 == dwarf_next_cu_header_d( dbg, true, &cu_header_length, &version_stamp, &abbrev_offset, &address_size, &dw_length_size, &dw_extension_size, &dw_type_signature, &dw_typeoffset,
&next_cu_header, &dw_header_cu_type, &err ) ) )
{
dwarf_siblingof_b( dbg, NULL, 0, &cu_die, &err );
dwarf_siblingof_b( dbg, NULL, true, &cu_die, &err );

dwarf_diename( cu_die, &name, 0 );
dwarf_die_text( cu_die, DW_AT_producer, &producer, 0 );
dwarf_die_text( cu_die, DW_AT_comp_dir, &compdir, 0 );
Expand Down Expand Up @@ -565,9 +562,6 @@ static bool _readLines( int fd, struct symbol *p )

p->nlines--;
}

/* Now set the high extent address to one less than the low address of the following line */
// p->line[i-1]->highaddr = p->line[i]->lowaddr-1;
}

/* Now do the same for lines with the same line number and file */
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

project('orbuculum', 'c', meson_version: '>=0.63')
project('orbuculum', 'c', version:'2.1.0', meson_version: '>=0.63')

uicolours_default = declare_dependency(compile_args: ['-include', 'uicolours_default.h'])
if host_machine.system() == 'windows'
Expand Down

0 comments on commit 5eb3552

Please sign in to comment.