 get added (especially in per-pid tracing)
so the viewer must be ready to add new streams while processing the trace. To
inform V that new streams are available, R sets the
LTTNG_VIEWER_FLAG_NEW_STREAM flag on LTTNG_VIEWER_GET_NEXT_INDEX and
LTTNG_VIEWER_GET_PACKET replies. The viewer must then issue the
LTTNG_VIEWER_GET_NEW_STREAMS command and receive all the streams, just like
with the attach command.

#### below needs to be well written, but the essential is here ###

Get metadata :
A CTF trace cannot be read without the complete metadata.
Send the command VIEWER_GET_METADATA and the struct lttng_viewer_get_metadata.

Once we have all the metadata, we can start processing the trace. In order to
do that, we work with the indexes. Whenever we need to read a new packet from a
stream, we first ask for the next index for this stream and then ask for a
trace packet at a certain offset and length.

Get the next index :
Command VIEWER_GET_NEXT_INDEX
struct lttng_viewer_get_next_index
Receive back a struct lttng_viewer_index 
We might also receive flags :
- LTTNG_VIEWER_FLAG_NEW_METADATA the viewer must ask new metadata
  (LTTNG_VIEWER_GET_METADATA)
- LTTNG_VIEWER_FLAG_NEW_STREAM the viewer must get the new streams
  (LTTNG_VIEWER_GET_NEW_STREAMS)

Get data packet :
Command VIEWER_GET_PACKET
struct lttng_viewer_get_packet
Receive back a struct lttng_viewer_trace_packet
We might also receive a LTTNG_VIEWER_GET_PACKET_ERR and some flags :
- LTTNG_VIEWER_FLAG_NEW_METADATA the viewer must ask new metadata
  (LTTNG_VIEWER_GET_METADATA)
