@@ -1976,20 +1976,60 @@ static int drain_events_block(struct ptxed_decoder *decoder, uint64_t *time,
1976
1976
return status ;
1977
1977
}
1978
1978
1979
+ static int decode_one_block (struct ptxed_decoder * decoder ,
1980
+ const struct ptxed_options * options ,
1981
+ struct ptxed_stats * stats ,
1982
+ struct pt_block * block ,
1983
+ uint64_t time )
1984
+ {
1985
+ struct pt_block_decoder * ptdec ;
1986
+ uint64_t offset ;
1987
+ int status ;
1988
+
1989
+ if (!decoder || !options || !block )
1990
+ return - pte_internal ;
1991
+
1992
+ ptdec = decoder -> variant .block ;
1993
+ offset = 0ull ;
1994
+
1995
+ if (options -> print_offset || options -> check ) {
1996
+ status = pt_blk_get_offset (ptdec , & offset );
1997
+ if (status < 0 )
1998
+ return status ;
1999
+ }
2000
+
2001
+ status = pt_blk_next (ptdec , block , sizeof (* block ));
2002
+
2003
+ /* Even in case of errors, we may have succeeded in decoding some
2004
+ * instructions.
2005
+ */
2006
+ if (stats ) {
2007
+ stats -> insn += block -> ninsn ;
2008
+ stats -> blocks += 1 ;
2009
+ }
2010
+
2011
+ if (!options -> quiet )
2012
+ print_block (decoder , block , options , stats , offset , time );
2013
+
2014
+ if (options -> check )
2015
+ check_block (decoder , block , offset );
2016
+
2017
+ return status ;
2018
+ }
2019
+
1979
2020
static void decode_block (struct ptxed_decoder * decoder ,
1980
2021
const struct ptxed_options * options ,
1981
2022
struct ptxed_stats * stats )
1982
2023
{
1983
2024
struct pt_block_decoder * ptdec ;
1984
- uint64_t offset , sync , time ;
2025
+ uint64_t sync , time ;
1985
2026
1986
2027
if (!decoder || !options ) {
1987
2028
printf ("[internal error]\n" );
1988
2029
return ;
1989
2030
}
1990
2031
1991
2032
ptdec = decoder -> variant .block ;
1992
- offset = 0ull ;
1993
2033
sync = 0ull ;
1994
2034
time = 0ull ;
1995
2035
for (;;) {
@@ -2039,46 +2079,10 @@ static void decode_block(struct ptxed_decoder *decoder,
2039
2079
break ;
2040
2080
}
2041
2081
2042
- if (options -> print_offset || options -> check ) {
2043
- status = pt_blk_get_offset (ptdec , & offset );
2044
- if (status < 0 )
2045
- break ;
2046
- }
2047
-
2048
- status = pt_blk_next (ptdec , & block , sizeof (block ));
2049
- if (status < 0 ) {
2050
- /* Even in case of errors, we may have succeeded
2051
- * in decoding some instructions.
2052
- */
2053
- if (block .ninsn ) {
2054
- if (stats ) {
2055
- stats -> insn += block .ninsn ;
2056
- stats -> blocks += 1 ;
2057
- }
2058
-
2059
- if (!options -> quiet )
2060
- print_block (decoder , & block ,
2061
- options , stats ,
2062
- offset , time );
2063
-
2064
- if (options -> check )
2065
- check_block (decoder , & block ,
2066
- offset );
2067
- }
2082
+ status = decode_one_block (decoder , options , stats ,
2083
+ & block , time );
2084
+ if (status < 0 )
2068
2085
break ;
2069
- }
2070
-
2071
- if (stats ) {
2072
- stats -> insn += block .ninsn ;
2073
- stats -> blocks += 1 ;
2074
- }
2075
-
2076
- if (!options -> quiet )
2077
- print_block (decoder , & block , options , stats ,
2078
- offset , time );
2079
-
2080
- if (options -> check )
2081
- check_block (decoder , & block , offset );
2082
2086
}
2083
2087
2084
2088
/* We're done when we reach the end of the trace stream. */
0 commit comments