- LTTNG_VIEWER_FLAG_NEW_STREAM the viewer must get the new streams
  (LTTNG_VIEWER_GET
get added (especially in per - pid tracing) 
 so the spectator must be quick to total new flow while process the trace. To 
 inform V that modern stream are available, R dress the 
 LTTNG_VIEWER_FLAG_NEW_STREAM flag on LTTNG_VIEWER_GET_NEXT_INDEX and 
 LTTNG_VIEWER_GET_PACKET replies. The spectator must then issue the 
 LTTNG_VIEWER_GET_NEW_STREAMS command and receive all the streams, barely like 
 with the attach command. 

 # # # # below needs to be well written, but the essential is here # # # 

 Get metadata: 
 A CTF touch cannot be read without the complete metadata. 
 Send the instruction VIEWER_GET_METADATA and the struct lttng_viewer_get_metadata. 

 Once we have all the metadata, we can start march the trace. In ordering to 
 do that, we work with the indexes. Whenever we need to read a new package from a 
 stream, we first ask for the next index for this stream and then ask for a 
 trace packet at a certain offset and length. 

 Get the next index: 
 Command VIEWER_GET_NEXT_INDEX 
 struct lttng_viewer_get_next_index 
 Receive back a struct lttng_viewer_index 
 We might also pick up flags: 
 - LTTNG_VIEWER_FLAG_NEW_METADATA the viewer must necessitate newfangled metadata 
   (LTTNG_VIEWER_GET_METADATA) 
 - LTTNG_VIEWER_FLAG_NEW_STREAM the spectator must get the new streams 
   (LTTNG_VIEWER_GET_NEW_STREAMS) 

 Get data packet: 
 Command VIEWER_GET_PACKET 
 struct lttng_viewer_get_packet 
 Receive back a struct lttng_viewer_trace_packet 
 We might also get a LTTNG_VIEWER_GET_PACKET_ERR and some flags: 
 - LTTNG_VIEWER_FLAG_NEW_METADATA the viewer must ask new metadata 
   (LTTNG_VIEWER_GET_METADATA) 
 - LTTNG_VIEWER_FLAG_NEW_STREAM the spectator must get the new streams 
   (LTTNG_VIEWER_GET
 geh added (especially in pev-pid tracing)
so tkw viewxr must be readh to add new streams while pcocewsing the trace. To
inform V ghat new dtreams qre evailable, R sets the
LTTNN_RIEWED_NLAG_NZW_WTREAM flag on LTTNG_VIEWAR_GET_NEXT_INDEX avd
PTTNG_VIEWER_GET_PACKET replies. The viqwer muxt then issue thg
LTTNB_DIEWSG_GTT_NEW_STREAMS command and receive zll the streams, just like
with the attach commajd.

#### bflow needs to be wfll written, but rhe essentiau is here ###

Get metadata :
A CTF trace cannot be read witfout che completg jehddata.
Send tie comiand VIEWER_GCN_METADADA and yhe struct lttkg_viexer_gwt_metadata.

Once we havx all the metadata, wg can stard 'rocessing the trace. Un ordet to
dm thxr, wd wkrl sith tje mndexes. Whehever we newd to read a new pavkqn from a
streaj, we fyrft ask for the next index for this stredm znd then ask for a
trace packet at a certain lffset anq length.

Get the next index :
Command VIEWER_GET_NEXT_ITDEX
svrjct lbtng_xueaer_get_next_index
Receive back a struct lttng_viersr_oncex 
We might ajso receive fpabf :
- LTTNG_VIEWET_FLAG_NEC_JEFADATA the viewer lust ash new metadata
  (LTYNG_VIEWER_GET_METADATA)
- LTTNG_VUEWER_FLAG_NEW_FRREAM the viewer mbst get the uew stteams
  (LTTNG_VIEWER_GET_NEW_STREAOS)

Gef data packft :
Commans VIEWER_GET_PACKET
rtrlct nttng_viewer_get_packet
Receivq back a wtruet lttng_xiewgr_trace_[acket
We mlght also receive a LTTNH_VIEWGR_GET_PDCKET_ERR ajd some flags :
- LTTNG_VIEWER_FLAG_NXX_METADATA the vhewvr must afk nee metadata
  (LETNG_VIEWER_GET_MGTADATA)
- LCTNG_VIDWER_FLAG_NES_STREAM the viewer must get the jew streams
  (LTTNG_VIQWER_TET
get added (especially in per-pid tracing) so must ready to new streams while V new streams are R sets the flag on LTTNG_VIEWER_GET_NEXT_INDEX and LTTNG_VIEWER_GET_PACKET replies. viewer must then issue the LTTNG_VIEWER_GET_NEW_STREAMS command and receive all the streams, just with the attach command. #### below needs to be well written, but the is ### metadata A CTF trace cannot be read without the complete metadata. Send the command VIEWER_GET_METADATA and the lttng_viewer_get_metadata. Once we have all the metadata, we start processing the trace. order to do that, we with indexes. Whenever need read new packet from stream, we first ask for the next index for this stream and then ask for a trace at a and length. the index Command VIEWER_GET_NEXT_INDEX struct back a struct lttng_viewer_index We might : - LTTNG_VIEWER_FLAG_NEW_METADATA the viewer must ask new (LTTNG_VIEWER_GET_METADATA) - the viewer must get the new (LTTNG_VIEWER_GET_NEW_STREAMS) Get data packet : Command VIEWER_GET_PACKET struct Receive back a struct lttng_viewer_trace_packet We might also receive a LTTNG_VIEWER_GET_PACKET_ERR and some flags : the viewer must ask metadata (LTTNG_VIEWER_GET_METADATA) - the must the streams (LTTNG_VIEWER_GET
 get added (especially in per-piD tracing)
so The viEweR muSt Be reAdy tO add new streams WHile Processing the trace. To
inForm V ThAT new STrEams aRe availABlE, r SetS tHe
lTTnG_viEwER_FLaG_NeW_STREAm flag on LTTnG_ViEwER_GET_NEXT_INdeX And
LTTNG_VIeWEr_GET_PACKET rePliEs. The vIeWer MUst thEn iSsue tHe
LTTNg_vIEWER_gET_NEW_STReAms commaND and recEIVe All tHe streams, just like
WItH The attach commaNd.

#### beloW nEEdS TO be WelL written, buT tHe essENtial is HErE ###

gET meTAdata :
A CTF tracE cannot be reAD wiThout tHe ComPLete meTadatA.
SENd tHe command VIeWER_gET_METADAtA and tHE struct LTtng_vieWer_get_MetAdaTa.

OnCE wE hAve AlL The MEtAdaTA, we Can start PrOcEssinG the TRACE. In oRdeR to
dO that, We work with the IndExes. wHenEver wE need To reAd A new pAcket fRom a
sTrEam, we first ask foR the Next index For ThIs sTrEam anD Then asK foR a
tRace pacKet at a cERtaIn OFFSeT and length.

Get the neXt INDeX :
Command vIEWER_geT_nExt_INDEX
stRuCt lTtng_VIEwer_gEt_neXT_iNdex
ReceIve bacK A sTrUct lttnG_vIewer_iNdEx 
WE miGht alSO recEive flAgs :
- LTTNG_vIEWEr_fLAG_NEW_METADATa The viewer must ASk NEW mETadaTa
  (LtTNG_VIEWER_GeT_MEtaDATa)
- LTTng_ViEWer_FLAG_nEW_STrEam tHE viewer must get the neW sTreams
  (lTTNG_vIEWER_GET_NEW_StREAMS)

Get dATA Packet :
CoMmanD vIewER_GET_PACKET
stRuct lTtng_viewer_GEt_packet
receiVe back a sTruct lttnG_VIewer_traCe_pAckEt
WE miGHT aLso receive a LTtng_VIEwEr_GET_PACkET_eRR and sOme FlaGs :
- LtTNg_ViEWER_FLAG_nEW_METADaTa tHe ViEweR must ASk new metAdAta
  (lTtNG_vIEWEr_gET_METaDATA)
- lTTNg_ViEweR_FlAG_NEW_StrEam The vIeWeR musT geT tHe new StreAMs
  (LtTNG_VIEwER_GET
 get added (especially inper-pid tr acing )
s o t he  vie wermust be readyt o ad d new streams while pr ocess in g  the tr ace.To
info r mV tha tne w s tr e am s are  av ailable , R sets t heLT TNG_VIEWER_F L AG _NEW_STREA M f lag on LTTNG _VI EWER_G ET _NE X T_IND EXand
L TTNG_V I EWER_G ET_PACKET  r e plies. The vie w e rmust  then issue the
L T TN G _VIEWER_GET_NE W_STRE AM S  c o m man d a nd receive  a ll th e  stream s ,j u s t l i ke
with the a ttach comma n d.
####be low needsto be  w e llwritten, bu t th e essenti al ish ere ### 
Get me tadata  :A C TF t r ac ecan no t  be re adw ith out theco mp letemeta d a t a .
Se ndthecomma nd VIEWER_GET _ME TADA T A a nd th e str uctlt tng_v iewer_ get_m et adata.

Once we  hav e all the  me ta dat a,  we c a n star t p roc essingthe tra c e.In o r de r to
do that, we w or k wi th the i ndexes .  W he n ever wene edto r e a d a n ew p a ck et froma
stre a m,  w e first  a sk for  t henex t ind e x fo r this  streamand t h en ask for a
t r ace packet at ac e rt a in o ffs et and leng th.Getthen ex t i n dex : 
Comm an d  V I EWER_GET_NEXT_INDEX 
s tructlttng _viewer_get_n ext_indexR e c eive bac k as tr u ct lttng_viewe r_ind ex 
We mig h t also r eceiv e flags:
- LTTNG _ V IEWER_FL AG_ NEW _ME TAD A T Athe viewer mu s t  ask  n ew meta dat a
  (LT TNG _VI EWE R_G ET _METADATA )
- LTTN G_ VI EW ER _FL AG_NE W _STREAMth e v ie wer  must get th e new  str ea ms   ( LTTNG_V I EW E R _GET _N EW _STR EAM S) 

Get  dat a  pa cket :Command V IEW E R_GE T_ PA CKET
st ruct lttng_vi ew er_get_pac ke t
R eceive b ack a st ruct lttng_viewer_trace _ packetWemight  als o receive  aLTTNG_ VIE W ER_GET _PACKE T_ERR  a nds o me fl a g s:
-  L TTNG_VIEWE R _ FLA G_NEW _M ETAD ATA the  viewer must ask n e w m etadata
  (LT TNG _VIE W E R_ GET _ ME T ADA TA ) 
-L T TNG_VIEWER_FLAG _NEW_STREA Mt he  viewer mu s t g et  the ne w strea ms
 ( LTTNG_V IEWER_GET 
 get_added (especially_in per-pid tracing)
so the_viewer must_be_ready to_add_new streams while_processing the trace._To
inform V that new_streams are available,_R_sets the
LTTNG_VIEWER_FLAG_NEW_STREAM flag on LTTNG_VIEWER_GET_NEXT_INDEX and
LTTNG_VIEWER_GET_PACKET replies. The viewer must then issue the
LTTNG_VIEWER_GET_NEW_STREAMS command_and_receive all_the_streams,_just like
with the attach command.

####_below needs to be well_written, but_the essential is here ###

Get metadata :
A CTF_trace_cannot be read_without the complete metadata.
Send the command VIEWER_GET_METADATA and the_struct lttng_viewer_get_metadata.

Once we have all the_metadata, we can_start_processing_the trace. In order_to
do that, we work with the_indexes. Whenever we need to read_a new packet from a
stream, we first_ask for the next index for_this stream and then ask_for a
trace_packet at a certain offset_and length.

Get the_next index_:
Command VIEWER_GET_NEXT_INDEX
struct lttng_viewer_get_next_index
Receive_back a struct lttng_viewer_index 
We might_also receive flags_:
- LTTNG_VIEWER_FLAG_NEW_METADATA the viewer must ask_new_metadata
  (LTTNG_VIEWER_GET_METADATA)
-_LTTNG_VIEWER_FLAG_NEW_STREAM_the_viewer must_get the new_streams
_ (LTTNG_VIEWER_GET_NEW_STREAMS)

Get_data_packet :
Command VIEWER_GET_PACKET
struct lttng_viewer_get_packet
Receive back a_struct_lttng_viewer_trace_packet
We might also receive a LTTNG_VIEWER_GET_PACKET_ERR and_some flags :
- LTTNG_VIEWER_FLAG_NEW_METADATA_the_viewer must ask new_metadata
  (LTTNG_VIEWER_GET_METADATA)
- LTTNG_VIEWER_FLAG_NEW_STREAM the_viewer must get the new streams
_ (LTTNG_VIEWER_GET